From 50f58d4c4fb399c91fdb2bdbb2a72e35e1ee3056 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Thu, 20 Mar 2025 16:34:09 +0100 Subject: [PATCH] Change: allow going back in editor when converting a save --- .../windows/EditorBottomToolbar.cpp | 26 +++++++------------ .../windows/EditorScenarioOptions.cpp | 24 +++++++++++++++++ 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/openrct2-ui/windows/EditorBottomToolbar.cpp b/src/openrct2-ui/windows/EditorBottomToolbar.cpp index 20eb3374c2..5d16d85264 100644 --- a/src/openrct2-ui/windows/EditorBottomToolbar.cpp +++ b/src/openrct2-ui/windows/EditorBottomToolbar.cpp @@ -68,6 +68,11 @@ namespace OpenRCT2::Ui::Windows SetAllSceneryItemsInvented(); } + bool GameHasEntities() const + { + return GetNumFreeEntities() != kMaxEntities || getGameState().park.Flags & PARK_FLAGS_SPRITES_INITIALISED; + } + void OnPrepareDraw() override { ColourSchemeUpdateByClass( @@ -86,16 +91,16 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_PREVIOUS_IMAGE].type = WindowWidgetType::ImgBtn; widgets[WIDX_NEXT_IMAGE].type = WindowWidgetType::ImgBtn; - if (gLegacyScene == LegacyScene::trackDesignsManager) + auto& gameState = getGameState(); + if (gLegacyScene == LegacyScene::trackDesignsManager || gameState.editorStep == EditorStep::SaveScenario) { HidePreviousStepButton(); HideNextStepButton(); } else { - auto& gameState = getGameState(); - - if (gameState.editorStep == EditorStep::ObjectSelection) + if (gameState.editorStep == EditorStep::ObjectSelection + || (GameHasEntities() && gameState.editorStep == EditorStep::OptionsSelection)) { HidePreviousStepButton(); } @@ -103,13 +108,6 @@ namespace OpenRCT2::Ui::Windows { HideNextStepButton(); } - else if (gLegacyScene != LegacyScene::trackDesigner) - { - if (GetNumFreeEntities() != kMaxEntities || getGameState().park.Flags & PARK_FLAGS_SPRITES_INITIALISED) - { - HidePreviousStepButton(); - } - } } } @@ -140,11 +138,7 @@ namespace OpenRCT2::Ui::Windows auto& gameState = getGameState(); if (widgetIndex == WIDX_PREVIOUS_STEP_BUTTON) { - if (gLegacyScene == LegacyScene::trackDesigner - || (GetNumFreeEntities() == kMaxEntities && !(gameState.park.Flags & PARK_FLAGS_SPRITES_INITIALISED))) - { - ((this)->*(kPreviousButtonMouseUp[EnumValue(gameState.editorStep)]))(); - } + ((this)->*(kPreviousButtonMouseUp[EnumValue(gameState.editorStep)]))(); } else if (widgetIndex == WIDX_NEXT_STEP_BUTTON) { diff --git a/src/openrct2-ui/windows/EditorScenarioOptions.cpp b/src/openrct2-ui/windows/EditorScenarioOptions.cpp index 49c8f1606d..ab37fa2602 100644 --- a/src/openrct2-ui/windows/EditorScenarioOptions.cpp +++ b/src/openrct2-ui/windows/EditorScenarioOptions.cpp @@ -413,6 +413,8 @@ namespace OpenRCT2::Ui::Windows void OnPrepareDraw() override { + HideUnavailableTabs(); + switch (page) { case WINDOW_EDITOR_SCENARIO_OPTIONS_PAGE_OBJECTIVE: @@ -507,6 +509,27 @@ namespace OpenRCT2::Ui::Windows } private: + void HideUnavailableTabs() + { + if (gLegacyScene != LegacyScene::scenarioEditor) + return; + + // Disable tabs based on current editor step + auto step = getGameState().editorStep; + SetWidgetDisabled(WIDX_TAB_1, step == EditorStep::ObjectiveSelection); + for (auto i = 1; i < WINDOW_EDITOR_SCENARIO_OPTIONS_PAGE_COUNT; i++) + SetWidgetDisabled(WIDX_TAB_1 + i, step == EditorStep::SaveScenario); + + // Reposition tabs based on availability so there are no gaps + WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_6); + + // Switch tabs if our current tab has become unavailable + if (WidgetIsDisabled(*this, WIDX_TAB_1) && page == WINDOW_EDITOR_SCENARIO_OPTIONS_PAGE_OBJECTIVE) + SetPage(WINDOW_EDITOR_SCENARIO_OPTIONS_PAGE_SCENARIO_INFO); + else if (!WidgetIsDisabled(*this, WIDX_TAB_1) && page != WINDOW_EDITOR_SCENARIO_OPTIONS_PAGE_OBJECTIVE) + SetPage(WINDOW_EDITOR_SCENARIO_OPTIONS_PAGE_OBJECTIVE); + } + void SetPressedTab() { int32_t i; @@ -582,6 +605,7 @@ namespace OpenRCT2::Ui::Windows page = newPage; frame_no = 0; + disabled_widgets = 0; hold_down_widgets = window_editor_scenario_options_page_hold_down_widgets[page]; pressed_widgets = 0;