Turn WindowDetail into strong enum

This commit is contained in:
Gymnasiast committed 2025-09-17 23:35:10 +02:00
1 parent a662c5ef8e
commit ea5fc03dd0
12 files changed
+40 -38

No files matched your search

+11 -11
View File
@@ -206,23 +206,23 @@ public:
}
}
WindowBase* OpenDetails(uint8_t type, int32_t id) override
WindowBase* openDetails(WindowDetail type, int32_t id) override
{
switch (type)
{
case WD_BANNER:
case WindowDetail::banner:
return BannerOpen(id);
case WD_NEW_CAMPAIGN:
case WindowDetail::newCampaign:
return NewCampaignOpen(id);
case WD_DEMOLISH_RIDE:
case WindowDetail::demolishRide:
return RideDemolishPromptOpen(*GetRide(RideId::FromUnderlying(id)));
case WD_REFURBISH_RIDE:
case WindowDetail::refurbishRide:
return RideRefurbishPromptOpen(*GetRide(RideId::FromUnderlying(id)));
case WD_SIGN:
case WindowDetail::sign:
return SignOpen(id);
case WD_SIGN_SMALL:
case WindowDetail::signSmall:
return SignSmallOpen(id);
case WD_PLAYER:
case WindowDetail::player:
return PlayerOpen(id);
default:
@@ -378,12 +378,12 @@ public:
switch (intent->GetWindowDetail())
{
case WD_VEHICLE:
case WindowDetail::vehicle:
return RideOpenVehicle(static_cast<Vehicle*>(intent->GetPointerExtra(INTENT_EXTRA_VEHICLE)));
case WD_TRACK:
case WindowDetail::track:
return RideOpenTrack(static_cast<TileElement*>(intent->GetPointerExtra(INTENT_EXTRA_TILE_ELEMENT)));
case WD_NULL:
case WindowDetail::null:
// Intent does not hold an window detail
break;
@@ -207,7 +207,7 @@ namespace OpenRCT2::Ui
{
case EntityType::Vehicle:
{
auto intent = Intent(WD_VEHICLE);
auto intent = Intent(WindowDetail::vehicle);
intent.PutExtra(INTENT_EXTRA_VEHICLE, entity);
ContextOpenIntent(&intent);
break;
@@ -248,7 +248,7 @@ namespace OpenRCT2::Ui
}
case ViewportInteractionItem::ride:
{
auto intent = Intent(WD_TRACK);
auto intent = Intent(WindowDetail::track);
intent.PutExtra(INTENT_EXTRA_TILE_ELEMENT, info.Element);
ContextOpenIntent(&intent);
return true;
@@ -611,7 +611,7 @@ namespace OpenRCT2::Ui
ViewportInteractionRemoveLargeScenery(*info.Element->AsLargeScenery(), info.Loc);
break;
case ViewportInteractionItem::banner:
ContextOpenDetailWindow(WD_BANNER, info.Element->AsBanner()->GetIndex().ToUnderlying());
ContextOpenDetailWindow(WindowDetail::banner, info.Element->AsBanner()->GetIndex().ToUnderlying());
break;
}
@@ -699,7 +699,7 @@ namespace OpenRCT2::Ui
auto* wallEntry = wallElement.GetEntry();
if (wallEntry->scrolling_mode != kScrollingModeNone)
{
ContextOpenDetailWindow(WD_SIGN_SMALL, wallElement.GetBannerIndex().ToUnderlying());
ContextOpenDetailWindow(WindowDetail::signSmall, wallElement.GetBannerIndex().ToUnderlying());
}
else
{
@@ -720,7 +720,7 @@ namespace OpenRCT2::Ui
if (sceneryEntry->scrolling_mode != kScrollingModeNone)
{
auto bannerIndex = largeSceneryElement.GetBannerIndex();
ContextOpenDetailWindow(WD_SIGN, bannerIndex.ToUnderlying());
ContextOpenDetailWindow(WindowDetail::sign, bannerIndex.ToUnderlying());
}
else
{
+1 -1
View File
@@ -669,7 +669,7 @@ namespace OpenRCT2::Ui::Windows
{
if (widgetIndex >= WIDX_CAMPAIGN_1 && widgetIndex <= WIDX_CAMPAIGN_6)
{
ContextOpenDetailWindow(WD_NEW_CAMPAIGN, widgetIndex - WIDX_CAMPAIGN_1);
ContextOpenDetailWindow(WindowDetail::newCampaign, widgetIndex - WIDX_CAMPAIGN_1);
}
}
+2 -2
View File
@@ -1645,7 +1645,7 @@ namespace OpenRCT2::Ui::Windows
Rename();
break;
case WIDX_DEMOLISH:
ContextOpenDetailWindow(WD_DEMOLISH_RIDE, number);
ContextOpenDetailWindow(WindowDetail::demolishRide, number);
break;
case WIDX_CLOSE_LIGHT:
case WIDX_SIMULATE_LIGHT:
@@ -3758,7 +3758,7 @@ namespace OpenRCT2::Ui::Windows
LocateMechanic();
break;
case WIDX_REFURBISH_RIDE:
ContextOpenDetailWindow(WD_REFURBISH_RIDE, number);
ContextOpenDetailWindow(WindowDetail::refurbishRide, number);
break;
}
}
+1 -1
View File
@@ -3231,7 +3231,7 @@ namespace OpenRCT2::Ui::Windows
{
auto data = result->GetData<GameActions::BannerPlaceActionResult>();
Audio::Play3D(Audio::SoundId::PlaceItem, result->Position);
ContextOpenDetailWindow(WD_BANNER, data.bannerId.ToUnderlying());
ContextOpenDetailWindow(WindowDetail::banner, data.bannerId.ToUnderlying());
}
});
GameActions::Execute(&bannerPlaceAction, gameState);
+2 -2
View File
@@ -1716,10 +1716,10 @@ namespace OpenRCT2
return windowManager->OpenView(wc);
}
WindowBase* ContextOpenDetailWindow(uint8_t type, int32_t id)
WindowBase* ContextOpenDetailWindow(WindowDetail type, int32_t id)
{
auto windowManager = Ui::GetWindowManager();
return windowManager->OpenDetails(type, id);
return windowManager->openDetails(type, id);
}
WindowBase* ContextOpenIntent(Intent* intent)
+3 -1
View File
@@ -27,6 +27,8 @@ struct TTFFontDescriptor;
namespace OpenRCT2
{
enum class WindowDetail : uint8_t;
class AssetPackManager;
class Formatter;
class Intent;
@@ -169,7 +171,7 @@ namespace OpenRCT2
bool ContextHasFocus();
void ContextSetCursorTrap(bool value);
OpenRCT2::WindowBase* ContextOpenWindow(WindowClass wc);
OpenRCT2::WindowBase* ContextOpenDetailWindow(uint8_t type, int32_t id);
OpenRCT2::WindowBase* ContextOpenDetailWindow(WindowDetail type, int32_t id);
OpenRCT2::WindowBase* ContextOpenWindowView(uint8_t view);
OpenRCT2::WindowBase* ContextShowError(
StringId title, StringId message, const class OpenRCT2::Formatter& args, bool autoClose = false);
+11 -11
View File
@@ -111,21 +111,21 @@ namespace OpenRCT2
WV_CONTRIBUTORS,
};
enum WindowDetail
enum class WindowDetail : uint8_t
{
WD_BANNER,
WD_NEW_CAMPAIGN,
WD_DEMOLISH_RIDE,
WD_REFURBISH_RIDE,
WD_SIGN,
WD_SIGN_SMALL,
banner,
newCampaign,
demolishRide,
refurbishRide,
sign,
signSmall,
WD_PLAYER,
player,
WD_VEHICLE,
WD_TRACK,
vehicle,
track,
WD_NULL = 255,
null = 255,
};
} // namespace OpenRCT2
+1 -1
View File
@@ -5289,7 +5289,7 @@ void Ride::crash(uint8_t vehicleIndex)
if (gLegacyScene != LegacyScene::titleSequence && vehicle != nullptr)
{
// Open ride window for crashed vehicle
auto intent = Intent(WD_VEHICLE);
auto intent = Intent(WindowDetail::vehicle);
intent.PutExtra(INTENT_EXTRA_VEHICLE, vehicle);
WindowBase* w = ContextOpenIntent(&intent);
+1 -1
View File
@@ -22,7 +22,7 @@ namespace OpenRCT2::Ui
{
return nullptr;
}
WindowBase* OpenDetails(uint8_t /*type*/, int32_t /*id*/) override
WindowBase* openDetails(WindowDetail /*type*/, int32_t /*id*/) override
{
return nullptr;
}
+1 -1
View File
@@ -32,7 +32,7 @@ namespace OpenRCT2::Ui
virtual void Init() = 0;
virtual WindowBase* OpenWindow(WindowClass wc) = 0;
virtual WindowBase* OpenView(uint8_t view) = 0;
virtual WindowBase* OpenDetails(uint8_t type, int32_t id) = 0;
virtual WindowBase* openDetails(WindowDetail type, int32_t id) = 0;
virtual WindowBase* OpenIntent(Intent* intent) = 0;
virtual void BroadcastIntent(const Intent& intent) = 0;
virtual WindowBase* ShowError(StringId title, StringId message, const Formatter& formatter, bool autoClose = false) = 0;
+1 -1
View File
@@ -71,7 +71,7 @@ namespace OpenRCT2
class Intent
{
WindowClass _Class{ WindowClass::null };
WindowDetail _WindowDetail{ WD_NULL };
WindowDetail _WindowDetail{ WindowDetail::null };
IntentAction _Action{ INTENT_ACTION_NULL };
IntentDataStorage _Data;