Codechange: make WindowClass a scoped enum

This commit is contained in:
Rubidium
2026-04-25 20:16:40 +02:00
committed by rubidium42
parent a9a2965131
commit bcda4a72ee
134 changed files with 1361 additions and 1249 deletions
+17 -17
View File
@@ -626,7 +626,7 @@ bool EngineOverrideManager::ResetToCurrentNewGRFConfig()
*/
void SetupEngines()
{
CloseWindowByClass(WC_ENGINE_PREVIEW);
CloseWindowByClass(WindowClass::EnginePreview);
_engine_pool.CleanPool();
for (VehicleType type = VehicleType::Begin; type != VehicleType::CompanyEnd; type++) {
@@ -844,10 +844,10 @@ void StartupEngines()
}
/* Invalidate any open purchase lists */
InvalidateWindowClassesData(WC_BUILD_VEHICLE);
InvalidateWindowClassesData(WindowClass::BuildVehicle);
SetWindowClassesDirty(WC_BUILD_VEHICLE);
SetWindowClassesDirty(WC_REPLACE_VEHICLE);
SetWindowClassesDirty(WindowClass::BuildVehicle);
SetWindowClassesDirty(WindowClass::ReplaceVehicle);
}
/**
@@ -871,10 +871,10 @@ static void EnableEngineForCompany(EngineID eid, CompanyID company)
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
/* Update the toolbar. */
InvalidateWindowData(WC_MAIN_TOOLBAR, 0);
if (e->type == VehicleType::Road) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_ROAD);
if (e->type == VehicleType::Ship) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_WATER);
if (e->type == VehicleType::Aircraft) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_AIR);
InvalidateWindowData(WindowClass::MainToolbar, 0);
if (e->type == VehicleType::Road) InvalidateWindowData(WindowClass::BuildToolbar, TRANSPORT_ROAD);
if (e->type == VehicleType::Ship) InvalidateWindowData(WindowClass::BuildToolbar, TRANSPORT_WATER);
if (e->type == VehicleType::Aircraft) InvalidateWindowData(WindowClass::BuildToolbar, TRANSPORT_AIR);
}
}
@@ -921,7 +921,7 @@ static void AcceptEnginePreview(EngineID eid, CompanyID company, int recursion_d
* In singleplayer this function is called from the preview window, so
* we have to use the GUI-scope scheduling of InvalidateWindowData.
*/
InvalidateWindowClassesData(WC_ENGINE_PREVIEW);
InvalidateWindowClassesData(WindowClass::EnginePreview);
/* Don't search for variants to include if we are 10 levels deep already. */
if (recursion_depth >= 10) return;
@@ -1000,7 +1000,7 @@ static const IntervalTimer<TimerGameCalendar> _calendar_engines_daily({TimerGame
if (e->flags.Test(EngineFlag::ExclusivePreview)) {
if (e->preview_company != CompanyID::Invalid()) {
if (!--e->preview_wait) {
InvalidateWindowClassesData(WC_ENGINE_PREVIEW);
InvalidateWindowClassesData(WindowClass::EnginePreview);
e->preview_company = CompanyID::Invalid();
}
} else if (e->preview_asked.Count() < MAX_COMPANIES) {
@@ -1155,12 +1155,12 @@ static void NewVehicleAvailable(Engine *e)
}
/* Update the toolbar. */
if (e->type == VehicleType::Road) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_ROAD);
if (e->type == VehicleType::Ship) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_WATER);
if (e->type == VehicleType::Aircraft) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_AIR);
if (e->type == VehicleType::Road) InvalidateWindowData(WindowClass::BuildToolbar, TRANSPORT_ROAD);
if (e->type == VehicleType::Ship) InvalidateWindowData(WindowClass::BuildToolbar, TRANSPORT_WATER);
if (e->type == VehicleType::Aircraft) InvalidateWindowData(WindowClass::BuildToolbar, TRANSPORT_AIR);
/* Remove from preview windows */
InvalidateWindowClassesData(WC_ENGINE_PREVIEW);
InvalidateWindowClassesData(WindowClass::EnginePreview);
}
/** Monthly update of the availability, reliability, and preview offers of the engines. */
@@ -1202,11 +1202,11 @@ void CalendarEnginesMonthlyLoop()
}
}
InvalidateWindowClassesData(WC_BUILD_VEHICLE); // rebuild the purchase list (esp. when sorted by reliability)
InvalidateWindowClassesData(WindowClass::BuildVehicle); // rebuild the purchase list (esp. when sorted by reliability)
if (refresh) {
SetWindowClassesDirty(WC_BUILD_VEHICLE);
SetWindowClassesDirty(WC_REPLACE_VEHICLE);
SetWindowClassesDirty(WindowClass::BuildVehicle);
SetWindowClassesDirty(WindowClass::ReplaceVehicle);
}
}
}