static void osinterface_create_window() { SDL_SysWMinfo wmInfo; HWND hWnd; int width, height; if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Error: SDL_Init\n"); exit(-1); } // stuff { RCT2_CALLPROC_EBPSAFE(0x0068352C); RCT2_CALLPROC_EBPSAFE(0x0068371D); width = RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_RESOLUTION_WIDTH, sint16); height = RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_RESOLUTION_HEIGHT, sint16); width = 640; height = 480; } RCT2_GLOBAL(0x009E2D8C, sint32) = 0; _window = SDL_CreateWindow("OpenRCT2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_RESIZABLE); // Get the HWND context SDL_GetWindowWMInfo(_window, &wmInfo); hWnd = wmInfo.info.win.window; RCT2_GLOBAL(0x009E2D70, HWND) = hWnd; // Set the update palette function pointer RCT2_GLOBAL(0x009E2BE4, update_palette_func) = osinterface_update_palette; // Initialise the surface, palette and draw buffer osinterface_resize(width, height); }
static void window_cheats_mouseup() { int i; short widgetIndex; rct_window *w; __asm mov widgetIndex, dx __asm mov w, esi switch (widgetIndex) { case WIDX_CLOSE: window_close(w); break; case WIDX_HIGH_MONEY: i = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32)); i += 100000; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(i); window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0); break; } }
/** * * rct2: 0x004080EA */ int osinterface_open_common_file_dialog(int type, char *title, char *filename, char *filterPattern, char *filterName) { char initialDirectory[MAX_PATH], *dotAddress, *slashAddress; OPENFILENAME openFileName; BOOL result; int tmp; DWORD commonFlags; // Get directory path from given filename strcpy(initialDirectory, filename); dotAddress = strrchr(initialDirectory, '.'); if (dotAddress != NULL) { slashAddress = strrchr(initialDirectory, '\\'); if (slashAddress < dotAddress) *(slashAddress + 1) = 0; } // Clear filename if (type != 0) *filename = 0; // Set open file name options memset(&openFileName, 0, sizeof(OPENFILENAME)); openFileName.lStructSize = sizeof(OPENFILENAME); openFileName.hwndOwner = RCT2_GLOBAL(0x009E2D70, HWND); openFileName.lpstrFile = filename; openFileName.nMaxFile = MAX_PATH; openFileName.lpstrInitialDir = initialDirectory; openFileName.lpstrTitle = title; // Copy filter name strcpy((char*)0x01423800, filterName); // Copy filter pattern strcpy((char*)0x01423800 + strlen(filterName) + 1, filterPattern); *((char*)(0x01423800 + strlen(filterName) + 1 + strlen(filterPattern) + 1)) = 0; openFileName.lpstrFilter = (char*)0x01423800; // tmp = RCT2_GLOBAL(0x009E2C74, uint32); if (RCT2_GLOBAL(0x009E2BB8, uint32) == 2 && RCT2_GLOBAL(0x009E1AF8, uint32) == 1) RCT2_GLOBAL(0x009E2C74, uint32) = 1; // Open dialog commonFlags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR; if (type == 0) { openFileName.Flags = commonFlags | OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT; result = GetSaveFileName(&openFileName); } else if (type == 1) { openFileName.Flags = commonFlags | OFN_NONETWORKBUTTON | OFN_FILEMUSTEXIST; result = GetOpenFileName(&openFileName); } // RCT2_GLOBAL(0x009E2C74, uint32) = tmp; return result; }
void game_handle_key_scroll() { rct_window *mainWindow; int scrollX, scrollY; mainWindow = window_get_main(); if (mainWindow == NULL) return; if ((mainWindow->flags & WF_2) || (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 9)) return; if (mainWindow->viewport == NULL) return; scrollX = 0; scrollY = 0; // Scroll left / right if (gKeysState[SDL_SCANCODE_LEFT]) scrollX = -1; else if (gKeysState[SDL_SCANCODE_RIGHT]) scrollX = 1; // Scroll up / down if (gKeysState[SDL_SCANCODE_UP]) scrollY = -1; else if (gKeysState[SDL_SCANCODE_DOWN]) scrollY = 1; // Scroll viewport if (scrollX != 0) { mainWindow->saved_view_x += scrollX * (12 << mainWindow->viewport->zoom); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 7); } if (scrollY != 0) { mainWindow->saved_view_y += scrollY * (12 << mainWindow->viewport->zoom); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 7); } }
/** * * rct2: 0x006CF2D6 */ static void window_track_list_invalidate(rct_window *w) { rct_ride_entry *entry; rct_string_id stringId; colour_scheme_update(w); entry = get_ride_entry(_window_track_list_item.entry_index); stringId = entry->name; if (!(entry->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME) || rideTypeShouldLoseSeparateFlag(entry)) stringId = _window_track_list_item.type + 2; RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = stringId; if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) { window_track_list_widgets[WIDX_TITLE].image = STR_TRACK_DESIGNS; window_track_list_widgets[WIDX_TRACK_LIST].tooltip = STR_CLICK_ON_DESIGN_TO_RENAME_OR_DELETE_IT; } else { window_track_list_widgets[WIDX_TITLE].image = STR_SELECT_DESIGN; window_track_list_widgets[WIDX_TRACK_LIST].tooltip = STR_CLICK_ON_DESIGN_TO_BUILD_IT_TIP; } if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) || w->track_list.var_482 != 0) { w->pressed_widgets |= 1 << WIDX_TRACK_PREVIEW; w->disabled_widgets &= ~(1 << WIDX_TRACK_PREVIEW); window_track_list_widgets[WIDX_ROTATE].type = WWT_FLATBTN; window_track_list_widgets[WIDX_TOGGLE_SCENERY].type = WWT_FLATBTN; if (RCT2_GLOBAL(RCT2_ADDRESS_TRACK_DESIGN_SCENERY_TOGGLE, uint8) == 0) w->pressed_widgets |= (1 << WIDX_TOGGLE_SCENERY); else w->pressed_widgets &= ~(1 << WIDX_TOGGLE_SCENERY); } else { w->pressed_widgets &= ~(1 << WIDX_TRACK_PREVIEW); w->disabled_widgets |= (1 << WIDX_TRACK_PREVIEW); window_track_list_widgets[WIDX_ROTATE].type = WWT_EMPTY; window_track_list_widgets[WIDX_TOGGLE_SCENERY].type = WWT_EMPTY; } }
/** * * rct2: 0x006EB951 */ static void widget_draw_image(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) { int l, t, r, b, colour, image; rct_widget *widget; // Get the widget widget = &w->widgets[widgetIndex]; // Get the image image = widget->image; if (image == -1) return; // Resolve the absolute ltrb l = w->x + widget->left; t = w->y + widget->top; r = w->x + widget->right; b = w->y + widget->bottom; // Get the colour colour = w->colours[widget->colour]; if (widget->type == WWT_4 || widget->type == WWT_6 || widget->type == WWT_TRNBTN || widget->type == WWT_TAB) if (widget_is_pressed(w, widgetIndex) || widget_is_active_tool(w, widgetIndex)) image++; if (widget_is_disabled(w, widgetIndex)) { // Draw greyed out (light border bottom right shadow) colour = w->colours[widget->colour]; colour = RCT2_ADDRESS(0x00141FC4A, uint8)[(colour & 0x7F) * 8] & 0xFF; RCT2_GLOBAL(0x009ABDA4, uint32) = 0x009DED74; memset(0x009DED74, colour, 256); RCT2_GLOBAL(0x009DED74, uint8) = 0; RCT2_GLOBAL(0x00EDF81C, uint32) = 0x20000000; image &= 0x7FFFF; RCT2_CALLPROC_X(0x0067A46E, 0, image, l + 1, t + 1, 0, dpi, 0); // Draw greyed out (dark) colour = w->colours[widget->colour]; colour = RCT2_ADDRESS(0x00141FC48, uint8)[(colour & 0x7F) * 8] & 0xFF; RCT2_GLOBAL(0x009ABDA4, uint32) = 0x009DED74; memset(0x009DED74, colour, 256); RCT2_GLOBAL(0x009DED74, uint8) = 0; RCT2_GLOBAL(0x00EDF81C, uint32) = 0x20000000; RCT2_CALLPROC_X(0x0067A46E, 0, image, l, t, 0, dpi, 0); } else { if (image & 0x80000000) { // ? } if (image & 0x40000000) image &= ~0x40000000; else image |= colour << 19; gfx_draw_sprite(dpi, image, l, t); } }
void game_handle_edge_scroll() { rct_window *mainWindow; int scrollX, scrollY; mainWindow = window_get_main(); if (mainWindow == NULL) return; if ((mainWindow->flags & WF_2) || (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 9)) return; if (mainWindow->viewport == NULL) return; scrollX = 0; scrollY = 0; // Scroll left / right if (gCursorState.x == 0) scrollX = -1; else if (gCursorState.x == RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 1) scrollX = 1; // Scroll up / down if (gCursorState.y == 0) scrollY = -1; else if (gCursorState.y == RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 1) scrollY = 1; // Scroll viewport if (scrollX != 0) { mainWindow->saved_view_x += scrollX * (12 << mainWindow->viewport->zoom); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 7); } if (scrollY != 0) { mainWindow->saved_view_y += scrollY * (12 << mainWindow->viewport->zoom); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 7); } }
/** * * rct2: 0x00407E6E */ int osinterface_progressbar_create(char* title, int a2) { DWORD style = WS_VISIBLE | WS_BORDER | WS_DLGFRAME; if (a2) { style = WS_VISIBLE | WS_BORDER | WS_DLGFRAME | PBS_SMOOTH; } int width = 340; int height = GetSystemMetrics(SM_CYCAPTION) + 24; HWND hwnd = CreateWindowExA(WS_EX_TOPMOST | WS_EX_DLGMODALFRAME, "msctls_progress32", title, style, (RCT2_GLOBAL(0x01423C08, sint32) - width) / 2, (RCT2_GLOBAL(0x01423C0C, sint32) - height) / 2, width, height, 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_HINSTANCE, HINSTANCE), 0); RCT2_GLOBAL(RCT2_ADDRESS_PROGRESSBAR_HWND, HWND) = hwnd; if (hwnd) { RCT2_GLOBAL(0x009E2DFC, uint32) = 1; if (RCT2_GLOBAL(RCT2_ADDRESS_HFONT, HFONT)) { SendMessageA(hwnd, WM_SETFONT, (WPARAM)RCT2_GLOBAL(RCT2_ADDRESS_HFONT, HFONT), 1); } SetWindowTextA(hwnd, title); osinterface_progressbar_setmax(0xFF); osinterface_progressbar_setpos(0); return 1; } else { return 0; } }
void window_shortcut_change_open(int selected_key){ // Move this to window_shortcut_change_open window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); // Save the item we are selecting for new window RCT2_GLOBAL(0x9DE511, uint8) = selected_key; rct_window* w = window_create_auto_pos(WW, WH, (uint32*)window_shortcut_change_events, WC_CHANGE_KEYBOARD_SHORTCUT, 0); w->widgets = window_shortcut_change_widgets; w->enabled_widgets = (1 << 2); window_init_scroll_widgets(w); w->colours[0] = 7; w->colours[1] = 7; w->colours[2] = 7; }
/* rct2: 0x6ba517 */ static void window_banner_dropdown() { short widgetIndex, dropdownIndex; rct_window* w; window_dropdown_get_registers(w, widgetIndex, dropdownIndex); rct_banner* banner = &gBanners[w->number]; switch(widgetIndex){ case WIDX_MAIN_COLOR: if ( dropdownIndex == 0xFFFF) return; banner->colour = (uint8)dropdownIndex; window_invalidate(w); break; case WIDX_TEXT_COLOR_DROPDOWN_BUTTON: if ( dropdownIndex == 0xFFFF) return; banner->text_colour = dropdownIndex + 1; //Can be replaced with a buffer 34 chars wide ( 32 character + 1 colour_format + 1 '\0') uint8* text_buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, uint8); format_string(text_buffer, banner->string_idx, 0); if (text_buffer[0] < FORMAT_COLOUR_CODE_START || text_buffer[0] > FORMAT_COLOUR_CODE_END){ int end_point = strlen(text_buffer) + 1; strncpy(text_buffer + 1, text_buffer, 32); text_buffer[end_point] = '\0'; } text_buffer[0] = banner->text_colour + FORMAT_COLOUR_CODE_START; int string_id = 0, ebx = 0, ecx = 128, edx = 0, ebp = 0, esi = 0; // Allocate text_buffer to a new string_id? RCT2_CALLFUNC_X(0x6C421D, &string_id, &ebx, &ecx, &edx, &esi, (int*)&text_buffer, &ebp); if (string_id){ rct_string_id prev_string_id = banner->string_idx; banner->string_idx = string_id; // De-allocate previous string id? RCT2_CALLPROC_X(0x6C42AC, prev_string_id, 0, 0, 0, 0, 0, 0); window_invalidate(w); } else{ window_error_open(2984, RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id)); } break; } }
static void window_changelog_resize() { rct_window *w; window_get_register(w); int screenWidth = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16); int screenHeight = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16); w->max_width = (screenWidth * 4) / 5; w->max_height = (screenHeight * 4) / 5; w->min_width = MIN_WW; w->min_height = MIN_WH; if (w->width < w->min_width) { window_invalidate(w); w->width = w->min_width; } if (w->height < w->min_height) { window_invalidate(w); w->height = w->min_height; } }
static void window_network_status_paint(rct_window *w, rct_drawpixelinfo *dpi) { window_draw_widgets(w, dpi); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; char buffer[sizeof(window_network_status_text) + 10]; char* lineCh = buffer; lineCh = utf8_write_codepoint(lineCh, FORMAT_BLACK); strcpy(lineCh, window_network_status_text); gfx_clip_string(buffer, 230); int x = w->x + (w->width / 2); int y = w->y + (w->height / 2); x -= gfx_get_string_width(buffer) / 2; gfx_draw_string(dpi, buffer, 0, x, y); }
void window_land_rights_open() { rct_window* window; // Check if window is already open if (window_find_by_class(WC_LAND_RIGHTS) != NULL) return; window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 98, 29, 98, 94, &window_land_rights_events, WC_LAND_RIGHTS, 0); window->widgets = window_land_rights_widgets; window->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_DECREMENT) | (1 << WIDX_INCREMENT) | (1 << WIDX_PREVIEW) | (1 << WIDX_BUY_LAND_RIGHTS) | (1 << WIDX_BUY_CONSTRUCTION_RIGHTS); window_init_scroll_widgets(window); window_push_others_below(window); LandRightsMode = true; window->pressed_widgets = (1 << WIDX_BUY_LAND_RIGHTS); RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) = MONEY32_UNDEFINED; RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) = MONEY32_UNDEFINED; show_land_rights(); }
static bool window_changelog_read_file() { window_changelog_dispose_file(); utf8 path[MAX_PATH]; sprintf(path, "%s%cchangelog.txt", gExePath, platform_get_path_separator()); if (!readentirefile(path, (void**)&_changelogText, (int*)&_changelogTextSize)) { log_error("Unable to read changelog.txt"); return false; } _changelogText = realloc(_changelogText, _changelogTextSize + 1); _changelogText[_changelogTextSize++] = 0; char *start = _changelogText; if (_changelogTextSize >= 3 && utf8_is_bom(_changelogText)) start += 3; int changelogLinesCapacity = 8; _changelogLines = malloc(changelogLinesCapacity * sizeof(char*)); _changelogLines[0] = start; _changelogNumLines = 1; char *ch = start; while (*ch != 0) { unsigned char c = *ch; if (c == '\n') { *ch++ = 0; _changelogNumLines++; if (_changelogNumLines > changelogLinesCapacity) { changelogLinesCapacity *= 2; _changelogLines = realloc(_changelogLines, changelogLinesCapacity * sizeof(char*)); } _changelogLines[_changelogNumLines - 1] = ch; } else if (c < 32 || c > 122) { // A character that won't be drawn or change state. *ch++ = FORMAT_OUTLINE_OFF; } else { ch++; } } _changelogLines = realloc(_changelogLines, _changelogNumLines * sizeof(char*)); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; _changelogLongestLineWidth = 0; for (int i = 0; i < _changelogNumLines; i++) { int width = gfx_get_string_width(_changelogLines[i]); _changelogLongestLineWidth = max(width, _changelogLongestLineWidth); } return true; }
static int title_load_park(const char *path) { rct_window* w; int successfulLoad = 0; if (_strcmpi(path_get_extension(path), ".sv6") == 0) { SDL_RWops* rw = SDL_RWFromFile(path, "rb"); if (rw != NULL) { successfulLoad = game_load_sv6(rw); SDL_RWclose(rw); } } else { successfulLoad = scenario_load(path); } if (!successfulLoad) return 0; w = window_get_main(); w->viewport_target_sprite = -1; w->saved_view_x = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, sint16); w->saved_view_y = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16); { char _cl = (RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION, sint16) & 0xFF) - w->viewport->zoom; w->viewport->zoom = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION, sint16) & 0xFF; *((char*)(&RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32))) = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION, sint16) >> 8; if (_cl != 0) { if (_cl < 0) { _cl = -_cl; w->viewport->view_width >>= _cl; w->viewport->view_height >>= _cl; } else { w->viewport->view_width <<= _cl; w->viewport->view_height <<= _cl; } }
/** * Update status of marketing campaigns and send produce a news item when they have finished. * rct2: 0x0069E0C1 */ void marketing_update() { for (int campaign = 0; campaign < ADVERTISING_CAMPAIGN_COUNT; campaign++) { if (gCheatsNeverendingMarketing) continue; int active = (gMarketingCampaignDaysLeft[campaign] & CAMPAIGN_ACTIVE_FLAG) != 0; if (gMarketingCampaignDaysLeft[campaign] == 0) continue; window_invalidate_by_class(WC_FINANCES); // High bit marks the campaign as inactive, on first check the campaign is set active // this makes campaigns run a full x weeks even when started in the middle of a week gMarketingCampaignDaysLeft[campaign] &= ~CAMPAIGN_ACTIVE_FLAG; if (active) continue; if (--gMarketingCampaignDaysLeft[campaign] != 0) continue; int campaignItem = gMarketingCampaignRideIndex[campaign]; // This sets the string parameters for the marketing types that have an argument. if (campaign == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign == ADVERTISING_CAMPAIGN_RIDE) { rct_ride* ride = get_ride(campaignItem); RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = ride->name; RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint32) = ride->name_arguments; } else if (campaign == ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE) { RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = ShopItemStringIds[campaignItem].plural; } if (gConfigNotifications.park_marketing_campaign_finished) { news_item_add_to_queue(NEWS_ITEM_MONEY, STR_MARKETING_FINISHED_BASE + campaign, 0); } } }
void window_tooltip_reset(int x, int y) { RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_Y, uint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = 0; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, uint8) = 255; RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 1; RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) &= ~(1 << 4); }
/** * * rct2: 0x006E83C7 */ static void game_get_next_input(int *x, int *y, int *state) { int eax, ebx, ecx, edx, esi, edi, ebp; RCT2_CALLFUNC_X(0x00407074, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); if (eax == 0) { *x = gCursorState.x; *y = gCursorState.y; *state = 0; return; } *x = RCT2_GLOBAL(eax + 0, sint32); *y = RCT2_GLOBAL(eax + 4, sint32); *state = RCT2_GLOBAL(eax + 8, sint32); //int eax, ebx, ecx, edx, esi, edi, ebp; //RCT2_CALLFUNC_X(0x006E83C7, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); //*x = eax & 0xFFFF; //*y = ebx & 0xFFFF; //*state = ecx & 0xFF; //return; //int on_tutorial = RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8); //if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 5)) { // if (on_tutorial == 1) { // } else { // RCT2_CALLPROC_EBPSAFE(0x00407074); // } // if (on_tutorial == 2) { // } //} else { //} }
static void osinterface_resize(int width, int height) { rct_drawpixelinfo *screenDPI; int newScreenBufferSize; void *newScreenBuffer; if (_surface != NULL) SDL_FreeSurface(_surface); if (_palette != NULL) SDL_FreePalette(_palette); _surface = SDL_CreateRGBSurface(0, width, height, 8, 0, 0, 0, 0); _palette = SDL_AllocPalette(256); SDL_SetSurfacePalette(_surface, _palette); newScreenBufferSize = _surface->pitch * _surface->h; newScreenBuffer = malloc(newScreenBufferSize); if (_screenBuffer == NULL) { memset(newScreenBuffer, 0, newScreenBufferSize); } else { memcpy(newScreenBuffer, _screenBuffer, min(_screenBufferSize, newScreenBufferSize)); if (newScreenBufferSize - _screenBufferSize > 0) memset((uint8*)newScreenBuffer + _screenBufferSize, 0, newScreenBufferSize - _screenBufferSize); free(_screenBuffer); } _screenBuffer = newScreenBuffer; _screenBufferSize = newScreenBufferSize; RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) = width; RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) = height; screenDPI = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo); screenDPI->bits = _screenBuffer; screenDPI->x = 0; screenDPI->y = 0; screenDPI->width = width; screenDPI->height = height; screenDPI->pitch = _surface->pitch - _surface->w; RCT2_GLOBAL(0x009ABDF0, uint8) = 6; RCT2_GLOBAL(0x009ABDF1, uint8) = 3; RCT2_GLOBAL(0x009ABDF2, uint8) = 1; RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_WIDTH, sint16) = 64; RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_HEIGHT, sint16) = 8; RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32) = (width >> 6) + 1; RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_ROWS, sint32) = (height >> 3) + 1; RCT2_CALLPROC_EBPSAFE(0x0066B905); // resize_gui() gfx_invalidate_screen(); }
void window_player_overview_invalidate(rct_window *w) { if (window_player_page_widgets[w->page] != w->widgets) { w->widgets = window_player_page_widgets[w->page]; window_init_scroll_widgets(w); } colour_scheme_update(w); w->pressed_widgets &= ~(WIDX_TAB_1); w->pressed_widgets &= ~(WIDX_TAB_2); w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = w->error.var_480; // set title caption to player name w->widgets[WIDX_BACKGROUND].right = w->width - 1; w->widgets[WIDX_BACKGROUND].bottom = w->height - 1; w->widgets[WIDX_PAGE_BACKGROUND].right =w->width - 1; w->widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1; w->widgets[WIDX_TITLE].right = w->width - 2; w->widgets[WIDX_CLOSE].left = w->width - 13; w->widgets[WIDX_CLOSE].right = w->width - 3; w->widgets[WIDX_LOCATE].right = w->width - 2; w->widgets[WIDX_LOCATE].left = w->width - 25; w->widgets[WIDX_KICK].right = w->width - 2; w->widgets[WIDX_KICK].left = w->width - 25; w->widgets[WIDX_VIEWPORT].right = w->width - 26; w->widgets[WIDX_VIEWPORT].bottom = w->height - 14; int groupDropdownWidth = w->widgets[WIDX_GROUP].right - w->widgets[WIDX_GROUP].left; w->widgets[WIDX_GROUP].left = (w->width - groupDropdownWidth) / 2; w->widgets[WIDX_GROUP].right = w->widgets[WIDX_GROUP].left + groupDropdownWidth; w->widgets[WIDX_GROUP_DROPDOWN].left = w->widgets[WIDX_GROUP].right - 10; w->widgets[WIDX_GROUP_DROPDOWN].right = w->widgets[WIDX_GROUP].right; window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_2); rct_viewport *viewport = w->viewport; if (viewport != NULL) { rct_widget *viewportWidget = &window_player_overview_widgets[WIDX_VIEWPORT]; viewport->x = w->x + viewportWidget->left; viewport->y = w->y + viewportWidget->top; viewport->width = viewportWidget->right - viewportWidget->left; viewport->height = viewportWidget->bottom - viewportWidget->top; viewport->view_width = viewport->width << viewport->zoom; viewport->view_height = viewport->height << viewport->zoom; } }
/** * * rct2: 0x006B6B38 */ static void window_research_development_mouseup(rct_window *w, int widgetIndex) { switch (widgetIndex) { case WIDX_CLOSE: window_close(w); break; case WIDX_TAB_1: case WIDX_TAB_2: window_research_set_page(w, widgetIndex - WIDX_TAB_1); break; case WIDX_LAST_DEVELOPMENT_BUTTON: news_item_open_subject(NEWS_ITEM_RESEARCH, RCT2_GLOBAL(RCT2_ADDRESS_LAST_RESEARCHED_ITEM_SUBJECT, sint32)); break; } }
/** * * rct2: 0x0066FFE1 */ void editor_load() { rct_window *mainWindow; RCT2_CALLPROC_EBPSAFE(0x006BABB4); RCT2_CALLPROC_EBPSAFE(0x006BABD8); RCT2_CALLPROC_EBPSAFE(0x006A9CE8); map_init(); RCT2_CALLPROC_EBPSAFE(0x006B9CB0); RCT2_CALLPROC_EBPSAFE(0x00667104); RCT2_CALLPROC_EBPSAFE(0x006C4209); RCT2_CALLPROC_EBPSAFE(0x0069EB13); ride_init_all(); RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a RCT2_CALLPROC_EBPSAFE(0x006BD3A4); park_init(); RCT2_CALLPROC_EBPSAFE(0x0069DEFB); date_reset(); RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b RCT2_CALLPROC_EBPSAFE(0x006BD39C); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_SCENARIO_EDITOR; RCT2_GLOBAL(0x0141F570, uint8) = 0; RCT2_GLOBAL(RCT2_ADDRESS_GAME_FLAGS, uint32) |= 16; RCT2_CALLPROC_EBPSAFE(0x006ACA58); RCT2_GLOBAL(0x0141F571, uint8) = 4; viewport_init_all(); news_item_init_queue(); RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create mainWindow = window_get_main(); window_scroll_to_location(mainWindow, 2400, 2400, 112); mainWindow->flags &= ~0x08; RCT2_CALLPROC_EBPSAFE(0x006837E3); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, sint16) = 0; rct2_endupdate(); }
int marketing_get_campaign_guest_generation_probability(int campaign) { int probability = AdvertisingCampaignGuestGenerationProbabilities[campaign]; rct_ride *ride; // Lower probability of guest generation if price was already low switch (campaign) { case ADVERTISING_CAMPAIGN_PARK_ENTRY_FREE: if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, money16) < 4) probability /= 8; break; case ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE: if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, money16) < 6) probability /= 8; break; case ADVERTISING_CAMPAIGN_RIDE_FREE: ride = get_ride(gMarketingCampaignRideIndex[campaign]); if (ride->price < 3) probability /= 8; break; } return probability; }
static int screenshot_get_next_path(char *path, char *extension) { int i; for (i = 1; i < 1000; i++) { RCT2_GLOBAL(0x013CE952, uint16) = i; // Glue together path and filename sprintf(path, "%sSCR%d%s", RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH_SLASH, char), i, extension); if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND) return i; } return -1; }
/** * * rct2: 0x0068AB4C */ void map_init() { int i; rct_map_element *map_element; date_reset(); RCT2_GLOBAL(0x0138B580, sint16) = 0; RCT2_GLOBAL(0x010E63B8, sint32) = 0; for (i = 0; i < MAX_TILE_MAP_ELEMENT_POINTERS; i++) { map_element = GET_MAP_ELEMENT(i); map_element->type = (MAP_ELEMENT_TYPE_SURFACE << 2); map_element->flags = MAP_ELEMENT_FLAG_LAST_TILE; map_element->base_height = 14; map_element->clearance_height = 14; map_element->properties.surface.slope = 0; map_element->properties.surface.grass_length = 1; map_element->properties.surface.ownership = 0; map_element_set_terrain(map_element, TERRAIN_GRASS); map_element_set_terrain_edge(map_element, TERRAIN_EDGE_ROCK); } RCT2_GLOBAL(0x013B0E70, sint16) = 0; RCT2_GLOBAL(0x013CE774, sint16) = 0; RCT2_GLOBAL(0x013CE776, sint16) = 0; RCT2_GLOBAL(0x01358830, sint16) = 4768; RCT2_GLOBAL(0x01358832, sint16) = 5054; RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, sint16) = 150; RCT2_GLOBAL(0x01358836, sint16) = 4767; RCT2_GLOBAL(0x01359208, sint16) = 7; map_update_tile_pointers(); RCT2_CALLPROC_EBPSAFE(0x0068ADBC); climate_reset(CLIMATE_WARM); }
/** * Creates the window containing the options button on the title screen. */ void window_title_options_open() { rct_window* window; window = window_create( RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 80, 0, 80, 12, (uint32*)window_title_options_events, WC_TITLE_OPTIONS, WF_STICK_TO_BACK | WF_TRANSPARENT ); window->widgets = window_title_options_widgets; window->enabled_widgets |= 1; window_init_scroll_widgets(window); }
/** * * rct2: 0x0066FFE1 */ void editor_load() { rct_window *mainWindow; pause_sounds(); unpause_sounds(); object_unload_all(); map_init(); RCT2_CALLPROC_EBPSAFE(0x006B9CB0); reset_park_entrances(); reset_saved_strings(); reset_sprite_list(); ride_init_all(); window_guest_list_init_vars_a(); sub_6BD3A4(); park_init(); finance_init(); date_reset(); window_guest_list_init_vars_b(); window_staff_list_init_vars(); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_SCENARIO_EDITOR; RCT2_GLOBAL(0x0141F570, uint8) = 0; RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; window_new_ride_init_vars(); RCT2_GLOBAL(0x0141F571, uint8) = 4; viewport_init_all(); news_item_init_queue(); RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create mainWindow = window_get_main(); window_scroll_to_location(mainWindow, 2400, 2400, 112); mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION; RCT2_CALLPROC_EBPSAFE(0x006837E3); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, sint16) = 0; // rct2_endupdate(); }
static void window_title_logo_draw_expansion_packs(rct_drawpixelinfo *dpi) { int packs, x, y, i; char *buffer, *names; x = 0; y = 105; packs = RCT2_GLOBAL(RCT2_ADDRESS_EXPANSION_FLAGS, uint16); names = RCT2_ADDRESS(RCT2_ADDRESS_EXPANSION_NAMES, char); buffer = (char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER; while (packs != 0) { if (packs & 1) { // Prefix for expansion name buffer[0] = '\n'; buffer[1] = '\v'; buffer[2] = FORMAT_YELLOW; // Colour of the text buffer[3] = '+'; buffer[4] = ' '; // Copies the expansion name to the buffer, offset by 5 i = 0; do { buffer[5 + i] = names[i]; i++; } while (names[i - 1] != 0); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint32) = 0; gfx_draw_string(dpi, buffer, 0, x, y); y += 10; } packs = packs >> 1; names += 128; } }
/** * Sets each tile's water level to the specified water level if underneath that water level. */ static void mapgen_set_water_level(int waterLevel) { int x, y, mapSize; rct_map_element *mapElement; mapSize = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, sint16); for (y = 1; y < mapSize - 1; y++) { for (x = 1; x < mapSize - 1; x++) { mapElement = map_get_surface_element_at(x, y); if (mapElement->base_height < waterLevel) mapElement->properties.surface.terrain |= (waterLevel / 2); } } }
/** * * rct2: 0x006EA594 * x (ax) * y (bx) * returns widget_index (edx) * EDI NEEDS TO BE SET TO w->widgets[widget_index] AFTER */ int window_find_widget_from_point(rct_window *w, int x, int y) { rct_widget *widget; int i, widget_index; // Invalidate the window RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); // Find the widget at point x, y widget_index = -1; RCT2_GLOBAL(0x01420074, uint8) = -1; for (i = 0;; i++) { widget = &w->widgets[i]; if (widget->type == WWT_LAST) { break; } else if (widget->type != WWT_EMPTY) { if (widget->type == WWT_SCROLL) RCT2_GLOBAL(0x01420074, uint8)++; if (x >= w->x + widget->left && x <= w->x + widget->right && y >= w->y + widget->top && y <= w->y + widget->bottom ) { widget_index = i; RCT2_GLOBAL(0x01420075, uint8) = RCT2_GLOBAL(0x01420074, uint8); } } } // Return next widget if a dropdown if (widget_index != -1) if (w->widgets[widget_index].type == WWT_DROPDOWN) widget_index++; // Return the widget index return widget_index; }