/** * * rct2: 0x0066DDF2 */ static void window_save_prompt_mouseup(rct_window *w, int widgetIndex) { if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) { switch (widgetIndex) { case WQIDX_OK: game_load_or_quit_no_save_prompt(); break; case WQIDX_CLOSE: case WQIDX_CANCEL: window_close(w); break; } return; } else { switch (widgetIndex) { case WIDX_SAVE: save_game_as(); window_close(w); gLoadSaveCallback = window_save_prompt_callback; break; case WIDX_DONT_SAVE: game_load_or_quit_no_save_prompt(); return; case WIDX_CLOSE: case WIDX_CANCEL: window_close(w); return; } } if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) { if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 1) { RCT2_CALLPROC_EBPSAFE(0x0066EE54); game_load_or_quit_no_save_prompt(); return; } else { tutorial_stop(); game_load_or_quit_no_save_prompt(); return; } } }
/** * * rct2: 0x0066DCBE */ void window_save_prompt_open() { int stringId, width, height; rct_window* window; unsigned short prompt_mode; rct_widget *widgets; uint64 enabled_widgets; prompt_mode = RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16); if (prompt_mode == PM_QUIT) prompt_mode = PM_SAVE_BEFORE_QUIT; // do not show save prompt if we're in the title demo and click on load game if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) { game_load_or_quit_no_save_prompt(); return; } if (!gConfigGeneral.confirmation_prompt) { /* game_load_or_quit_no_save_prompt() will exec requested task and close this window * immediately again. * TODO restructure these functions when we're sure game_load_or_quit_no_save_prompt() * and game_load_or_quit() are not called by the original binary anymore. */ if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) { if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 1) { RCT2_CALLPROC_EBPSAFE(0x0066EE54); game_load_or_quit_no_save_prompt(); return; } else { tutorial_stop(); game_load_or_quit_no_save_prompt(); return; } } if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) < 3840) { game_load_or_quit_no_save_prompt(); return; } } // Check if window is already open window = window_bring_to_front_by_class(WC_SAVE_PROMPT); if (window){ window_close(window); } if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) { widgets = window_quit_prompt_widgets; enabled_widgets = (1 << WQIDX_CLOSE) | (1 << WQIDX_OK) | (1 << WQIDX_CANCEL); width = 177; height = 34; } else { widgets = window_save_prompt_widgets; enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_SAVE) | (1 << WIDX_DONT_SAVE) | (1 << WIDX_CANCEL); width = 260; height = 50; } window = window_create_centred( width, height, &window_save_prompt_events, WC_SAVE_PROMPT, WF_TRANSPARENT | WF_STICK_TO_FRONT ); window->widgets = widgets; window->enabled_widgets = enabled_widgets; window_init_scroll_widgets(window); // Pause the game RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) |= 2; audio_pause_sounds(); window_invalidate_by_class(WC_TOP_TOOLBAR); stringId = prompt_mode + STR_LOAD_GAME_PROMPT_TITLE; if (stringId == STR_LOAD_GAME_PROMPT_TITLE && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) stringId = STR_LOAD_LANDSCAPE_PROMPT_TITLE; if (stringId == STR_QUIT_GAME_PROMPT_TITLE && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) stringId = STR_QUIT_SCENARIO_EDITOR; window_save_prompt_widgets[WIDX_TITLE].image = stringId; window_save_prompt_widgets[WIDX_LABEL].image = prompt_mode + STR_SAVE_BEFORE_LOADING; }
/** * * rct2: 0x0066DCBE */ void window_save_prompt_open() { int stringId, x, y; rct_window* window; unsigned short prompt_mode; rct_widget *widgets; uint64 enabled_widgets; prompt_mode = RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16); // do not show save prompt if we're in the title demo and click on load game if (prompt_mode != PM_QUIT && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) { game_load_or_quit_no_save_prompt(); return; } // Check if window is already open window = window_bring_to_front_by_id(WC_SAVE_PROMPT, 0); if (window) { window_close(window); } if (prompt_mode == PM_QUIT) { widgets = window_quit_prompt_widgets; enabled_widgets = (1 << WQIDX_CLOSE) | (1 << WQIDX_OK) | (1 << WQIDX_CANCEL); x = 177; y = 34; } else { widgets = window_save_prompt_widgets; enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_SAVE) | (1 << WIDX_DONT_SAVE) | (1 << WIDX_CANCEL); x = 260; y = 50; } window = window_create( (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2) - x / 2, max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - y / 2), x, y, (uint32*)window_save_prompt_events, WC_SAVE_PROMPT, WF_TRANSPARENT | WF_STICK_TO_FRONT ); window->widgets = widgets; window->enabled_widgets = enabled_widgets; window_init_scroll_widgets(window); window->colours[0] = 154; // Pause the game RCT2_GLOBAL(0x009DEA6E, uint8) |= 2; pause_sounds(); window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0); stringId = prompt_mode + STR_LOAD_GAME; if (stringId == STR_LOAD_GAME && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) stringId = STR_LOAD_LANDSCAPE; if (stringId == STR_QUIT_GAME && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) stringId = STR_QUIT_SCENARIO_EDITOR; window_save_prompt_widgets[WIDX_TITLE].image = stringId; window_save_prompt_widgets[WIDX_LABEL].image = prompt_mode + STR_SAVE_BEFORE_LOADING; if (!gGeneral_config.confirmation_prompt) { /* game_load_or_quit_no_save_prompt() will exec requested task and close this window * immediately again. * TODO restructure these functions when we're sure game_load_or_quit_no_save_prompt() * and game_load_or_quit() are not called by the original binary anymore. */ if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0D) { game_load_or_quit_no_save_prompt(); return; } if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) { if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 1) { RCT2_CALLPROC_EBPSAFE(0x0066EE54); game_load_or_quit_no_save_prompt(); return; } else { tutorial_stop(); game_load_or_quit_no_save_prompt(); return; } } if (RCT2_GLOBAL(0x009DEA66, uint16) < 3840) { game_load_or_quit_no_save_prompt(); return; } } }
/** * * rct2: 0x0066DDF2 */ static void window_save_prompt_mouseup() { short widgetIndex; rct_window *w; short prompt_mode; window_widget_get_registers(w, widgetIndex); prompt_mode = RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16); if (prompt_mode == PM_QUIT) { switch (widgetIndex) { case WQIDX_OK: rct2_finish(); break; case WQIDX_CLOSE: case WQIDX_CANCEL: window_close(w); break; } return; } else { switch (widgetIndex) { case WIDX_SAVE: if (!save_game()) { // user pressed cancel window_close(w); return; } break; case WIDX_DONT_SAVE: break; case WIDX_CLOSE: case WIDX_CANCEL: window_close(w); return; } } if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0D) { game_load_or_quit_no_save_prompt(); return; } if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) { if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 1) { RCT2_CALLPROC_EBPSAFE(0x0066EE54); game_load_or_quit_no_save_prompt(); return; } else { tutorial_stop(); game_load_or_quit_no_save_prompt(); return; } } if (RCT2_GLOBAL(0x009DEA66, uint16) < 3840) { game_load_or_quit_no_save_prompt(); return; } }
/** * * rct2: 0x006E3B43 */ void game_handle_keyboard_input() { rct_window *w; int key; // Handle mouse scrolling if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, uint8) != 0) if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == 1) if (!(RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 3)) game_handle_edge_scroll(); // Handle modifier keys and key scrolling RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = 0; if (RCT2_GLOBAL(0x009E2B64, uint32) != 1) { if (gKeysState[SDL_SCANCODE_LSHIFT] || gKeysState[SDL_SCANCODE_RSHIFT]) RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) |= 1; if (gKeysState[SDL_SCANCODE_LCTRL] || gKeysState[SDL_SCANCODE_RCTRL]) RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) |= 2; if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) game_handle_key_scroll(); } // Handle key input while ((key = get_next_key()) != 0) { if (key == 255) continue; key |= RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) << 8; w = window_find_by_id(WC_CHANGE_KEYBOARD_SHORTCUT, 0); if (w != NULL) set_shortcut(key); else if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 1) tutorial_stop(); else handle_shortcut(key); } if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) return; // Tutorial and the modifier key if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 1) { int eax, ebx, ecx, edx, esi, edi, ebp; RCT2_CALLFUNC_X(0x0066EEB4, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); eax &= 0xFF; RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = eax; if (RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 4) { window_tooltip_close(); if ((w = window_get_main()) != NULL) { RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); RCT2_GLOBAL(0x009DEA72, uint16)++; } } } else { if (!(RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 4)) { window_tooltip_close(); if ((w = window_get_main()) != NULL) { RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); RCT2_GLOBAL(0x009DEA72, uint16)++; } } // Write tutorial input RCT2_CALLPROC_X(0x0066EEE1, RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8), 0, 0, 0, 0, 0, 0); } }