/** * * 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() { sint32 width, height; rct_string_id stringId; rct_window* window; uint8 prompt_mode; rct_widget *widgets; uint64 enabled_widgets; prompt_mode = gSavePromptMode; 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 (gScreenFlags & 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 (gScreenAge < 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 (gScreenFlags & (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; } if (prompt_mode >= countof(window_save_prompt_labels)) { log_warning("Invalid save prompt mode %u", prompt_mode); return; } 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 gGamePaused |= GAME_PAUSED_MODAL; audio_pause_sounds(); window_invalidate_by_class(WC_TOP_TOOLBAR); stringId = window_save_prompt_labels[prompt_mode][0]; if (stringId == STR_LOAD_GAME_PROMPT_TITLE && gScreenFlags & 2) stringId = STR_LOAD_LANDSCAPE_PROMPT_TITLE; if (stringId == STR_QUIT_GAME_PROMPT_TITLE && gScreenFlags & 2) stringId = STR_QUIT_SCENARIO_EDITOR; window_save_prompt_widgets[WIDX_TITLE].text = stringId; window_save_prompt_widgets[WIDX_LABEL].text = window_save_prompt_labels[prompt_mode][1]; }