Skip to content

Commit

Permalink
Merge pull request OpenRCT2#22411 from AaronVanGeffen/cleanup-top-too…
Browse files Browse the repository at this point in the history
…lbar

Move tool event functions out of top toolbar
  • Loading branch information
AaronVanGeffen authored Jul 31, 2024
2 parents e5a6ccc + 706fd8f commit 30e890c
Show file tree
Hide file tree
Showing 18 changed files with 2,735 additions and 2,697 deletions.
1 change: 1 addition & 0 deletions distribution/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Change: [#22309] The scenario editor now supports loading landscapes from .sea save files.
- Fix: [#17390] Glitchy animations for the ride type tabs in the object selection window.
- Fix: [#19210] The load/save window executes the loading code twice, resulting in a slowdown.
- Fix: [#21175] Terraform tool hotkeys don't work when toolbars are hidden.
- Fix: [#22056] Potential crash upon exiting the game.
- Fix: [#22101] Wrong tunnel shapes on Log Flume and Giga, Hybrid, Single-Rail and Alpine Coasters.
- Fix: [#22208] Cursor may fail to register hits in some cases (original bug).
Expand Down
13 changes: 1 addition & 12 deletions src/openrct2-ui/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,7 @@ class WindowManager final : public IWindowManager
// Check if window is already open
auto* window = WindowBringToFrontByClass(WindowClass::Scenery);
if (window == nullptr)
{
auto* tlbrWindow = WindowFindByClass(WindowClass::TopToolbar);
if (tlbrWindow != nullptr)
{
tlbrWindow->Invalidate();
if (!ToolSet(*tlbrWindow, WC_TOP_TOOLBAR__WIDX_SCENERY, Tool::Arrow))
{
InputSetFlag(INPUT_FLAG_6, true);
window = SceneryOpen();
}
}
}
ToggleSceneryWindow();

// Switch to new scenery tab
WindowScenerySetSelectedTab(intent->GetUIntExtra(INTENT_EXTRA_SCENERY_GROUP_ENTRY_INDEX));
Expand Down
99 changes: 36 additions & 63 deletions src/openrct2-ui/input/Shortcuts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,70 +192,55 @@ static void ShortcutAdjustLand()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;

if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
WindowBase* window = WindowFindByClass(WindowClass::TopToolbar);
if (window != nullptr)
{
window->Invalidate();
window->OnMouseUp(WC_TOP_TOOLBAR__WIDX_LAND);
}
}
}
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && GetGameState().EditorStep != EditorStep::LandscapeEditor)
return;

if (gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
return;

ToggleLandWindow();
}

static void ShortcutAdjustWater()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;

if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
WindowBase* window = WindowFindByClass(WindowClass::TopToolbar);
if (window != nullptr)
{
window->Invalidate();
window->OnMouseUp(WC_TOP_TOOLBAR__WIDX_WATER);
}
}
}
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && GetGameState().EditorStep != EditorStep::LandscapeEditor)
return;

if (gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
return;

ToggleWaterWindow();
}

static void ShortcutBuildScenery()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;

if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
WindowBase* window = WindowFindByClass(WindowClass::TopToolbar);
if (window != nullptr)
{
window->Invalidate();
window->OnMouseUp(WC_TOP_TOOLBAR__WIDX_SCENERY);
}
}
}
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && GetGameState().EditorStep != EditorStep::LandscapeEditor)
return;

if (gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
return;

ToggleSceneryWindow();
}

static void ShortcutBuildPaths()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;

if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
ContextOpenWindow(WindowClass::Footpath);
}
}
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && GetGameState().EditorStep != EditorStep::LandscapeEditor)
return;

if (gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
return;

ToggleFootpathWindow();
}

static void ShortcutBuildNewRide()
Expand Down Expand Up @@ -407,18 +392,13 @@ static void ShortcutClearScenery()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;

if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
WindowBase* window = WindowFindByClass(WindowClass::TopToolbar);
if (window != nullptr)
{
window->Invalidate();
window->OnMouseUp(WC_TOP_TOOLBAR__WIDX_CLEAR_SCENERY);
}
}
}
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && GetGameState().EditorStep != EditorStep::LandscapeEditor)
return;

if (gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
return;

ToggleClearSceneryWindow();
}

static void ShortcutQuickSaveGame()
Expand Down Expand Up @@ -455,14 +435,7 @@ static void ShortcutOpenSceneryPicker()

WindowBase* window_scenery = WindowFindByClass(WindowClass::Scenery);
if (window_scenery == nullptr)
{
WindowBase* window_toolbar = WindowFindByClass(WindowClass::TopToolbar);
if (window_toolbar != nullptr)
{
window_toolbar->Invalidate();
window_toolbar->OnMouseUp(WC_TOP_TOOLBAR__WIDX_SCENERY);
}
}
ToggleSceneryWindow();

window_scenery = WindowFindByClass(WindowClass::Scenery);
if (window_scenery != nullptr && !WidgetIsDisabled(*window_scenery, WC_SCENERY__WIDX_SCENERY_EYEDROPPER_BUTTON)
Expand Down
4 changes: 0 additions & 4 deletions src/openrct2-ui/interface/LandTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,8 @@ static uint16_t toolSizeSpriteIndices[] =
// clang-format on

uint16_t gLandToolSize;
money64 gLandToolRaiseCost;
money64 gLandToolLowerCost;
ObjectEntryIndex gLandToolTerrainSurface;
ObjectEntryIndex gLandToolTerrainEdge;
money64 gWaterToolRaiseCost;
money64 gWaterToolLowerCost;

uint32_t LandTool::SizeToSpriteIndex(uint16_t size)
{
Expand Down
4 changes: 0 additions & 4 deletions src/openrct2-ui/interface/LandTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ constexpr uint16_t kLandToolMaximumSize = 64;
constexpr uint16_t kLandToolMaximumSizeWithSprite = 7;

extern uint16_t gLandToolSize;
extern money64 gLandToolRaiseCost;
extern money64 gLandToolLowerCost;
extern ObjectEntryIndex gLandToolTerrainSurface;
extern ObjectEntryIndex gLandToolTerrainEdge;
extern money64 gWaterToolRaiseCost;
extern money64 gWaterToolLowerCost;

namespace OpenRCT2::LandTool
{
Expand Down
Loading

0 comments on commit 30e890c

Please sign in to comment.