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)
* Conrad Cash (HouseholdVTuber)
* Michael Bickerton (mdbckrtn)
* Nehemiah Negussie (nehemiah-negussie)
## Toolchain
@ -272,4 +273,4 @@ Representation by Jacqui Lyons at Marjacq Ltd.
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: [#18905] Ride Construction window theme is not applied correctly.
- 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.
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_QUIT_GAME_PROMPT_TITLE, STR_SAVE_BEFORE_QUITTING },
{ STR_QUIT_GAME_2_PROMPT_TITLE, STR_SAVE_BEFORE_QUITTING_2 },
{ STR_NEW_GAME, STR_SAVE_BEFORE_QUITTING },
};
// 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
@ -573,9 +564,8 @@ static void WindowTopToolbarDropdown(rct_window* w, WidgetIndex widgetIndex, int
{
case DDIDX_NEW_GAME:
{
auto intent = Intent(WindowClass::ScenarioSelect);
intent.putExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast<void*>(WindowTopToolbarScenarioselectCallback));
ContextOpenIntent(&intent);
auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::OpenSavePrompt, PromptMode::SaveBeforeNewGame);
GameActions::Execute(&loadOrQuitAction);
break;
}
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
@ -778,6 +787,16 @@ void game_load_or_quit_no_save_prompt()
title_load();
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:
game_unload_scripts();
openrct2_finish();

View File

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