Fix #18971: New Game does not prompt for save before quitting (#19046)

Co-authored-by: Tulio Leao <tupaschoal@gmail.com>
This commit is contained in:
Nehemiah Negussie 2023-01-06 06:56:46 -05:00 committed by GitHub
parent 52fffb96cb
commit eeb5c58238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 13 deletions

View file

@ -205,6 +205,7 @@ The following people are not part of the development team, but have been contrib
* (ReticulatingSplines) * (ReticulatingSplines)
* Conrad Cash (HouseholdVTuber) * Conrad Cash (HouseholdVTuber)
* Michael Bickerton (mdbckrtn) * Michael Bickerton (mdbckrtn)
* Nehemiah Negussie (nehemiah-negussie)
## Toolchain ## Toolchain
@ -272,4 +273,4 @@ Representation by Jacqui Lyons at Marjacq Ltd.
Thanks to: Peter James Adcock, Joe Booth, and John Wardley Thanks to: Peter James Adcock, Joe Booth, and John Wardley
Licensed to Infogrames Interactive Inc. Licensed to Infogrames Interactive Inc.

View file

@ -11,6 +11,7 @@
- Fix: [#18467] “Selected only” Object Selection filter is active in Track Designs Manager, and cannot be toggled. - Fix: [#18467] “Selected only” Object Selection filter is active in Track Designs Manager, and cannot be toggled.
- Fix: [#18905] Ride Construction window theme is not applied correctly. - Fix: [#18905] Ride Construction window theme is not applied correctly.
- Fix: [#18911] Mini Golf station does not draw correctly from all angles. - Fix: [#18911] Mini Golf station does not draw correctly from all angles.
- Fix: [#18971] New Game does not prompt for save before quitting.
- Fix: [#19026] Park loan is clamped to a 32-bit integer. - Fix: [#19026] Park loan is clamped to a 32-bit integer.
0.4.3 (2022-12-14) 0.4.3 (2022-12-14)

View file

@ -64,6 +64,7 @@ static constexpr const StringId window_save_prompt_labels[][2] = {
{ STR_LOAD_GAME_PROMPT_TITLE, STR_SAVE_BEFORE_LOADING }, { STR_LOAD_GAME_PROMPT_TITLE, STR_SAVE_BEFORE_LOADING },
{ STR_QUIT_GAME_PROMPT_TITLE, STR_SAVE_BEFORE_QUITTING }, { STR_QUIT_GAME_PROMPT_TITLE, STR_SAVE_BEFORE_QUITTING },
{ STR_QUIT_GAME_2_PROMPT_TITLE, STR_SAVE_BEFORE_QUITTING_2 }, { STR_QUIT_GAME_2_PROMPT_TITLE, STR_SAVE_BEFORE_QUITTING_2 },
{ STR_NEW_GAME, STR_SAVE_BEFORE_QUITTING },
}; };
// clang-format on // clang-format on

View file

@ -532,15 +532,6 @@ static void WindowTopToolbarMousedown(rct_window* w, WidgetIndex widgetIndex, Wi
} }
} }
static void WindowTopToolbarScenarioselectCallback(const utf8* path)
{
window_close_by_class(WindowClass::EditorObjectSelection);
game_notify_map_change();
GetContext()->LoadParkFromFile(path, false, true);
game_load_scripts();
game_notify_map_changed();
}
/** /**
* *
* rct2: 0x0066C9EA * rct2: 0x0066C9EA
@ -573,9 +564,8 @@ static void WindowTopToolbarDropdown(rct_window* w, WidgetIndex widgetIndex, int
{ {
case DDIDX_NEW_GAME: case DDIDX_NEW_GAME:
{ {
auto intent = Intent(WindowClass::ScenarioSelect); auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::OpenSavePrompt, PromptMode::SaveBeforeNewGame);
intent.putExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast<void*>(WindowTopToolbarScenarioselectCallback)); GameActions::Execute(&loadOrQuitAction);
ContextOpenIntent(&intent);
break; break;
} }
case DDIDX_LOAD_GAME: case DDIDX_LOAD_GAME:

View file

@ -736,6 +736,15 @@ static void game_load_or_quit_no_save_prompt_callback(int32_t result, const utf8
} }
} }
static void NewGameWindowCallback(const utf8* path)
{
window_close_by_class(WindowClass::EditorObjectSelection);
game_notify_map_change();
GetContext()->LoadParkFromFile(path, false, true);
game_load_scripts();
game_notify_map_changed();
}
/** /**
* *
* rct2: 0x0066DB79 * rct2: 0x0066DB79
@ -778,6 +787,16 @@ void game_load_or_quit_no_save_prompt()
title_load(); title_load();
break; break;
} }
case PromptMode::SaveBeforeNewGame:
{
auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::CloseSavePrompt);
GameActions::Execute(&loadOrQuitAction);
tool_cancel();
auto intent = Intent(WindowClass::ScenarioSelect);
intent.putExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast<void*>(NewGameWindowCallback));
ContextOpenIntent(&intent);
break;
}
default: default:
game_unload_scripts(); game_unload_scripts();
openrct2_finish(); openrct2_finish();

View file

@ -469,6 +469,7 @@ enum class PromptMode : uint8_t
SaveBeforeLoad = 0, SaveBeforeLoad = 0,
SaveBeforeQuit, SaveBeforeQuit,
SaveBeforeQuit2, SaveBeforeQuit2,
SaveBeforeNewGame,
Quit Quit
}; };