1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-04 13:42:55 +01:00

Change: allow going back in editor when converting a save

This commit is contained in:
Aaron van Geffen
2025-03-20 16:34:09 +01:00
parent 42126cd35d
commit 50f58d4c4f
2 changed files with 34 additions and 16 deletions

View File

@@ -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)
{

View File

@@ -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;