Move gEditorStep to GameState_t (#21492)

* Move gEditorStep to GameState_t

* Fix compilation on GCC

---------

Co-authored-by: Gymnasiast <m.o.steenbeek@gmail.com>
This commit is contained in:
Harry Hopkinson 2024-03-01 20:26:20 +00:00 committed by GitHub
parent 14f0479c94
commit 701bbda164
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 86 additions and 72 deletions

View File

@ -193,7 +193,7 @@ static void ShortcutAdjustLand()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor)
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
@ -212,7 +212,7 @@ static void ShortcutAdjustWater()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor)
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
@ -231,7 +231,7 @@ static void ShortcutBuildScenery()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor)
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
@ -250,7 +250,7 @@ static void ShortcutBuildPaths()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor)
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
@ -357,7 +357,7 @@ static void ShortcutShowMap()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor)
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || GetGameState().EditorStep == EditorStep::LandscapeEditor)
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
ContextOpenWindow(WindowClass::Map);
}
@ -413,7 +413,7 @@ static void ShortcutClearScenery()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gEditorStep == EditorStep::LandscapeEditor)
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
@ -456,7 +456,7 @@ static void ShortcutLoadGame()
static void ShortcutOpenSceneryPicker()
{
if ((gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
|| (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && gEditorStep != EditorStep::LandscapeEditor))
|| (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && GetGameState().EditorStep != EditorStep::LandscapeEditor))
return;
WindowBase* window_scenery = WindowFindByClass(WindowClass::Scenery);
@ -760,7 +760,7 @@ void ShortcutManager::RegisterDefaultShortcuts()
{
WindowCloseAll();
}
else if (gEditorStep == EditorStep::LandscapeEditor)
else if (GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
WindowCloseTop();
}

View File

@ -52,6 +52,8 @@
#include <openrct2/world/Surface.h>
#include <openrct2/world/Wall.h>
using namespace OpenRCT2;
static void ViewportInteractionRemoveScenery(const SmallSceneryElement& smallSceneryElement, const CoordsXY& mapCoords);
static void ViewportInteractionRemoveFootpath(const PathElement& pathElement, const CoordsXY& mapCoords);
static void ViewportInteractionRemovePathAddition(const PathElement& pathElement, const CoordsXY& mapCoords);
@ -72,7 +74,7 @@ InteractionInfo ViewportInteractionGetItemLeft(const ScreenCoordsXY& screenCoord
return info;
//
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gEditorStep != EditorStep::RollercoasterDesigner)
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && GetGameState().EditorStep != EditorStep::RollercoasterDesigner)
return info;
info = GetMapCoordinatesFromPos(
@ -131,7 +133,7 @@ InteractionInfo ViewportInteractionGetItemLeft(const ScreenCoordsXY& screenCoord
break;
case ViewportInteractionItem::ParkEntrance:
{
auto& park = OpenRCT2::GetContext()->GetGameState()->GetPark();
auto& park = GetContext()->GetGameState()->GetPark();
auto parkName = park.Name.c_str();
auto ft = Formatter();
@ -258,7 +260,7 @@ InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoor
return info;
//
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gEditorStep != EditorStep::RollercoasterDesigner)
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && GetGameState().EditorStep != EditorStep::RollercoasterDesigner)
return info;
constexpr auto flags = static_cast<int32_t>(
@ -434,7 +436,7 @@ InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoor
auto banner = tileElement->AsBanner()->GetBanner();
if (banner != nullptr)
{
auto* bannerEntry = OpenRCT2::ObjectManager::GetObjectEntry<BannerSceneryEntry>(banner->type);
auto* bannerEntry = ObjectManager::GetObjectEntry<BannerSceneryEntry>(banner->type);
auto ft = Formatter();
ft.Add<StringId>(STR_MAP_TOOLTIP_BANNER_STRINGID_STRINGID);

View File

@ -92,11 +92,13 @@ public:
}
else
{
if (gEditorStep == EditorStep::ObjectSelection)
auto& gameState = GetGameState();
if (gameState.EditorStep == EditorStep::ObjectSelection)
{
HidePreviousStepButton();
}
else if (gEditorStep == EditorStep::RollercoasterDesigner)
else if (gameState.EditorStep == EditorStep::RollercoasterDesigner)
{
HideNextStepButton();
}
@ -134,17 +136,18 @@ public:
void OnMouseUp(WidgetIndex widgetIndex) override
{
auto& gameState = GetGameState();
if (widgetIndex == WIDX_PREVIOUS_STEP_BUTTON)
{
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
|| (GetNumFreeEntities() == MAX_ENTITIES && !(GetGameState().ParkFlags & PARK_FLAGS_SPRITES_INITIALISED)))
{
((this)->*(_previousButtonMouseUp[EnumValue(gEditorStep)]))();
((this)->*(_previousButtonMouseUp[EnumValue(gameState.EditorStep)]))();
}
}
else if (widgetIndex == WIDX_NEXT_STEP_BUTTON)
{
((this)->*(_nextButtonMouseUp[EnumValue(gEditorStep)]))();
((this)->*(_nextButtonMouseUp[EnumValue(gameState.EditorStep)]))();
}
}
@ -152,7 +155,7 @@ private:
void JumpBackToObjectSelection() const
{
WindowCloseAll();
gEditorStep = EditorStep::ObjectSelection;
GetGameState().EditorStep = EditorStep::ObjectSelection;
GfxInvalidateScreen();
}
@ -161,7 +164,7 @@ private:
WindowCloseAll();
SetAllSceneryItemsInvented();
ScenerySetDefaultPlacementConfiguration();
gEditorStep = EditorStep::LandscapeEditor;
GetGameState().EditorStep = EditorStep::LandscapeEditor;
ContextOpenWindow(WindowClass::Map);
GfxInvalidateScreen();
}
@ -170,7 +173,7 @@ private:
{
WindowCloseAll();
ContextOpenWindow(WindowClass::EditorInventionList);
gEditorStep = EditorStep::InventionsListSetUp;
GetGameState().EditorStep = EditorStep::InventionsListSetUp;
GfxInvalidateScreen();
}
@ -178,7 +181,7 @@ private:
{
WindowCloseAll();
ContextOpenWindow(WindowClass::EditorScenarioOptions);
gEditorStep = EditorStep::OptionsSelection;
GetGameState().EditorStep = EditorStep::OptionsSelection;
GfxInvalidateScreen();
}
@ -226,7 +229,7 @@ private:
{
WindowCloseAll();
ContextOpenWindow(WindowClass::EditorInventionList);
gEditorStep = EditorStep::InventionsListSetUp;
GetGameState().EditorStep = EditorStep::InventionsListSetUp;
}
else
{
@ -240,7 +243,7 @@ private:
{
WindowCloseAll();
ContextOpenWindow(WindowClass::EditorScenarioOptions);
gEditorStep = EditorStep::OptionsSelection;
GetGameState().EditorStep = EditorStep::OptionsSelection;
GfxInvalidateScreen();
}
@ -248,7 +251,7 @@ private:
{
WindowCloseAll();
ContextOpenWindow(WindowClass::EditorObjectiveOptions);
gEditorStep = EditorStep::ObjectiveSelection;
GetGameState().EditorStep = EditorStep::ObjectiveSelection;
GfxInvalidateScreen();
}
@ -312,7 +315,7 @@ private:
int16_t textX = (widgets[WIDX_PREVIOUS_IMAGE].left + 30 + widgets[WIDX_PREVIOUS_IMAGE].right) / 2 + windowPos.x;
int16_t textY = widgets[WIDX_PREVIOUS_IMAGE].top + 6 + windowPos.y;
StringId stringId = _editorStepNames[EnumValue(gEditorStep) - 1];
StringId stringId = _editorStepNames[EnumValue(GetGameState().EditorStep) - 1];
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
stringId = STR_EDITOR_STEP_OBJECT_SELECTION;
@ -350,7 +353,7 @@ private:
int16_t textX = (widgets[WIDX_NEXT_IMAGE].left + widgets[WIDX_NEXT_IMAGE].right - 30) / 2 + windowPos.x;
int16_t textY = widgets[WIDX_NEXT_IMAGE].top + 6 + windowPos.y;
StringId stringId = _editorStepNames[EnumValue(gEditorStep) + 1];
StringId stringId = _editorStepNames[EnumValue(GetGameState().EditorStep) + 1];
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
stringId = STR_EDITOR_STEP_ROLLERCOASTER_DESIGNER;
@ -363,7 +366,7 @@ private:
int16_t stateX = (widgets[WIDX_PREVIOUS_IMAGE].right + widgets[WIDX_NEXT_IMAGE].left) / 2 + windowPos.x;
int16_t stateY = height - 0x0C + windowPos.y;
DrawTextBasic(
dpi, { stateX, stateY }, _editorStepNames[EnumValue(gEditorStep)], {},
dpi, { stateX, stateY }, _editorStepNames[EnumValue(GetGameState().EditorStep)], {},
{ static_cast<colour_t>(NOT_TRANSLUCENT(colours[2]) | COLOUR_FLAG_OUTLINE), TextAlignment::CENTRE });
}

View File

@ -16,6 +16,7 @@
#include <openrct2/Editor.h>
#include <openrct2/EditorObjectSelectionSession.h>
#include <openrct2/Game.h>
#include <openrct2/GameState.h>
#include <openrct2/OpenRCT2.h>
#include <openrct2/actions/LoadOrQuitAction.h>
#include <openrct2/audio/audio.h>
@ -41,6 +42,8 @@
#include <string>
#include <vector>
using namespace OpenRCT2;
enum
{
FILTER_RCT1 = (1 << 0),
@ -454,7 +457,7 @@ public:
if (_loadedObject != nullptr)
{
auto descriptor = _loadedObject->GetDescriptor();
auto& objectManager = OpenRCT2::GetContext()->GetObjectManager();
auto& objectManager = GetContext()->GetObjectManager();
auto entryIndex = objectManager.GetLoadedObjectEntryIndex(descriptor);
if (entryIndex != OBJECT_ENTRY_INDEX_NULL)
{
@ -604,7 +607,7 @@ public:
Invalidate();
const CursorState* state = ContextGetCursorState();
OpenRCT2::Audio::Play(OpenRCT2::Audio::SoundId::Click1, 0, state->position.x);
Audio::Play(Audio::SoundId::Click1, 0, state->position.x);
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
{
@ -619,9 +622,9 @@ public:
_loadedObject = nullptr;
}
auto& objRepository = OpenRCT2::GetContext()->GetObjectRepository();
auto& objRepository = GetContext()->GetObjectRepository();
_loadedObject = objRepository.LoadObject(listItem->repositoryItem);
auto& objManager = OpenRCT2::GetContext()->GetObjectManager();
auto& objManager = GetContext()->GetObjectManager();
objManager.LoadObject(_loadedObject.get()->GetIdentifier());
// This function calls window_track_list_open
@ -698,7 +701,7 @@ public:
if (selectedObject != -1)
{
auto listItem = &_listItems[selectedObject];
auto& objRepository = OpenRCT2::GetContext()->GetObjectRepository();
auto& objRepository = GetContext()->GetObjectRepository();
_loadedObject = objRepository.LoadObject(listItem->repositoryItem);
if (_loadedObject != nullptr)
{
@ -1544,7 +1547,7 @@ private:
SetEveryRideTypeInvented();
SetEveryRideEntryInvented();
gEditorStep = EditorStep::DesignsManager;
GetGameState().EditorStep = EditorStep::DesignsManager;
int32_t entry_index = 0;
for (; ObjectEntryGetChunk(ObjectType::Ride, entry_index) == nullptr; entry_index++)
@ -1606,7 +1609,7 @@ static StringId GetRideTypeStringId(const ObjectRepositoryItem* item)
*/
void EditorLoadSelectedObjects()
{
auto& objManager = OpenRCT2::GetContext()->GetObjectManager();
auto& objManager = GetContext()->GetObjectManager();
int32_t numItems = static_cast<int32_t>(ObjectRepositoryGetItemsCount());
const ObjectRepositoryItem* items = ObjectRepositoryGetItems();
bool showFallbackWarning = false;

View File

@ -345,7 +345,7 @@ static void Select(const char* path)
SetAndSaveConfigPath(gConfigGeneral.LastSaveScenarioDirectory, pathBuffer);
int32_t parkFlagsBackup = gameState.ParkFlags;
gameState.ParkFlags &= ~PARK_FLAGS_SPRITES_INITIALISED;
gEditorStep = EditorStep::Invalid;
gameState.EditorStep = EditorStep::Invalid;
gScenarioFileName = std::string(String::ToStringView(pathBuffer, std::size(pathBuffer)));
int32_t success = ScenarioSave(gameState, pathBuffer, gConfigGeneral.SavePluginData ? 3 : 2);
gameState.ParkFlags = parkFlagsBackup;
@ -359,7 +359,7 @@ static void Select(const char* path)
else
{
ContextShowError(STR_FILE_DIALOG_TITLE_SAVE_SCENARIO, STR_SCENARIO_SAVE_FAILED, {});
gEditorStep = EditorStep::ObjectiveSelection;
gameState.EditorStep = EditorStep::ObjectiveSelection;
InvokeCallback(MODAL_RESULT_FAIL, pathBuffer);
}
break;

View File

@ -3047,20 +3047,22 @@ public:
widgets[WIDX_NEWS].type = WindowWidgetType::Empty;
widgets[WIDX_NETWORK].type = WindowWidgetType::Empty;
if (gEditorStep != EditorStep::LandscapeEditor)
auto& gameState = GetGameState();
if (gameState.EditorStep != EditorStep::LandscapeEditor)
{
widgets[WIDX_LAND].type = WindowWidgetType::Empty;
widgets[WIDX_WATER].type = WindowWidgetType::Empty;
}
if (gEditorStep != EditorStep::RollercoasterDesigner)
if (gameState.EditorStep != EditorStep::RollercoasterDesigner)
{
widgets[WIDX_RIDES].type = WindowWidgetType::Empty;
widgets[WIDX_CONSTRUCT_RIDE].type = WindowWidgetType::Empty;
widgets[WIDX_FASTFORWARD].type = WindowWidgetType::Empty;
}
if (gEditorStep != EditorStep::LandscapeEditor && gEditorStep != EditorStep::RollercoasterDesigner)
if (gameState.EditorStep != EditorStep::LandscapeEditor
&& gameState.EditorStep != EditorStep::RollercoasterDesigner)
{
widgets[WIDX_MAP].type = WindowWidgetType::Empty;
widgets[WIDX_SCENERY].type = WindowWidgetType::Empty;
@ -3537,7 +3539,7 @@ void TopToolbar::InitMapMenu(Widget& widget)
auto i = 0;
gDropdownItems[i++].Format = STR_SHORTCUT_SHOW_MAP;
gDropdownItems[i++].Format = STR_EXTRA_VIEWPORT;
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && gEditorStep == EditorStep::LandscapeEditor)
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
gDropdownItems[i++].Format = STR_MAPGEN_WINDOW_TITLE;
}
@ -3568,7 +3570,7 @@ void TopToolbar::InitMapMenu(Widget& widget)
void TopToolbar::MapMenuDropdown(int16_t dropdownIndex)
{
int32_t customStartIndex = 3;
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && gEditorStep == EditorStep::LandscapeEditor)
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && GetGameState().EditorStep == EditorStep::LandscapeEditor)
{
customStartIndex++;
}

View File

@ -54,8 +54,6 @@
using namespace OpenRCT2;
EditorStep gEditorStep;
namespace Editor
{
static std::array<std::vector<uint8_t>, EnumValue(ObjectType::Count)> _editorSelectedObjectFlags;
@ -105,11 +103,11 @@ namespace Editor
void Load()
{
auto& gameState = GetGameState();
OpenRCT2::Audio::StopAll();
Audio::StopAll();
ObjectListLoad();
OpenRCT2::GetContext()->GetGameState()->InitAll(DEFAULT_MAP_SIZE);
GetContext()->GetGameState()->InitAll(DEFAULT_MAP_SIZE);
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
gEditorStep = EditorStep::ObjectSelection;
gameState.EditorStep = EditorStep::ObjectSelection;
gameState.ParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
gameState.ScenarioCategory = SCENARIO_CATEGORY_OTHER;
ViewportInitAll();
@ -149,7 +147,7 @@ namespace Editor
ScenarioReset(gameState);
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
gEditorStep = EditorStep::ObjectiveSelection;
gameState.EditorStep = EditorStep::ObjectiveSelection;
gameState.ScenarioCategory = SCENARIO_CATEGORY_OTHER;
ViewportInitAll();
OpenEditorWindows();
@ -163,15 +161,15 @@ namespace Editor
*/
void LoadTrackDesigner()
{
OpenRCT2::Audio::StopAll();
Audio::StopAll();
gScreenFlags = SCREEN_FLAGS_TRACK_DESIGNER;
gScreenAge = 0;
ObjectManagerUnloadAllObjects();
ObjectListLoad();
OpenRCT2::GetContext()->GetGameState()->InitAll(DEFAULT_MAP_SIZE);
GetContext()->GetGameState()->InitAll(DEFAULT_MAP_SIZE);
SetAllLandOwned();
gEditorStep = EditorStep::ObjectSelection;
GetGameState().EditorStep = EditorStep::ObjectSelection;
ViewportInitAll();
WindowBase* mainWindow = OpenEditorWindows();
mainWindow->SetLocation(TileCoordsXYZ{ 75, 75, 14 }.ToCoordsXYZ());
@ -184,15 +182,15 @@ namespace Editor
*/
void LoadTrackManager()
{
OpenRCT2::Audio::StopAll();
Audio::StopAll();
gScreenFlags = SCREEN_FLAGS_TRACK_MANAGER;
gScreenAge = 0;
ObjectManagerUnloadAllObjects();
ObjectListLoad();
OpenRCT2::GetContext()->GetGameState()->InitAll(DEFAULT_MAP_SIZE);
GetContext()->GetGameState()->InitAll(DEFAULT_MAP_SIZE);
SetAllLandOwned();
gEditorStep = EditorStep::ObjectSelection;
GetGameState().EditorStep = EditorStep::ObjectSelection;
ViewportInitAll();
WindowBase* mainWindow = OpenEditorWindows();
mainWindow->SetLocation(TileCoordsXYZ{ 75, 75, 14 }.ToCoordsXYZ());
@ -246,7 +244,7 @@ namespace Editor
{
ClearMapForEditing(loadedFromSave);
gEditorStep = EditorStep::LandscapeEditor;
GetGameState().EditorStep = EditorStep::LandscapeEditor;
gScreenAge = 0;
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
ViewportInitAll();
@ -367,7 +365,7 @@ namespace Editor
return;
}
switch (gEditorStep)
switch (GetGameState().EditorStep)
{
case EditorStep::ObjectSelection:
if (WindowFindByClass(WindowClass::EditorObjectSelection) != nullptr)

View File

@ -45,6 +45,4 @@ enum class EditorStep : uint8_t
Invalid = 255, // 255
};
extern EditorStep gEditorStep;
void EditorOpenWindowsForCurrentStep();

View File

@ -12,6 +12,7 @@
#include "Context.h"
#include "Editor.h"
#include "Game.h"
#include "GameState.h"
#include "OpenRCT2.h"
#include "drawing/Drawing.h"
#include "localisation/Formatter.h"
@ -479,6 +480,7 @@ void ResetSelectedObjectCountAndSize()
void FinishObjectSelection()
{
auto& gameState = OpenRCT2::GetGameState();
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
{
SetEveryRideTypeInvented();
@ -491,14 +493,14 @@ void FinishObjectSelection()
gLastEntranceStyle = 0;
}
gEditorStep = EditorStep::RollercoasterDesigner;
gameState.EditorStep = EditorStep::RollercoasterDesigner;
GfxInvalidateScreen();
}
else
{
SetAllSceneryItemsInvented();
ScenerySetDefaultPlacementConfiguration();
gEditorStep = EditorStep::LandscapeEditor;
gameState.EditorStep = EditorStep::LandscapeEditor;
GfxInvalidateScreen();
}
}

View File

@ -10,6 +10,7 @@
#pragma once
#include "Date.h"
#include "Editor.h"
#include "Limits.h"
#include "interface/ZoomLevel.h"
#include "management/Finance.h"
@ -75,6 +76,8 @@ namespace OpenRCT2
random_engine_t ScenarioRand;
TileCoordsXY MapSize;
::EditorStep EditorStep;
SCENARIO_CATEGORY ScenarioCategory;
std::string ScenarioName;
std::string ScenarioDetails;

View File

@ -12,6 +12,7 @@
#include "../Context.h"
#include "../Editor.h"
#include "../Game.h"
#include "../GameState.h"
#include "../Input.h"
#include "../OpenRCT2.h"
#include "../audio/audio.h"
@ -39,6 +40,8 @@
#include <iterator>
#include <list>
using namespace OpenRCT2;
std::list<std::shared_ptr<WindowBase>> g_window_list;
WindowBase* gWindowAudioExclusive;
@ -152,7 +155,7 @@ void WindowUpdateAll()
}
});
auto windowManager = OpenRCT2::GetContext()->GetUiContext()->GetWindowManager();
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
windowManager->UpdateMouseWheel();
}
@ -331,7 +334,7 @@ void WindowCloseTop()
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
{
if (gEditorStep != EditorStep::LandscapeEditor)
if (GetGameState().EditorStep != EditorStep::LandscapeEditor)
return;
}
@ -1088,7 +1091,7 @@ void MainWindowZoom(bool zoomIn, bool atCursor)
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && gEditorStep != EditorStep::LandscapeEditor)
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && GetGameState().EditorStep != EditorStep::LandscapeEditor)
return;
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
@ -1649,7 +1652,7 @@ void WindowCloseConstructionWindows()
*/
void WindowUpdateViewportRideMusic()
{
OpenRCT2::RideAudio::ClearAllViewportInstances();
RideAudio::ClearAllViewportInstances();
g_music_tracking_viewport = nullptr;
for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++)
@ -1663,11 +1666,11 @@ void WindowUpdateViewportRideMusic()
gWindowAudioExclusive = w;
if (viewport->zoom <= ZoomLevel{ 0 })
OpenRCT2::Audio::gVolumeAdjustZoom = 0;
Audio::gVolumeAdjustZoom = 0;
else if (viewport->zoom == ZoomLevel{ 1 })
OpenRCT2::Audio::gVolumeAdjustZoom = 30;
Audio::gVolumeAdjustZoom = 30;
else
OpenRCT2::Audio::gVolumeAdjustZoom = 60;
Audio::gVolumeAdjustZoom = 60;
break;
}
}
@ -1854,7 +1857,7 @@ void WindowStartTextbox(
if (existing_text != STR_NONE)
{
char tempBuf[TEXT_INPUT_SIZE]{};
size_t len = OpenRCT2::FormatStringLegacy(tempBuf, TEXT_INPUT_SIZE, existing_text, &existing_args);
size_t len = FormatStringLegacy(tempBuf, TEXT_INPUT_SIZE, existing_text, &existing_args);
gTextBoxInput.assign(tempBuf, len);
}

View File

@ -618,7 +618,7 @@ namespace OpenRCT2
}
cs.ReadWrite(gameState.SavedViewRotation);
cs.ReadWrite(gLastEntranceStyle);
cs.ReadWrite(gEditorStep);
cs.ReadWrite(gameState.EditorStep);
});
}

View File

@ -326,7 +326,7 @@ namespace RCT1
// Do map initialisation, same kind of stuff done when loading scenario editor
auto context = OpenRCT2::GetContext();
context->GetGameState()->InitAll({ mapSize, mapSize });
gEditorStep = EditorStep::ObjectSelection;
gameState.EditorStep = EditorStep::ObjectSelection;
gameState.ParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
gameState.ScenarioCategory = SCENARIO_CATEGORY_OTHER;
}

View File

@ -231,7 +231,7 @@ namespace RCT2
{
Initialise();
gEditorStep = _s6.Info.EditorStep;
gameState.EditorStep = _s6.Info.EditorStep;
gameState.ScenarioCategory = static_cast<SCENARIO_CATEGORY>(_s6.Info.Category);
// Some scenarios have their scenario details in UTF-8, due to earlier bugs in OpenRCT2.

View File

@ -979,7 +979,7 @@ void Ride::UpdateAll()
// Remove all rides if scenario editor
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
{
switch (gEditorStep)
switch (GetGameState().EditorStep)
{
case EditorStep::ObjectSelection:
case EditorStep::LandscapeEditor:

View File

@ -664,7 +664,7 @@ bool Vehicle::SoundCanPlay() const
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
return false;
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gEditorStep != EditorStep::RollercoasterDesigner)
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && GetGameState().EditorStep != EditorStep::RollercoasterDesigner)
return false;
if (sound1_id == OpenRCT2::Audio::SoundId::Null && sound2_id == OpenRCT2::Audio::SoundId::Null)
@ -1180,7 +1180,7 @@ void VehicleUpdateAll()
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
return;
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gEditorStep != EditorStep::RollercoasterDesigner)
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && GetGameState().EditorStep != EditorStep::RollercoasterDesigner)
return;
for (auto vehicle : TrainManager::View())