mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Advance editor step when saving (and go back if user cancels)
This commit is contained in:
@@ -196,7 +196,7 @@ namespace OpenRCT2::Ui::FileBrowser
|
||||
return result;
|
||||
}
|
||||
|
||||
void RegisterCallback(std::function<void(ModalResult result, std::string_view)> callback)
|
||||
void RegisterCallback(LoadSaveCallback callback)
|
||||
{
|
||||
_loadSaveCallback = callback;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenRCT2::Ui::FileBrowser
|
||||
const char* GetFilterPatternByType(const LoadSaveType type, const bool isSave);
|
||||
u8string RemovePatternWildcard(u8string_view pattern);
|
||||
u8string GetDir(const LoadSaveType type);
|
||||
void RegisterCallback(std::function<void(ModalResult result, std::string_view)> callback);
|
||||
void RegisterCallback(LoadSaveCallback callback);
|
||||
void InvokeCallback(ModalResult result, const utf8* path);
|
||||
void Select(const char* path, LoadSaveAction action, LoadSaveType type, TrackDesign* trackDesignPtr);
|
||||
StringId GetTitleStringId(LoadSaveType type, bool isSave);
|
||||
|
||||
@@ -271,19 +271,34 @@ namespace OpenRCT2::Ui::Windows
|
||||
GfxInvalidateScreen();
|
||||
}
|
||||
|
||||
static void SaveScenarioCallback(ModalResult result, const utf8* path)
|
||||
{
|
||||
if (result == ModalResult::ok)
|
||||
{
|
||||
GameUnloadScripts();
|
||||
}
|
||||
else
|
||||
{
|
||||
getGameState().editorStep = EditorStep::ScenarioDetails;
|
||||
}
|
||||
}
|
||||
|
||||
void JumpForwardToSaveScenario() const
|
||||
{
|
||||
auto& gameState = getGameState();
|
||||
gameState.editorStep = EditorStep::SaveScenario;
|
||||
GfxInvalidateScreen();
|
||||
|
||||
const auto savePrepareResult = ScenarioPrepareForSave(gameState);
|
||||
if (!savePrepareResult.Successful)
|
||||
{
|
||||
ContextShowError(STR_UNABLE_TO_SAVE_SCENARIO_FILE, savePrepareResult.Message, {});
|
||||
GfxInvalidateScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
windowMgr->CloseAll();
|
||||
|
||||
auto intent = Intent(WindowClass::Loadsave);
|
||||
intent.PutEnumExtra<LoadSaveAction>(INTENT_EXTRA_LOADSAVE_ACTION, LoadSaveAction::save);
|
||||
intent.PutEnumExtra<LoadSaveType>(INTENT_EXTRA_LOADSAVE_TYPE, LoadSaveType::scenario);
|
||||
@@ -292,16 +307,6 @@ namespace OpenRCT2::Ui::Windows
|
||||
ContextOpenIntent(&intent);
|
||||
}
|
||||
|
||||
static void SaveScenarioCallback(ModalResult result, const utf8* path)
|
||||
{
|
||||
if (result != ModalResult::ok)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameUnloadScripts();
|
||||
}
|
||||
|
||||
void HidePreviousStepButton()
|
||||
{
|
||||
widgets[WIDX_PREVIOUS_STEP_BUTTON].type = WindowWidgetType::Empty;
|
||||
|
||||
@@ -764,6 +764,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_CLOSE:
|
||||
InvokeCallback(ModalResult::cancel, "");
|
||||
Close();
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user