mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-22 06:23:04 +01:00
Make WindowView into strong enum
This commit is contained in:
@@ -70,7 +70,7 @@ public:
|
||||
case WindowClass::bottomToolbar:
|
||||
return GameBottomToolbarOpen();
|
||||
case WindowClass::changelog:
|
||||
return OpenView(WV_CHANGELOG);
|
||||
return openView(WindowView::changelog);
|
||||
case WindowClass::cheats:
|
||||
return CheatsOpen();
|
||||
case WindowClass::clearScenery:
|
||||
@@ -167,39 +167,39 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
WindowBase* OpenView(uint8_t view) override
|
||||
WindowBase* openView(WindowView view) override
|
||||
{
|
||||
switch (view)
|
||||
{
|
||||
case WV_PARK_AWARDS:
|
||||
case WindowView::parkAwards:
|
||||
return ParkAwardsOpen();
|
||||
case WV_PARK_RATING:
|
||||
case WindowView::parkRating:
|
||||
return ParkRatingOpen();
|
||||
case WV_PARK_OBJECTIVE:
|
||||
case WindowView::parkObjective:
|
||||
return ParkObjectiveOpen();
|
||||
case WV_PARK_GUESTS:
|
||||
case WindowView::parkGuests:
|
||||
return ParkGuestsOpen();
|
||||
case WV_FINANCES_RESEARCH:
|
||||
case WindowView::financesResearch:
|
||||
return FinancesResearchOpen();
|
||||
case WV_RIDE_RESEARCH:
|
||||
case WindowView::rideResearch:
|
||||
if (Config::Get().interface.ToolbarShowResearch)
|
||||
{
|
||||
return this->OpenWindow(WindowClass::research);
|
||||
}
|
||||
return NewRideOpenResearch();
|
||||
case WV_MAZE_CONSTRUCTION:
|
||||
case WindowView::mazeConstruction:
|
||||
return MazeConstructionOpen();
|
||||
case WV_NETWORK_PASSWORD:
|
||||
case WindowView::networkPassword:
|
||||
return NetworkStatusOpenPassword();
|
||||
case WV_EDITOR_BOTTOM_TOOLBAR:
|
||||
case WindowView::editorBottomToolbar:
|
||||
return EditorBottomToolbarOpen();
|
||||
case WV_CHANGELOG:
|
||||
return ChangelogOpen(WV_CHANGELOG);
|
||||
case WV_NEW_VERSION_INFO:
|
||||
return ChangelogOpen(WV_NEW_VERSION_INFO);
|
||||
case WV_CONTRIBUTORS:
|
||||
return ChangelogOpen(WV_CONTRIBUTORS);
|
||||
case WV_FINANCE_MARKETING:
|
||||
case WindowView::changelog:
|
||||
return ChangelogOpen(WindowView::changelog);
|
||||
case WindowView::newVersionInfo:
|
||||
return ChangelogOpen(WindowView::newVersionInfo);
|
||||
case WindowView::contributors:
|
||||
return ChangelogOpen(WindowView::contributors);
|
||||
case WindowView::financeMarketing:
|
||||
return FinancesMarketingOpen();
|
||||
default:
|
||||
return nullptr;
|
||||
|
||||
@@ -185,7 +185,7 @@ static void ShortcutRemoveTopBottomToolbarToggle()
|
||||
else
|
||||
{
|
||||
ContextOpenWindow(WindowClass::topToolbar);
|
||||
ContextOpenWindowView(WV_EDITOR_BOTTOM_TOOLBAR);
|
||||
ContextOpenWindowView(WindowView::editorBottomToolbar);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -279,7 +279,7 @@ static void ShortcutShowResearchInformation()
|
||||
|
||||
if (!isInEditorMode())
|
||||
{
|
||||
ContextOpenWindowView(WV_RIDE_RESEARCH);
|
||||
ContextOpenWindowView(WindowView::rideResearch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,13 +136,13 @@ namespace OpenRCT2::Ui::Windows
|
||||
ContextOpenWindow(WindowClass::changelog);
|
||||
break;
|
||||
case WIDX_NEW_VERSION:
|
||||
ContextOpenWindowView(WV_NEW_VERSION_INFO);
|
||||
ContextOpenWindowView(WindowView::newVersionInfo);
|
||||
break;
|
||||
case WIDX_COPY_BUILD_INFO:
|
||||
OpenRCT2::GetContext()->GetUiContext().SetClipboardText(gVersionInfoFull);
|
||||
break;
|
||||
case WIDX_CONTRIBUTORS_BUTTON:
|
||||
ContextOpenWindowView(WV_CONTRIBUTORS);
|
||||
ContextOpenWindowView(WindowView::contributors);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
const NewVersionInfo* _newVersionInfo;
|
||||
std::vector<std::string> _changelogLines;
|
||||
int32_t _changelogLongestLineWidth = 0;
|
||||
int _personality = 0;
|
||||
WindowView _personality = WindowView::changelog;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -83,35 +83,35 @@ namespace OpenRCT2::Ui::Windows
|
||||
*
|
||||
* @param personality
|
||||
*/
|
||||
bool SetPersonality(int personality)
|
||||
bool SetPersonality(WindowView personality)
|
||||
{
|
||||
switch (personality)
|
||||
{
|
||||
case WV_NEW_VERSION_INFO:
|
||||
case WindowView::newVersionInfo:
|
||||
if (!GetContext()->HasNewVersionInfo())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_personality = WV_NEW_VERSION_INFO;
|
||||
_personality = WindowView::newVersionInfo;
|
||||
NewVersionProcessInfo();
|
||||
widgets[WIDX_OPEN_URL].type = WidgetType::button;
|
||||
return true;
|
||||
|
||||
case WV_CHANGELOG:
|
||||
case WindowView::changelog:
|
||||
if (!ReadFile(PathId::changelog))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_personality = WV_CHANGELOG;
|
||||
_personality = WindowView::changelog;
|
||||
widgets[WIDX_TITLE].text = STR_CHANGELOG_TITLE;
|
||||
return true;
|
||||
|
||||
case WV_CONTRIBUTORS:
|
||||
case WindowView::contributors:
|
||||
if (!ReadFile(PathId::contributors))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_personality = WV_CONTRIBUTORS;
|
||||
_personality = WindowView::contributors;
|
||||
widgets[WIDX_TITLE].text = STR_CONTRIBUTORS_WINDOW;
|
||||
return true;
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
};
|
||||
|
||||
WindowBase* ChangelogOpen(int personality)
|
||||
WindowBase* ChangelogOpen(WindowView personality)
|
||||
{
|
||||
auto* windowMgr = GetWindowManager();
|
||||
auto* window = windowMgr->BringToFrontByClass(WindowClass::changelog);
|
||||
|
||||
@@ -436,10 +436,10 @@ namespace OpenRCT2::Ui::Windows
|
||||
ContextOpenWindow(WindowClass::finances);
|
||||
break;
|
||||
case WIDX_GUESTS:
|
||||
ContextOpenWindowView(WV_PARK_GUESTS);
|
||||
ContextOpenWindowView(WindowView::parkGuests);
|
||||
break;
|
||||
case WIDX_PARK_RATING:
|
||||
ContextOpenWindowView(WV_PARK_RATING);
|
||||
ContextOpenWindowView(WindowView::parkRating);
|
||||
break;
|
||||
case WIDX_MIDDLE_INSET:
|
||||
if (News::IsQueueEmpty())
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
WindowResearchDevelopmentMouseUp(widgetIndex, WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP);
|
||||
break;
|
||||
case WIDX_RESEARCH_FUNDING_BUTTON:
|
||||
ContextOpenWindowView(WV_FINANCES_RESEARCH);
|
||||
ContextOpenWindowView(WindowView::financesResearch);
|
||||
break;
|
||||
case WIDX_GROUP_BY_TRACK_TYPE:
|
||||
Config::Get().interface.ListRideVehiclesSeparately = !Config::Get().interface.ListRideVehiclesSeparately;
|
||||
|
||||
@@ -2898,7 +2898,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
switch (rtd.ConstructionWindowContext)
|
||||
{
|
||||
case RideConstructionWindowContext::Maze:
|
||||
return ContextOpenWindowView(WV_MAZE_CONSTRUCTION);
|
||||
return ContextOpenWindowView(WindowView::mazeConstruction);
|
||||
case RideConstructionWindowContext::Default:
|
||||
return windowMgr->Create<RideConstructionWindow>(
|
||||
WindowClass::rideConstruction, ScreenCoordsXY(0, 29), kWindowSize, WF_NO_AUTO_CLOSE);
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
break;
|
||||
case WIDX_NEW_VERSION:
|
||||
ContextOpenWindowView(WV_NEW_VERSION_INFO);
|
||||
ContextOpenWindowView(WindowView::newVersionInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -993,7 +993,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
break;
|
||||
case DDIDX_UPDATE_AVAILABLE:
|
||||
ContextOpenWindowView(WV_NEW_VERSION_INFO);
|
||||
ContextOpenWindowView(WindowView::newVersionInfo);
|
||||
break;
|
||||
case DDIDX_QUIT_TO_MENU:
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
WindowBase* BannerOpen(WindowNumber number);
|
||||
|
||||
// Changelog
|
||||
WindowBase* ChangelogOpen(int personality);
|
||||
WindowBase* ChangelogOpen(WindowView personality);
|
||||
|
||||
// Cheats
|
||||
WindowBase* CheatsOpen();
|
||||
|
||||
@@ -1710,10 +1710,10 @@ namespace OpenRCT2
|
||||
return windowManager->OpenWindow(wc);
|
||||
}
|
||||
|
||||
WindowBase* ContextOpenWindowView(uint8_t wc)
|
||||
WindowBase* ContextOpenWindowView(WindowView view)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
return windowManager->OpenView(wc);
|
||||
return windowManager->openView(view);
|
||||
}
|
||||
|
||||
WindowBase* ContextOpenDetailWindow(WindowDetail type, int32_t id)
|
||||
|
||||
@@ -28,7 +28,8 @@ struct TTFFontDescriptor;
|
||||
namespace OpenRCT2
|
||||
{
|
||||
enum class WindowDetail : uint8_t;
|
||||
|
||||
enum class WindowView : uint8_t;
|
||||
|
||||
class AssetPackManager;
|
||||
class Formatter;
|
||||
class Intent;
|
||||
@@ -172,7 +173,7 @@ namespace OpenRCT2
|
||||
void ContextSetCursorTrap(bool value);
|
||||
OpenRCT2::WindowBase* ContextOpenWindow(WindowClass wc);
|
||||
OpenRCT2::WindowBase* ContextOpenDetailWindow(WindowDetail type, int32_t id);
|
||||
OpenRCT2::WindowBase* ContextOpenWindowView(uint8_t view);
|
||||
OpenRCT2::WindowBase* ContextOpenWindowView(WindowView view);
|
||||
OpenRCT2::WindowBase* ContextShowError(
|
||||
StringId title, StringId message, const class OpenRCT2::Formatter& args, bool autoClose = false);
|
||||
OpenRCT2::WindowBase* ContextOpenIntent(OpenRCT2::Intent* intent);
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace OpenRCT2::Editor
|
||||
{
|
||||
auto* main = ContextOpenWindow(WindowClass::mainWindow);
|
||||
ContextOpenWindow(WindowClass::topToolbar);
|
||||
ContextOpenWindowView(WV_EDITOR_BOTTOM_TOOLBAR);
|
||||
ContextOpenWindowView(WindowView::editorBottomToolbar);
|
||||
return main;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,21 +94,21 @@ namespace OpenRCT2
|
||||
};
|
||||
using WindowFlags = uint32_t;
|
||||
|
||||
enum
|
||||
enum class WindowView : uint8_t
|
||||
{
|
||||
WV_PARK_AWARDS,
|
||||
WV_PARK_RATING,
|
||||
WV_PARK_OBJECTIVE,
|
||||
WV_PARK_GUESTS,
|
||||
WV_FINANCES_RESEARCH,
|
||||
WV_RIDE_RESEARCH,
|
||||
WV_MAZE_CONSTRUCTION,
|
||||
WV_NETWORK_PASSWORD,
|
||||
WV_EDITOR_BOTTOM_TOOLBAR,
|
||||
WV_CHANGELOG,
|
||||
WV_NEW_VERSION_INFO,
|
||||
WV_FINANCE_MARKETING,
|
||||
WV_CONTRIBUTORS,
|
||||
parkAwards,
|
||||
parkRating,
|
||||
parkObjective,
|
||||
parkGuests,
|
||||
financesResearch,
|
||||
rideResearch,
|
||||
mazeConstruction,
|
||||
networkPassword,
|
||||
editorBottomToolbar,
|
||||
changelog,
|
||||
newVersionInfo,
|
||||
financeMarketing,
|
||||
contributors,
|
||||
};
|
||||
|
||||
enum class WindowDetail : uint8_t
|
||||
|
||||
@@ -393,7 +393,7 @@ void News::OpenSubject(News::ItemType type, int32_t subject)
|
||||
ContextOpenWindow(WindowClass::finances);
|
||||
break;
|
||||
case News::ItemType::campaign:
|
||||
ContextOpenWindowView(WV_FINANCE_MARKETING);
|
||||
ContextOpenWindowView(WindowView::financeMarketing);
|
||||
break;
|
||||
case News::ItemType::research:
|
||||
{
|
||||
@@ -421,10 +421,10 @@ void News::OpenSubject(News::ItemType type, int32_t subject)
|
||||
break;
|
||||
}
|
||||
case News::ItemType::award:
|
||||
ContextOpenWindowView(WV_PARK_AWARDS);
|
||||
ContextOpenWindowView(WindowView::parkAwards);
|
||||
break;
|
||||
case News::ItemType::graph:
|
||||
ContextOpenWindowView(WV_PARK_RATING);
|
||||
ContextOpenWindowView(WindowView::parkRating);
|
||||
break;
|
||||
case News::ItemType::null:
|
||||
case News::ItemType::blank:
|
||||
|
||||
@@ -2341,7 +2341,7 @@ namespace OpenRCT2::Network
|
||||
connection.Disconnect();
|
||||
break;
|
||||
case Auth::requirePassword:
|
||||
ContextOpenWindowView(WV_NETWORK_PASSWORD);
|
||||
ContextOpenWindowView(WindowView::networkPassword);
|
||||
break;
|
||||
case Auth::unknownKeyDisallowed:
|
||||
connection.SetLastDisconnectReason(STR_MULTIPLAYER_UNKNOWN_KEY_DISALLOWED);
|
||||
|
||||
@@ -83,7 +83,7 @@ void ScenarioBegin(GameState_t& gameState)
|
||||
ScenarioReset(gameState);
|
||||
|
||||
if (gameState.scenarioOptions.objective.Type != ObjectiveType::none && !gLoadKeepWindowsOpen)
|
||||
ContextOpenWindowView(WV_PARK_OBJECTIVE);
|
||||
ContextOpenWindowView(WindowView::parkObjective);
|
||||
|
||||
gScreenAge = 0;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ static void ScenarioEnd()
|
||||
windowMgr->CloseByClass(WindowClass::dropdown);
|
||||
windowMgr->CloseAllExceptFlags(WF_STICK_TO_BACK | WF_STICK_TO_FRONT);
|
||||
|
||||
ContextOpenWindowView(WV_PARK_OBJECTIVE);
|
||||
ContextOpenWindowView(WindowView::parkObjective);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRCT2::Ui
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
WindowBase* OpenView(uint8_t /*view*/) override
|
||||
WindowBase* openView(WindowView /*view*/) override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRCT2::Ui
|
||||
virtual ~IWindowManager() = default;
|
||||
virtual void Init() = 0;
|
||||
virtual WindowBase* OpenWindow(WindowClass wc) = 0;
|
||||
virtual WindowBase* OpenView(uint8_t view) = 0;
|
||||
virtual WindowBase* openView(WindowView view) = 0;
|
||||
virtual WindowBase* openDetails(WindowDetail type, int32_t id) = 0;
|
||||
virtual WindowBase* OpenIntent(Intent* intent) = 0;
|
||||
virtual void BroadcastIntent(const Intent& intent) = 0;
|
||||
|
||||
Reference in New Issue
Block a user