From bcda4a72ee37f8f9a8e5f59a288e01d405753f5e Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sat, 25 Apr 2026 20:16:40 +0200 Subject: [PATCH] Codechange: make WindowClass a scoped enum --- bin/game/compat_15.nut | 111 +++++++++ src/ai/ai_core.cpp | 10 +- src/ai/ai_gui.cpp | 8 +- src/aircraft_cmd.cpp | 22 +- src/airport_gui.cpp | 16 +- src/autoreplace_cmd.cpp | 2 +- src/autoreplace_gui.cpp | 18 +- src/bootstrap_gui.cpp | 8 +- src/bridge_gui.cpp | 6 +- src/build_vehicle_gui.cpp | 14 +- src/cheat_gui.cpp | 20 +- src/company_cmd.cpp | 76 +++---- src/company_gui.cpp | 24 +- src/console_cmds.cpp | 2 +- src/console_gui.cpp | 8 +- src/date_gui.cpp | 4 +- src/depot.cpp | 2 +- src/depot_cmd.cpp | 4 +- src/depot_gui.cpp | 14 +- src/dock_gui.cpp | 26 +-- src/dropdown.cpp | 6 +- src/economy.cpp | 42 ++-- src/engine.cpp | 34 +-- src/engine_gui.cpp | 4 +- src/error_gui.cpp | 10 +- src/fios_gui.cpp | 12 +- src/framerate_gui.cpp | 4 +- src/game/game_core.cpp | 10 +- src/game/game_gui.cpp | 16 +- src/genworld.cpp | 6 +- src/genworld_gui.cpp | 24 +- src/goal.cpp | 28 +-- src/goal_gui.cpp | 10 +- src/graph_gui.cpp | 32 +-- src/ground_vehicle.cpp | 4 +- src/ground_vehicle.hpp | 2 +- src/group_cmd.cpp | 28 +-- src/group_gui.cpp | 14 +- src/help_gui.cpp | 2 +- src/highscore_gui.cpp | 8 +- src/industry_cmd.cpp | 24 +- src/industry_gui.cpp | 18 +- src/intro_gui.cpp | 2 +- src/league_cmd.cpp | 8 +- src/league_gui.cpp | 4 +- src/linkgraph/linkgraph_gui.cpp | 2 +- src/linkgraph/linkgraphjob.cpp | 2 +- src/main_gui.cpp | 4 +- src/misc_cmd.cpp | 4 +- src/misc_gui.cpp | 32 +-- src/music_gui.cpp | 36 +-- src/network/network.cpp | 6 +- src/network/network_chat_gui.cpp | 12 +- src/network/network_client.cpp | 30 +-- src/network/network_content.cpp | 4 +- src/network/network_content_gui.cpp | 26 +-- src/network/network_coordinator.cpp | 8 +- src/network/network_gamelist.cpp | 2 +- src/network/network_gui.cpp | 30 +-- src/network/network_server.cpp | 8 +- src/newgrf_config.cpp | 8 +- src/newgrf_debug_gui.cpp | 12 +- src/newgrf_gui.cpp | 82 +++---- src/newgrf_industries.cpp | 2 +- src/news_gui.cpp | 44 ++-- src/object_cmd.cpp | 8 +- src/object_gui.cpp | 2 +- src/openttd.cpp | 8 +- src/order_backup.cpp | 2 +- src/order_cmd.cpp | 20 +- src/order_gui.cpp | 12 +- src/osk_gui.cpp | 8 +- src/picker_gui.cpp | 24 +- src/rail_cmd.cpp | 6 +- src/rail_gui.cpp | 72 +++--- src/road_cmd.cpp | 6 +- src/road_gui.cpp | 64 +++--- src/roadveh_cmd.cpp | 12 +- src/saveload/afterload.cpp | 6 +- src/saveload/misc_sl.cpp | 2 +- src/saveload/saveload.cpp | 4 +- src/screenshot_gui.cpp | 6 +- src/script/api/script_log.cpp | 2 +- src/script/api/script_window.hpp.in | 4 +- src/script/script_gui.cpp | 42 ++-- src/settings.cpp | 6 +- src/settings_gui.cpp | 20 +- src/settings_table.cpp | 48 ++-- src/ship_cmd.cpp | 20 +- src/signs_cmd.cpp | 6 +- src/signs_gui.cpp | 8 +- src/smallmap_gui.cpp | 6 +- src/sound.cpp | 2 +- src/station.cpp | 18 +- src/station_cmd.cpp | 54 ++--- src/station_gui.cpp | 26 +-- src/statusbar_gui.cpp | 6 +- src/story.cpp | 18 +- src/story_gui.cpp | 4 +- src/strings.cpp | 14 +- src/subsidy.cpp | 8 +- src/subsidy_gui.cpp | 2 +- src/table/settings/difficulty_settings.ini | 2 +- src/table/settings/economy_settings.ini | 16 +- src/table/settings/game_settings.ini | 2 +- src/table/settings/gui_settings.ini | 12 +- src/table/settings/world_settings.ini | 4 +- src/terraform_gui.cpp | 10 +- src/textfile_gui.cpp | 2 +- src/timetable_cmd.cpp | 14 +- src/timetable_gui.cpp | 6 +- src/toolbar_gui.cpp | 10 +- src/town_cmd.cpp | 46 ++-- src/town_gui.cpp | 16 +- src/train_cmd.cpp | 98 ++++---- src/train_gui.cpp | 2 +- src/transparency_gui.cpp | 2 +- src/tree_gui.cpp | 2 +- src/vehicle.cpp | 81 +++---- src/vehicle_cmd.cpp | 16 +- src/vehicle_gui.cpp | 44 ++-- src/vehicle_gui.h | 8 +- src/video/cocoa/cocoa_v.mm | 2 +- src/video/sdl2_v.cpp | 2 +- src/video/win32_v.cpp | 4 +- src/viewport.cpp | 32 +-- src/viewport_gui.cpp | 4 +- src/waypoint.cpp | 2 +- src/waypoint_cmd.cpp | 8 +- src/waypoint_gui.cpp | 8 +- src/widgets/link_graph_legend_widget.h | 2 +- src/window.cpp | 248 ++++++++++----------- src/window_gui.h | 4 +- src/window_type.h | 224 +++++++++---------- 134 files changed, 1361 insertions(+), 1249 deletions(-) diff --git a/bin/game/compat_15.nut b/bin/game/compat_15.nut index 2741b25931..0684deb69b 100644 --- a/bin/game/compat_15.nut +++ b/bin/game/compat_15.nut @@ -27,3 +27,114 @@ GSWindow.WN_NETWORK_WINDOW_CONTENT_LIST <- GSWindow.NetworkWindowNumber.ContentL GSWindow.WN_NETWORK_WINDOW_START <- GSWindow.NetworkWindowNumber.StartServer; GSWindow.WN_NETWORK_STATUS_WINDOW_JOIN <- GSWindow.NetworkStatusWindowNumber.Join; GSWindow.WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD <- GSWindow.NetworkStatusWindowNumber.ContentDownload; + +GSWindow.WC_NONE <- GSWindow.WindowClass.None; +GSWindow.WC_MAIN_WINDOW <- GSWindow.WindowClass.MainWindow; +GSWindow.WC_MAIN_TOOLBAR <- GSWindow.WindowClass.MainToolbar; +GSWindow.WC_STATUS_BAR <- GSWindow.WindowClass.Statusbar; +GSWindow.WC_BUILD_TOOLBAR <- GSWindow.WindowClass.BuildToolbar; +GSWindow.WC_SCEN_BUILD_TOOLBAR <- GSWindow.WindowClass.ScenarioBuildToolbar; +GSWindow.WC_BUILD_TREES <- GSWindow.WindowClass.BuildTrees; +GSWindow.WC_TRANSPARENCY_TOOLBAR <- GSWindow.WindowClass.TransparencyToolbar; +GSWindow.WC_BUILD_SIGNAL <- GSWindow.WindowClass.BuildSignal; +GSWindow.WC_SMALLMAP <- GSWindow.WindowClass.SmallMap; +GSWindow.WC_ERRMSG <- GSWindow.WindowClass.ErrorMessage; +GSWindow.WC_TOOLTIPS <- GSWindow.WindowClass.ToolTips; +GSWindow.WC_QUERY_STRING <- GSWindow.WindowClass.QueryString; +GSWindow.WC_CONFIRM_POPUP_QUERY <- GSWindow.WindowClass.ConfirmPopupQuery; +GSWindow.WC_GOAL_QUESTION <- GSWindow.WindowClass.GoalQuestion; +GSWindow.WC_SAVELOAD <- GSWindow.WindowClass.SaveLoad; +GSWindow.WC_LAND_INFO <- GSWindow.WindowClass.LandInfo; +GSWindow.WC_DROPDOWN_MENU <- GSWindow.WindowClass.DropdownMenu; +GSWindow.WC_OSK <- GSWindow.WindowClass.OnScreenKeyboard; +GSWindow.WC_SET_DATE <- GSWindow.WindowClass.SetDate; +GSWindow.WC_SCRIPT_SETTINGS <- GSWindow.WindowClass.ScriptSettings; +GSWindow.WC_GRF_PARAMETERS <- GSWindow.WindowClass.NewGRFParameters; +GSWindow.WC_TEXTFILE <- GSWindow.WindowClass.Textfile; +GSWindow.WC_TOWN_AUTHORITY <- GSWindow.WindowClass.TownAuthority; +GSWindow.WC_VEHICLE_DETAILS <- GSWindow.WindowClass.VehicleDetails; +GSWindow.WC_VEHICLE_REFIT <- GSWindow.WindowClass.VehicleRefit; +GSWindow.WC_VEHICLE_ORDERS <- GSWindow.WindowClass.VehicleOrders; +GSWindow.WC_REPLACE_VEHICLE <- GSWindow.WindowClass.ReplaceVehicle; +GSWindow.WC_VEHICLE_TIMETABLE <- GSWindow.WindowClass.VehicleTimetable; +GSWindow.WC_COMPANY_COLOUR <- GSWindow.WindowClass.CompanyLivery; +GSWindow.WC_COMPANY_MANAGER_FACE <- GSWindow.WindowClass.CompanyManagerFace; +GSWindow.WC_SELECT_STATION <- GSWindow.WindowClass.JoinStation; +GSWindow.WC_NEWS_WINDOW <- GSWindow.WindowClass.News; +GSWindow.WC_TOWN_DIRECTORY <- GSWindow.WindowClass.TownDirectory; +GSWindow.WC_SUBSIDIES_LIST <- GSWindow.WindowClass.SubsidyList; +GSWindow.WC_INDUSTRY_DIRECTORY <- GSWindow.WindowClass.IndustryDirectory; +GSWindow.WC_MESSAGE_HISTORY <- GSWindow.WindowClass.MessageHistory; +GSWindow.WC_SIGN_LIST <- GSWindow.WindowClass.SignList; +GSWindow.WC_SCRIPT_LIST <- GSWindow.WindowClass.ScriptList; +GSWindow.WC_GOALS_LIST <- GSWindow.WindowClass.GoalList; +GSWindow.WC_STORY_BOOK <- GSWindow.WindowClass.StoryBook; +GSWindow.WC_STATION_LIST <- GSWindow.WindowClass.StationList; +GSWindow.WC_TRAINS_LIST <- GSWindow.WindowClass.TrainList; +GSWindow.WC_ROADVEH_LIST <- GSWindow.WindowClass.RoadVehicleList; +GSWindow.WC_SHIPS_LIST <- GSWindow.WindowClass.ShipList; +GSWindow.WC_AIRCRAFT_LIST <- GSWindow.WindowClass.AircraftList; +GSWindow.WC_TOWN_VIEW <- GSWindow.WindowClass.TownView; +GSWindow.WC_VEHICLE_VIEW <- GSWindow.WindowClass.VehicleView; +GSWindow.WC_STATION_VIEW <- GSWindow.WindowClass.StationView; +GSWindow.WC_VEHICLE_DEPOT <- GSWindow.WindowClass.VehicleDepot; +GSWindow.WC_WAYPOINT_VIEW <- GSWindow.WindowClass.WaypointView; +GSWindow.WC_INDUSTRY_VIEW <- GSWindow.WindowClass.IndustryView; +GSWindow.WC_COMPANY <- GSWindow.WindowClass.Company; +GSWindow.WC_BUILD_OBJECT <- GSWindow.WindowClass.BuildObject; +GSWindow.WC_BUILD_HOUSE <- GSWindow.WindowClass.BuildHouse; +GSWindow.WC_BUILD_VEHICLE <- GSWindow.WindowClass.BuildVehicle; +GSWindow.WC_BUILD_BRIDGE <- GSWindow.WindowClass.BuildBridge; +GSWindow.WC_BUILD_STATION <- GSWindow.WindowClass.BuildStation; +GSWindow.WC_BUS_STATION <- GSWindow.WindowClass.BuildBusStation; +GSWindow.WC_TRUCK_STATION <- GSWindow.WindowClass.BuildTruckStation; +GSWindow.WC_BUILD_DEPOT <- GSWindow.WindowClass.BuildDepot; +GSWindow.WC_BUILD_WAYPOINT <- GSWindow.WindowClass.BuildWaypoint; +GSWindow.WC_FOUND_TOWN <- GSWindow.WindowClass.FoundTown; +GSWindow.WC_BUILD_INDUSTRY <- GSWindow.WindowClass.BuildIndustry; +GSWindow.WC_SELECT_GAME <- GSWindow.WindowClass.SelectGame; +GSWindow.WC_SCEN_LAND_GEN <- GSWindow.WindowClass.ScenarioGenerateLandscape; +GSWindow.WC_GENERATE_LANDSCAPE <- GSWindow.WindowClass.GenerateLandscape; +GSWindow.WC_MODAL_PROGRESS <- GSWindow.WindowClass.ModalProgress; +GSWindow.WC_NETWORK_WINDOW <- GSWindow.WindowClass.Network; +GSWindow.WC_CLIENT_LIST <- GSWindow.WindowClass.NetworkClientList; +GSWindow.WC_NETWORK_STATUS_WINDOW <- GSWindow.WindowClass.NetworkStatus; +GSWindow.WC_NETWORK_ASK_RELAY <- GSWindow.WindowClass.NetworkAskRelay; +GSWindow.WC_NETWORK_ASK_SURVEY <- GSWindow.WindowClass.NetworkAskSurvey; +GSWindow.WC_SEND_NETWORK_MSG <- GSWindow.WindowClass.NetworkChat; +GSWindow.WC_INDUSTRY_CARGOES <- GSWindow.WindowClass.IndustryCargoes; +GSWindow.WC_GRAPH_LEGEND <- GSWindow.WindowClass.GraphLegend; +GSWindow.WC_FINANCES <- GSWindow.WindowClass.Finances; +GSWindow.WC_INCOME_GRAPH <- GSWindow.WindowClass.IncomeGraph; +GSWindow.WC_OPERATING_PROFIT <- GSWindow.WindowClass.OperatingProfitGraph; +GSWindow.WC_DELIVERED_CARGO <- GSWindow.WindowClass.DeliveredCargoGraph; +GSWindow.WC_PERFORMANCE_HISTORY <- GSWindow.WindowClass.PerformanceGraph; +GSWindow.WC_COMPANY_VALUE <- GSWindow.WindowClass.CompanyValueGraph; +GSWindow.WC_COMPANY_LEAGUE <- GSWindow.WindowClass.CompanyLeague; +GSWindow.WC_PAYMENT_RATES <- GSWindow.WindowClass.CargoPaymentRatesGraph; +GSWindow.WC_PERFORMANCE_DETAIL <- GSWindow.WindowClass.PerformanceDetail; +GSWindow.WC_INDUSTRY_PRODUCTION <- GSWindow.WindowClass.IndustryProductionGraph; +GSWindow.WC_TOWN_CARGO_GRAPH <- GSWindow.WindowClass.TownCargoGraph; +GSWindow.WC_COMPANY_INFRASTRUCTURE <- GSWindow.WindowClass.CompanyInfrastructure; +GSWindow.WC_BUY_COMPANY <- GSWindow.WindowClass.BuyCompany; +GSWindow.WC_ENGINE_PREVIEW <- GSWindow.WindowClass.EnginePreview; +GSWindow.WC_MUSIC_WINDOW <- GSWindow.WindowClass.Music; +GSWindow.WC_MUSIC_TRACK_SELECTION <- GSWindow.WindowClass.MusicTrackSelection; +GSWindow.WC_GAME_OPTIONS <- GSWindow.WindowClass.GameOptions; +GSWindow.WC_CUSTOM_CURRENCY <- GSWindow.WindowClass.CustomCurrenty; +GSWindow.WC_CHEATS <- GSWindow.WindowClass.Cheat; +GSWindow.WC_EXTRA_VIEWPORT <- GSWindow.WindowClass.ExtraViewport; +GSWindow.WC_CONSOLE <- GSWindow.WindowClass.Console; +GSWindow.WC_BOOTSTRAP <- GSWindow.WindowClass.Bootstrap; +GSWindow.WC_HIGHSCORE <- GSWindow.WindowClass.Highscore; +GSWindow.WC_ENDSCREEN <- GSWindow.WindowClass.Endscreen; +GSWindow.WC_SCRIPT_DEBUG <- GSWindow.WindowClass.ScriptDebug; +GSWindow.WC_NEWGRF_INSPECT <- GSWindow.WindowClass.NewGRFInspect; +GSWindow.WC_SPRITE_ALIGNER <- GSWindow.WindowClass.SpriteAligner; +GSWindow.WC_LINKGRAPH_LEGEND <- GSWindow.WindowClass.LinkGraphLegend; +GSWindow.WC_SAVE_PRESET <- GSWindow.WindowClass.SavePreset; +GSWindow.WC_FRAMERATE_DISPLAY <- GSWindow.WindowClass.FramerateDisplay; +GSWindow.WC_FRAMETIME_GRAPH <- GSWindow.WindowClass.FrametimeGraph; +GSWindow.WC_SCREENSHOT <- GSWindow.WindowClass.Screenshot; +GSWindow.WC_HELPWIN <- GSWindow.WindowClass.Help; +GSWindow.WC_INVALID <- GSWindow.WindowClass.Invalid; diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp index 561a625e6d..759fa0ac4a 100644 --- a/src/ai/ai_core.cpp +++ b/src/ai/ai_core.cpp @@ -65,7 +65,7 @@ c->ai_instance->LoadOnStack(config->GetToLoadData()); config->SetToLoadData(nullptr); - InvalidateWindowClassesData(WC_SCRIPT_DEBUG, -1); + InvalidateWindowClassesData(WindowClass::ScriptDebug, -1); return; } @@ -112,7 +112,7 @@ c->ai_info = nullptr; c->ai_config.reset(); - InvalidateWindowClassesData(WC_SCRIPT_DEBUG, -1); + InvalidateWindowClassesData(WindowClass::ScriptDebug, -1); } /* static */ void AI::Pause(CompanyID company) @@ -307,9 +307,9 @@ AI::scanner_library->RescanDir(); ResetConfig(); - InvalidateWindowData(WC_SCRIPT_LIST, 0, 1); - SetWindowClassesDirty(WC_SCRIPT_DEBUG); - InvalidateWindowClassesData(WC_SCRIPT_SETTINGS); + InvalidateWindowData(WindowClass::ScriptList, 0, 1); + SetWindowClassesDirty(WindowClass::ScriptDebug); + InvalidateWindowClassesData(WindowClass::ScriptSettings); } /** diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index e43b75869b..264166e0ff 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -85,7 +85,7 @@ static constexpr std::initializer_list _nested_ai_config_widgets = /** Window definition for the configure AI window. */ static WindowDesc _ai_config_desc( WindowPosition::Center, {}, 0, 0, - WC_GAME_OPTIONS, WC_NONE, + WindowClass::GameOptions, WindowClass::None, {}, _nested_ai_config_widgets ); @@ -111,8 +111,8 @@ struct AIConfigWindow : public Window { void Close([[maybe_unused]] int data = 0) override { - CloseWindowByClass(WC_SCRIPT_LIST); - CloseWindowByClass(WC_SCRIPT_SETTINGS); + CloseWindowByClass(WindowClass::ScriptList); + CloseWindowByClass(WindowClass::ScriptSettings); this->Window::Close(); } @@ -335,7 +335,7 @@ struct AIConfigWindow : public Window { /** Open the AI config window. */ void ShowAIConfigWindow() { - CloseWindowByClass(WC_GAME_OPTIONS); + CloseWindowByClass(WindowClass::GameOptions); new AIConfigWindow(); } diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 3458bf0bae..22d6187b14 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -427,10 +427,10 @@ static void CheckIfAircraftNeedsService(Aircraft *v) /* only goto depot if the target airport has a depot */ if (st->airport.HasHangar() && CanVehicleUseStation(v, st)) { v->current_order.MakeGoToDepot(st->index, OrderDepotTypeFlag::Service); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } else if (v->current_order.IsType(OT_GOTO_DEPOT)) { v->current_order.MakeDummy(); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } } @@ -470,8 +470,8 @@ void Aircraft::OnNewEconomyDay() SubtractMoneyFromCompanyFract(this->owner, cost); - SetWindowDirty(WC_VEHICLE_DETAILS, this->index); - SetWindowClassesDirty(WC_AIRCRAFT_LIST); + SetWindowDirty(WindowClass::VehicleDetails, this->index); + SetWindowClassesDirty(WindowClass::AircraftList); } static void HelicopterTickHandler(Aircraft *v) @@ -683,7 +683,7 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE, /* updates statusbar only if speed have changed to save CPU time */ if (spd != v->cur_speed) { v->cur_speed = spd; - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } /* Adjust distance moved by plane speed setting */ @@ -1497,8 +1497,8 @@ void AircraftLeaveHangar(Aircraft *v, Direction exit_dir) VehicleServiceInDepot(v); v->LeaveUnbunchingDepot(); SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos); - InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); - SetWindowClassesDirty(WC_AIRCRAFT_LIST); + InvalidateWindowData(WindowClass::VehicleDepot, v->tile); + SetWindowClassesDirty(WindowClass::AircraftList); } //////////////////////////////////////////////////////////////////////////////// @@ -1583,7 +1583,7 @@ static void AircraftEventHandler_AtTerminal(Aircraft *v, const AirportFTAClass * v->date_of_last_service_newgrf = TimerGameCalendar::date; v->breakdowns_since_last_service = 0; v->reliability = v->GetEngine()->reliability; - SetWindowDirty(WC_VEHICLE_DETAILS, v->index); + SetWindowDirty(WindowClass::VehicleDetails, v->index); } } return; @@ -2077,7 +2077,7 @@ static void AircraftHandleDestTooFar(Aircraft *v, bool too_far) if (too_far) { if (!v->flags.Test(VehicleAirFlag::DestinationTooFar)) { v->flags.Set(VehicleAirFlag::DestinationTooFar); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); AI::NewEvent(v->owner, new ScriptEventAircraftDestTooFar(v->index)); if (v->owner == _local_company) { /* Post a news message. */ @@ -2090,7 +2090,7 @@ static void AircraftHandleDestTooFar(Aircraft *v, bool too_far) if (v->flags.Test(VehicleAirFlag::DestinationTooFar)) { /* Not too far anymore, clear flag and message. */ v->flags.Reset(VehicleAirFlag::DestinationTooFar); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); DeleteVehicleNews(v->index, AdviceType::AircraftDestinationTooFar); } } @@ -2196,7 +2196,7 @@ void UpdateAirplanesOnNewStation(const Station *st) if (o->IsType(OT_GOTO_DEPOT) && !o->GetDepotOrderType().Test(OrderDepotTypeFlag::PartOfOrders) && o->GetDestination() == st->index && (!st->airport.HasHangar() || !CanVehicleUseStation(v, st))) { o->MakeDummy(); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } v->pos = v->previous_pos = AircraftGetEntryPoint(v, ap, rotation); UpdateAircraftCache(v); diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index d7e73addac..1240f4fbd0 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -96,7 +96,7 @@ struct BuildAirToolbarWindow : Window { void Close([[maybe_unused]] int data = 0) override { if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true); - if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false); + if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WindowClass::ScenarioGenerateLandscape, 0, false); this->Window::Close(); } @@ -112,7 +112,7 @@ struct BuildAirToolbarWindow : Window { bool can_build = CanBuildVehicleInfrastructure(VehicleType::Aircraft); this->SetWidgetDisabledState(WID_AT_AIRPORT, !can_build); if (!can_build) { - CloseWindowById(WC_BUILD_STATION, TRANSPORT_AIR); + CloseWindowById(WindowClass::BuildStation, TRANSPORT_AIR); /* Show in the tooltip why this button is disabled. */ this->GetWidget(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE); @@ -179,8 +179,8 @@ struct BuildAirToolbarWindow : Window { this->RaiseButtons(); - CloseWindowById(WC_BUILD_STATION, TRANSPORT_AIR); - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::BuildStation, TRANSPORT_AIR); + CloseWindowById(WindowClass::JoinStation, 0); } /** @@ -218,7 +218,7 @@ static constexpr std::initializer_list _nested_air_toolbar_widgets /** Window definition for the air toolbar. */ static WindowDesc _air_toolbar_desc( WindowPosition::Manual, "toolbar_air", 0, 0, - WC_BUILD_TOOLBAR, WC_NONE, + WindowClass::BuildToolbar, WindowClass::None, WindowDefaultFlag::Construction, _nested_air_toolbar_widgets, &BuildAirToolbarWindow::hotkeys @@ -235,7 +235,7 @@ Window *ShowBuildAirToolbar() { if (!Company::IsValidID(_local_company)) return nullptr; - CloseWindowByClass(WC_BUILD_TOOLBAR); + CloseWindowByClass(WindowClass::BuildToolbar); return AllocateWindowDescFront(_air_toolbar_desc, TRANSPORT_AIR); } @@ -299,7 +299,7 @@ public: void Close([[maybe_unused]] int data = 0) override { - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); this->PickerWindowBase::Close(); } @@ -629,7 +629,7 @@ static constexpr std::initializer_list _nested_build_airport_widget /** Window definition for the airport build window. */ static WindowDesc _build_airport_desc( WindowPosition::Automatic, {}, 0, 0, - WC_BUILD_STATION, WC_BUILD_TOOLBAR, + WindowClass::BuildStation, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_build_airport_widgets ); diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index eb9980b560..029921226c 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -853,7 +853,7 @@ CommandCost CmdSetAutoReplace(DoCommandFlags flags, GroupID id_g, EngineID old_e if (flags.Test(DoCommandFlag::Execute)) { GroupStatistics::UpdateAutoreplace(_current_company); - if (IsLocalCompany()) SetWindowDirty(WC_REPLACE_VEHICLE, Engine::Get(old_engine_type)->type); + if (IsLocalCompany()) SetWindowDirty(WindowClass::ReplaceVehicle, Engine::Get(old_engine_type)->type); const VehicleType vt = Engine::Get(old_engine_type)->type; SetWindowDirty(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, _current_company).ToWindowNumber()); diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 9d82c38a90..34a8141706 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -58,7 +58,7 @@ void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g) /* We don't have any of this engine type. * Either we just sold the last one, we build a new one or we stopped replacing it. * In all cases, we need to update the left list */ - InvalidateWindowData(WC_REPLACE_VEHICLE, Engine::Get(e)->type, 1); + InvalidateWindowData(WindowClass::ReplaceVehicle, Engine::Get(e)->type, 1); } } @@ -68,8 +68,8 @@ void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g) */ void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type) { - InvalidateWindowData(WC_REPLACE_VEHICLE, type, 0); // Update the autoreplace window - InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well + InvalidateWindowData(WindowClass::ReplaceVehicle, type, 0); // Update the autoreplace window + InvalidateWindowClassesData(WindowClass::BuildVehicle); // The build windows needs updating as well } static const StringID _start_replace_dropdown[] = { @@ -599,8 +599,8 @@ public: Engine *engine = Engine::Get(item.variant_id); engine->display_flags.Flip(EngineDisplayFlag::IsFolded); - InvalidateWindowData(WC_REPLACE_VEHICLE, this->window_number, 0); // Update the autoreplace window - InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well + InvalidateWindowData(WindowClass::ReplaceVehicle, this->window_number, 0); // Update the autoreplace window + InvalidateWindowClassesData(WindowClass::BuildVehicle); // The build windows needs updating as well return; } if (!item.flags.Test(EngineDisplayFlag::Shaded)) e = item.engine_id; @@ -763,7 +763,7 @@ static constexpr std::initializer_list _nested_replace_rail_vehicle /** Window definition for the replace rail vehicle window. */ static WindowDesc _replace_rail_vehicle_desc( WindowPosition::Automatic, "replace_vehicle_train", 500, 140, - WC_REPLACE_VEHICLE, WC_NONE, + WindowClass::ReplaceVehicle, WindowClass::None, WindowDefaultFlag::Construction, _nested_replace_rail_vehicle_widgets ); @@ -822,7 +822,7 @@ static constexpr std::initializer_list _nested_replace_road_vehicle /** Window definition for the replace road vehicle window. */ static WindowDesc _replace_road_vehicle_desc( WindowPosition::Automatic, "replace_vehicle_road", 500, 140, - WC_REPLACE_VEHICLE, WC_NONE, + WindowClass::ReplaceVehicle, WindowClass::None, WindowDefaultFlag::Construction, _nested_replace_road_vehicle_widgets ); @@ -877,7 +877,7 @@ static constexpr std::initializer_list _nested_replace_vehicle_widg /** Window definition for the replace ship/aircraft window. */ static WindowDesc _replace_vehicle_desc( WindowPosition::Automatic, "replace_vehicle", 456, 118, - WC_REPLACE_VEHICLE, WC_NONE, + WindowClass::ReplaceVehicle, WindowClass::None, WindowDefaultFlag::Construction, _nested_replace_vehicle_widgets ); @@ -889,7 +889,7 @@ static WindowDesc _replace_vehicle_desc( */ void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype) { - CloseWindowById(WC_REPLACE_VEHICLE, vehicletype); + CloseWindowById(WindowClass::ReplaceVehicle, vehicletype); switch (vehicletype) { case VehicleType::Train: new ReplaceVehicleWindow(_replace_rail_vehicle_desc, vehicletype, id_g); break; case VehicleType::Road: new ReplaceVehicleWindow(_replace_road_vehicle_desc, vehicletype, id_g); break; diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index 7cbee0c167..b83ecfdc07 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -43,7 +43,7 @@ static constexpr std::initializer_list _background_widgets = { */ static WindowDesc _background_desc( WindowPosition::Manual, {}, 0, 0, - WC_BOOTSTRAP, WC_NONE, + WindowClass::Bootstrap, WindowClass::None, WindowDefaultFlag::NoClose, _background_widgets ); @@ -79,7 +79,7 @@ static constexpr std::initializer_list _nested_bootstrap_errmsg_wid /** Window description for the error window. */ static WindowDesc _bootstrap_errmsg_desc( WindowPosition::Center, {}, 0, 0, - WC_BOOTSTRAP, WC_NONE, + WindowClass::Bootstrap, WindowClass::None, {WindowDefaultFlag::Modal, WindowDefaultFlag::NoClose}, _nested_bootstrap_errmsg_widgets ); @@ -136,7 +136,7 @@ static constexpr std::initializer_list _nested_bootstrap_download_s /** Window description for the download window */ static WindowDesc _bootstrap_download_status_window_desc( WindowPosition::Center, {}, 0, 0, - WC_NETWORK_STATUS_WINDOW, WC_NONE, + WindowClass::NetworkStatus, WindowClass::None, {WindowDefaultFlag::Modal, WindowDefaultFlag::NoClose}, _nested_bootstrap_download_status_window_widgets ); @@ -188,7 +188,7 @@ static constexpr std::initializer_list _bootstrap_query_widgets = { /** The window description for the query. */ static WindowDesc _bootstrap_query_desc( WindowPosition::Center, {}, 0, 0, - WC_CONFIRM_POPUP_QUERY, WC_NONE, + WindowClass::ConfirmPopupQuery, WindowClass::None, WindowDefaultFlag::NoClose, _bootstrap_query_widgets ); diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 36fee9a9c9..5c7df10c54 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -178,7 +178,7 @@ public: this->GetWidget(WID_BBS_CAPTION)->SetString((transport_type == TRANSPORT_ROAD) ? STR_SELECT_ROAD_BRIDGE_CAPTION : STR_SELECT_RAIL_BRIDGE_CAPTION); this->FinishInitNested(transport_type); // Initializes 'this->icon_width'. - this->parent = FindWindowById(WC_BUILD_TOOLBAR, transport_type); + this->parent = FindWindowById(WindowClass::BuildToolbar, transport_type); this->bridges.SetListing(BuildBridgeWindow::last_sorting); this->bridges.SetSortFuncs(BuildBridgeWindow::sorter_funcs); this->bridges.NeedResort(); @@ -351,7 +351,7 @@ static constexpr std::initializer_list _nested_build_bridge_widgets /** Window definition for the rail bridge selection window. */ static WindowDesc _build_bridge_desc( WindowPosition::Automatic, "build_bridge", 200, 114, - WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR, + WindowClass::BuildBridge, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_build_bridge_widgets ); @@ -369,7 +369,7 @@ static WindowDesc _build_bridge_desc( */ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, RailType railtype, RoadType roadtype) { - CloseWindowByClass(WC_BUILD_BRIDGE); + CloseWindowByClass(WindowClass::BuildBridge); /* The bridge length without ramps. */ const uint bridge_len = GetTunnelBridgeLength(start, end); diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 7f04d80377..836ffa6877 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1713,8 +1713,8 @@ struct BuildVehicleWindow : Window { } if (refresh) { - InvalidateWindowData(WC_REPLACE_VEHICLE, this->vehicle_type, 0); // Update the autoreplace window - InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well + InvalidateWindowData(WindowClass::ReplaceVehicle, this->vehicle_type, 0); // Update the autoreplace window + InvalidateWindowClassesData(WindowClass::BuildVehicle); // The build windows needs updating as well } } @@ -1748,8 +1748,8 @@ struct BuildVehicleWindow : Window { Engine *engine = Engine::Get(item.variant_id); engine->display_flags.Flip(EngineDisplayFlag::IsFolded); - InvalidateWindowData(WC_REPLACE_VEHICLE, this->vehicle_type, 0); // Update the autoreplace window - InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well + InvalidateWindowData(WindowClass::ReplaceVehicle, this->vehicle_type, 0); // Update the autoreplace window + InvalidateWindowClassesData(WindowClass::BuildVehicle); // The build windows needs updating as well return; } if (!item.flags.Test(EngineDisplayFlag::Shaded)) e = item.engine_id; @@ -1999,7 +1999,7 @@ struct BuildVehicleWindow : Window { if (reopen) { ReplaceDropDownList(this, this->BuildBadgeConfigurationList(), -1); } else { - this->CloseChildWindows(WC_DROPDOWN_MENU); + this->CloseChildWindows(WindowClass::DropdownMenu); } /* We need to refresh if a filter is removed. */ @@ -2042,7 +2042,7 @@ struct BuildVehicleWindow : Window { /** Window definition for the build vehicle window. */ static WindowDesc _build_vehicle_desc( WindowPosition::Automatic, "build_vehicle", 240, 268, - WC_BUILD_VEHICLE, WC_NONE, + WindowClass::BuildVehicle, WindowClass::None, WindowDefaultFlag::Construction, _nested_build_vehicle_widgets, &BuildVehicleWindow::hotkeys @@ -2058,7 +2058,7 @@ void ShowBuildVehicleWindow(TileIndex tile, VehicleType type) assert(IsCompanyBuildableVehicleType(type)); - CloseWindowById(WC_BUILD_VEHICLE, num); + CloseWindowById(WindowClass::BuildVehicle, num); new BuildVehicleWindow(_build_vehicle_desc, tile, type); } diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index f5f731f1e9..ef36505e84 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -92,7 +92,7 @@ static int32_t ClickChangeCompanyCheat(int32_t new_value, int32_t change_directi static int32_t ClickSetProdCheat(int32_t new_value, int32_t) { _cheats.setup_prod.value = (new_value != 0); - InvalidateWindowClassesData(WC_INDUSTRY_VIEW); + InvalidateWindowClassesData(WindowClass::IndustryView); return _cheats.setup_prod.value; } @@ -128,12 +128,12 @@ static int32_t ClickChangeDateCheat(int32_t new_value, int32_t) } CalendarEnginesMonthlyLoop(); - SetWindowDirty(WC_STATUS_BAR, 0); - InvalidateWindowClassesData(WC_BUILD_STATION, 0); - InvalidateWindowClassesData(WC_BUS_STATION, 0); - InvalidateWindowClassesData(WC_TRUCK_STATION, 0); - InvalidateWindowClassesData(WC_BUILD_OBJECT, 0); - InvalidateWindowClassesData(WC_FINANCES, 0); + SetWindowDirty(WindowClass::Statusbar, 0); + InvalidateWindowClassesData(WindowClass::BuildStation, 0); + InvalidateWindowClassesData(WindowClass::BuildBusStation, 0); + InvalidateWindowClassesData(WindowClass::BuildTruckStation, 0); + InvalidateWindowClassesData(WindowClass::BuildObject, 0); + InvalidateWindowClassesData(WindowClass::Finances, 0); ResetSignalVariant(); return TimerGameCalendar::year.base(); } @@ -163,7 +163,7 @@ static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t) ReloadNewGRFData(); /* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */ - InvalidateWindowClassesData(WC_SMALLMAP, 2); + InvalidateWindowClassesData(WindowClass::SmallMap, 2); return _settings_game.construction.map_height_limit; } @@ -642,7 +642,7 @@ struct CheatWindow : Window { /** Window description of the cheats GUI. */ static WindowDesc _cheats_desc( WindowPosition::Automatic, "cheats", 0, 0, - WC_CHEATS, WC_NONE, + WindowClass::Cheat, WindowClass::None, {}, _nested_cheat_widgets ); @@ -650,6 +650,6 @@ static WindowDesc _cheats_desc( /** Open cheat window. */ void ShowCheatWindow() { - CloseWindowById(WC_CHEATS, 0); + CloseWindowById(WindowClass::Cheat, 0); new CheatWindow(_cheats_desc); } diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index bbb63ed14a..2b1862c38e 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -76,7 +76,7 @@ Company::Company(CompanyID index, StringID name_1, bool is_ai) : CompanyPool::Po this->tree_limit = (uint32_t)_settings_game.construction.tree_frame_burst << 16; this->build_object_limit = (uint32_t)_settings_game.construction.build_object_frame_burst << 16; - InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, CompanyID::Invalid()); + InvalidateWindowData(WindowClass::PerformanceDetail, 0, CompanyID::Invalid()); } /** Close the associated company windows. */ @@ -93,12 +93,12 @@ Company::~Company() */ void Company::PostDestructor(size_t index) { - InvalidateWindowData(WC_GRAPH_LEGEND, 0, (int)index); - InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, (int)index); - InvalidateWindowData(WC_COMPANY_LEAGUE, 0, 0); - InvalidateWindowData(WC_LINKGRAPH_LEGEND, 0); + InvalidateWindowData(WindowClass::GraphLegend, 0, static_cast(index)); + InvalidateWindowData(WindowClass::PerformanceDetail, 0, static_cast(index)); + InvalidateWindowData(WindowClass::CompanyLeague, 0, 0); + InvalidateWindowData(WindowClass::LinkGraphLegend, 0); /* If the currently shown error message has this company in it, then close it. */ - InvalidateWindowData(WC_ERRMSG, 0); + InvalidateWindowData(WindowClass::ErrorMessage, 0); } /** @@ -126,15 +126,15 @@ void SetLocalCompany(CompanyID new_company) bool switching_company = _local_company != new_company; /* Delete the chat window, if you were team chatting. */ - if (switching_company) InvalidateWindowData(WC_SEND_NETWORK_MSG, NetworkChatDestinationType::Team, _local_company); + if (switching_company) InvalidateWindowData(WindowClass::NetworkChat, NetworkChatDestinationType::Team, _local_company); assert(IsLocalCompany()); _current_company = _local_company = new_company; if (switching_company) { - InvalidateWindowClassesData(WC_COMPANY); - InvalidateWindowClassesData(WC_VEHICLE_VIEW); + InvalidateWindowClassesData(WindowClass::Company); + InvalidateWindowClassesData(WindowClass::VehicleView); /* Delete any construction windows... */ CloseConstructionWindows(); /* Update the default rail based on most used */ @@ -143,9 +143,9 @@ void SetLocalCompany(CompanyID new_company) /* ... and redraw the whole screen. */ MarkWholeScreenDirty(); - InvalidateWindowClassesData(WC_SIGN_LIST, -1); - InvalidateWindowClassesData(WC_GOALS_LIST); - InvalidateWindowClassesData(WC_COMPANY_COLOUR, -1); + InvalidateWindowClassesData(WindowClass::SignList, -1); + InvalidateWindowClassesData(WindowClass::GoalList); + InvalidateWindowClassesData(WindowClass::CompanyLivery, -1); ResetVehicleColourMap(); } @@ -218,8 +218,8 @@ void InvalidateCompanyWindows(const Company *company) */ static const IntervalTimer invalidate_company_windows_interval(std::chrono::milliseconds(1), [](auto) { for (CompanyID cid : _dirty_company_finances) { - if (cid == _local_company) SetWindowWidgetDirty(WC_STATUS_BAR, 0, WID_S_RIGHT); - Window *w = FindWindowById(WC_FINANCES, cid); + if (cid == _local_company) SetWindowWidgetDirty(WindowClass::Statusbar, 0, WID_S_RIGHT); + Window *w = FindWindowById(WindowClass::Finances, cid); if (w != nullptr) { w->SetWidgetDirty(WID_CF_EXPS_PRICE3); w->SetWidgetDirty(WID_CF_OWN_VALUE); @@ -227,7 +227,7 @@ static const IntervalTimer invalidate_company_windows_interval(std: w->SetWidgetDirty(WID_CF_BALANCE_VALUE); w->SetWidgetDirty(WID_CF_MAXLOAN_VALUE); } - SetWindowWidgetDirty(WC_COMPANY, cid, WID_C_DESC_COMPANY_VALUE); + SetWindowWidgetDirty(WindowClass::Company, cid, WID_C_DESC_COMPANY_VALUE); } _dirty_company_finances.Reset(); }); @@ -633,11 +633,11 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = CompanyID::Invalid( GeneratePresidentName(c); - SetWindowDirty(WC_GRAPH_LEGEND, 0); - InvalidateWindowData(WC_CLIENT_LIST, 0); - InvalidateWindowData(WC_LINKGRAPH_LEGEND, 0); + SetWindowDirty(WindowClass::GraphLegend, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); + InvalidateWindowData(WindowClass::LinkGraphLegend, 0); BuildOwnerLegend(); - InvalidateWindowData(WC_SMALLMAP, 0, 1); + InvalidateWindowData(WindowClass::SmallMap, 0, 1); if (is_ai && (!_networking || _network_server)) AI::StartNew(c->index); @@ -808,7 +808,7 @@ static const IntervalTimer _economy_companies_yearly({TimerGam /* Move expenses to previous years. */ std::rotate(std::rbegin(c->yearly_expenses), std::rbegin(c->yearly_expenses) + 1, std::rend(c->yearly_expenses)); c->yearly_expenses[0].fill(0); - InvalidateWindowData(WC_FINANCES, c->index); + InvalidateWindowData(WindowClass::Finances, c->index); } if (_settings_client.gui.show_finances && _local_company != COMPANY_SPECTATOR) { @@ -875,7 +875,7 @@ void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason) */ CommandCost CmdCompanyCtrl(DoCommandFlags flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id) { - InvalidateWindowData(WC_COMPANY_LEAGUE, 0, 0); + InvalidateWindowData(WindowClass::CompanyLeague, 0, 0); switch (cca) { case CompanyCtrlAction::New: { // Create a new company @@ -888,7 +888,7 @@ CommandCost CmdCompanyCtrl(DoCommandFlags flags, CompanyCtrlAction cca, CompanyI NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id); /* Delete multiplayer progress bar */ - CloseWindowById(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::Join); + CloseWindowById(WindowClass::NetworkStatus, NetworkStatusWindowNumber::Join); Company *c = DoStartupNewCompany(false); @@ -978,8 +978,8 @@ CommandCost CmdCompanyCtrl(DoCommandFlags flags, CompanyCtrlAction cca, CompanyI Game::NewEvent(new ScriptEventCompanyBankrupt(c_index)); CompanyAdminRemove(c_index, (CompanyRemoveReason)reason); - if (StoryPage::GetNumItems() == 0 || Goal::GetNumItems() == 0) InvalidateWindowData(WC_MAIN_TOOLBAR, 0); - InvalidateWindowData(WC_CLIENT_LIST, 0); + if (StoryPage::GetNumItems() == 0 || Goal::GetNumItems() == 0) InvalidateWindowData(WindowClass::MainToolbar, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); break; } @@ -987,9 +987,9 @@ CommandCost CmdCompanyCtrl(DoCommandFlags flags, CompanyCtrlAction cca, CompanyI default: return CMD_ERROR; } - InvalidateWindowClassesData(WC_GAME_OPTIONS); - InvalidateWindowClassesData(WC_SCRIPT_SETTINGS); - InvalidateWindowClassesData(WC_SCRIPT_LIST); + InvalidateWindowClassesData(WindowClass::GameOptions); + InvalidateWindowClassesData(WindowClass::ScriptSettings); + InvalidateWindowClassesData(WindowClass::ScriptList); return CommandCost(); } @@ -1048,8 +1048,8 @@ CommandCost CmdCompanyAllowListCtrl(DoCommandFlags flags, CompanyAllowListCtrlAc if (flags.Test(DoCommandFlag::Execute)) { if (ExecuteAllowListCtrlAction(action, c, public_key)) { - InvalidateWindowData(WC_CLIENT_LIST, 0); - SetWindowDirty(WC_COMPANY, _current_company); + InvalidateWindowData(WindowClass::NetworkClientList, 0); + SetWindowDirty(WindowClass::Company, _current_company); } } @@ -1159,15 +1159,15 @@ CommandCost CmdSetCompanyColour(DoCommandFlags flags, LiveryScheme scheme, bool MarkWholeScreenDirty(); /* All graph related to companies use the company colour. */ - InvalidateWindowData(WC_INCOME_GRAPH, 0); - InvalidateWindowData(WC_OPERATING_PROFIT, 0); - InvalidateWindowData(WC_DELIVERED_CARGO, 0); - InvalidateWindowData(WC_PERFORMANCE_HISTORY, 0); - InvalidateWindowData(WC_COMPANY_VALUE, 0); - InvalidateWindowData(WC_LINKGRAPH_LEGEND, 0); + InvalidateWindowData(WindowClass::IncomeGraph, 0); + InvalidateWindowData(WindowClass::OperatingProfitGraph, 0); + InvalidateWindowData(WindowClass::DeliveredCargoGraph, 0); + InvalidateWindowData(WindowClass::PerformanceGraph, 0); + InvalidateWindowData(WindowClass::CompanyValueGraph, 0); + InvalidateWindowData(WindowClass::LinkGraphLegend, 0); /* The smallmap owner view also stores the company colours. */ BuildOwnerLegend(); - InvalidateWindowData(WC_SMALLMAP, 0, 1); + InvalidateWindowData(WindowClass::SmallMap, 0, 1); /* Company colour data is indirectly cached. */ for (Vehicle *v : Vehicle::Iterate()) { @@ -1216,7 +1216,7 @@ CommandCost CmdRenameCompany(DoCommandFlags flags, const std::string &text) c->name = text; } - InvalidateWindowClassesData(WC_COMPANY, WID_C_COMPANY_NAME); + InvalidateWindowClassesData(WindowClass::Company, WID_C_COMPANY_NAME); MarkWholeScreenDirty(); CompanyAdminUpdate(c); @@ -1270,7 +1270,7 @@ CommandCost CmdRenamePresident(DoCommandFlags flags, const std::string &text) } } - InvalidateWindowClassesData(WC_COMPANY, WID_C_PRESIDENT_NAME); + InvalidateWindowClassesData(WindowClass::Company, WID_C_PRESIDENT_NAME); MarkWholeScreenDirty(); CompanyAdminUpdate(c); diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 2c36818629..073cc72e38 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -567,7 +567,7 @@ Money CompanyFinancesWindow::max_money = INT32_MAX; /** Window definition for the company finances window. */ static WindowDesc _company_finances_desc( WindowPosition::Automatic, "company_finances", 0, 0, - WC_FINANCES, WC_NONE, + WindowClass::Finances, WindowClass::None, {}, _nested_company_finances_widgets ); @@ -580,7 +580,7 @@ static WindowDesc _company_finances_desc( void ShowCompanyFinances(CompanyID company) { if (!Company::IsValidID(company)) return; - if (BringWindowToFrontById(WC_FINANCES, company)) return; + if (BringWindowToFrontById(WindowClass::Finances, company)) return; new CompanyFinancesWindow(_company_finances_desc, company); } @@ -1108,14 +1108,14 @@ static constexpr std::initializer_list _nested_select_company_liver /** Window definition for the company livery configuration window. */ static WindowDesc _select_company_livery_desc( WindowPosition::Automatic, "company_colour_scheme", 0, 0, - WC_COMPANY_COLOUR, WC_NONE, + WindowClass::CompanyLivery, WindowClass::None, {}, _nested_select_company_livery_widgets ); void ShowCompanyLiveryWindow(CompanyID company, GroupID group) { - SelectCompanyLiveryWindow *w = (SelectCompanyLiveryWindow *)BringWindowToFrontById(WC_COMPANY_COLOUR, company); + SelectCompanyLiveryWindow *w = (SelectCompanyLiveryWindow *)BringWindowToFrontById(WindowClass::CompanyLivery, company); if (w == nullptr) { new SelectCompanyLiveryWindow(_select_company_livery_desc, company, group); } else if (group != GroupID::Invalid()) { @@ -1530,7 +1530,7 @@ public: /** Company manager face selection window description */ static WindowDesc _select_company_manager_face_desc( WindowPosition::Automatic, {}, 0, 0, - WC_COMPANY_MANAGER_FACE, WC_NONE, + WindowClass::CompanyManagerFace, WindowClass::None, WindowDefaultFlag::Construction, _nested_select_company_manager_face_widgets ); @@ -1544,7 +1544,7 @@ static void DoSelectCompanyManagerFace(Window *parent) { if (!Company::IsValidID(parent->window_number)) return; - if (BringWindowToFrontById(WC_COMPANY_MANAGER_FACE, parent->window_number)) return; + if (BringWindowToFrontById(WindowClass::CompanyManagerFace, parent->window_number)) return; new SelectCompanyManagerFaceWindow(_select_company_manager_face_desc, parent); } @@ -1838,7 +1838,7 @@ struct CompanyInfrastructureWindow : Window /** Window definition for the company infrastructure statistics window. */ static WindowDesc _company_infrastructure_desc( WindowPosition::Automatic, "company_infrastructure", 0, 0, - WC_COMPANY_INFRASTRUCTURE, WC_NONE, + WindowClass::CompanyInfrastructure, WindowClass::None, {}, _nested_company_infrastructure_widgets ); @@ -2318,7 +2318,7 @@ struct CompanyWindow : Window /** Window definition for the company window. */ static WindowDesc _company_desc( WindowPosition::Automatic, "company", 0, 0, - WC_COMPANY, WC_NONE, + WindowClass::Company, WindowClass::None, {}, _nested_company_widgets ); @@ -2340,8 +2340,8 @@ void ShowCompany(CompanyID company) */ void DirtyCompanyInfrastructureWindows(CompanyID company) { - SetWindowDirty(WC_COMPANY, company); - SetWindowDirty(WC_COMPANY_INFRASTRUCTURE, company); + SetWindowDirty(WindowClass::Company, company); + SetWindowDirty(WindowClass::CompanyInfrastructure, company); } struct BuyCompanyWindow : Window { @@ -2450,7 +2450,7 @@ static constexpr std::initializer_list _nested_buy_company_widgets /** Window definition for the window to buy a company. */ static WindowDesc _buy_company_desc( WindowPosition::Automatic, {}, 0, 0, - WC_BUY_COMPANY, WC_NONE, + WindowClass::BuyCompany, WindowClass::None, WindowDefaultFlag::Construction, _nested_buy_company_widgets ); @@ -2462,7 +2462,7 @@ static WindowDesc _buy_company_desc( */ void ShowBuyCompanyDialog(CompanyID company, bool hostile_takeover) { - auto window = BringWindowToFrontById(WC_BUY_COMPANY, company); + auto window = BringWindowToFrontById(WindowClass::BuyCompany, company); if (window == nullptr) { new BuyCompanyWindow(_buy_company_desc, company, hostile_takeover); } diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index e062ccf6a5..b26e1d443c 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -667,7 +667,7 @@ static bool ConClearBuffer(std::span argv) } IConsoleClearBuffer(); - SetWindowDirty(WC_CONSOLE, 0); + SetWindowDirty(WindowClass::Console, 0); return true; } diff --git a/src/console_gui.cpp b/src/console_gui.cpp index 54a048a242..fc66e3562e 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -121,7 +121,7 @@ static void IConsoleClearCommand() { _iconsole_cmdline.DeleteAll(); _iconsole_tab_completion.Reset(); - SetWindowDirty(WC_CONSOLE, 0); + SetWindowDirty(WindowClass::Console, 0); } static inline void IConsoleResetHistoryPos() @@ -140,7 +140,7 @@ static constexpr std::initializer_list _nested_console_window_widge /** Window definition for the console window. */ static WindowDesc _console_window_desc( WindowPosition::Manual, {}, 0, 0, - WC_CONSOLE, WC_NONE, + WindowClass::Console, WindowClass::None, {}, _nested_console_window_widgets ); @@ -435,7 +435,7 @@ void IConsoleSwitch() break; case ICONSOLE_OPENED: case ICONSOLE_FULL: - CloseWindowById(WC_CONSOLE, 0); + CloseWindowById(WindowClass::Console, 0); break; } @@ -502,7 +502,7 @@ static void IConsoleHistoryNavigate(int direction) void IConsoleGUIPrint(ExtendedTextColour colour_code, const std::string &str) { _iconsole_buffer.push_front(IConsoleLine(str, colour_code)); - SetWindowDirty(WC_CONSOLE, 0); + SetWindowDirty(WindowClass::Console, 0); } /** diff --git a/src/date_gui.cpp b/src/date_gui.cpp index 42352ecc05..7e7a7c21ed 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -197,7 +197,7 @@ static constexpr std::initializer_list _nested_set_date_widgets = { /** Description of the date setting window. */ static WindowDesc _set_date_desc( WindowPosition::Center, {}, 0, 0, - WC_SET_DATE, WC_NONE, + WindowClass::SetDate, WindowClass::None, {}, _nested_set_date_widgets ); @@ -213,6 +213,6 @@ static WindowDesc _set_date_desc( */ void ShowSetDateWindow(Window *parent, int window_number, TimerGameEconomy::Date initial_date, TimerGameEconomy::Year min_year, TimerGameEconomy::Year max_year, SetDateCallback &&callback) { - CloseWindowByClass(WC_SET_DATE); + CloseWindowByClass(WindowClass::SetDate); new SetDateWindow(_set_date_desc, window_number, parent, initial_date, min_year, max_year, std::move(callback)); } diff --git a/src/depot.cpp b/src/depot.cpp index 3dea62971c..cba5745304 100644 --- a/src/depot.cpp +++ b/src/depot.cpp @@ -41,7 +41,7 @@ Depot::~Depot() RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index); /* Delete the depot-window */ - CloseWindowById(WC_VEHICLE_DEPOT, this->xy); + CloseWindowById(WindowClass::VehicleDepot, this->xy); /* Delete the depot list */ VehicleType vt = GetDepotVehicleType(this->xy); diff --git a/src/depot_cmd.cpp b/src/depot_cmd.cpp index 7d09a2bfca..2eb8c77d8e 100644 --- a/src/depot_cmd.cpp +++ b/src/depot_cmd.cpp @@ -67,8 +67,8 @@ CommandCost CmdRenameDepot(DoCommandFlags flags, DepotID depot_id, const std::st } /* Update the orders and depot */ - SetWindowClassesDirty(WC_VEHICLE_ORDERS); - SetWindowDirty(WC_VEHICLE_DEPOT, d->xy); + SetWindowClassesDirty(WindowClass::VehicleOrders); + SetWindowDirty(WindowClass::VehicleDepot, d->xy); /* Update the depot list */ VehicleType vt = GetDepotVehicleType(d->xy); diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 51560ed030..620e299767 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -89,7 +89,7 @@ static constexpr std::initializer_list _nested_train_depot_widgets /** Window definition for the train depot window. */ static WindowDesc _train_depot_desc( WindowPosition::Automatic, "depot_train", 362, 123, - WC_VEHICLE_DEPOT, WC_NONE, + WindowClass::VehicleDepot, WindowClass::None, {}, _nested_train_depot_widgets ); @@ -97,7 +97,7 @@ static WindowDesc _train_depot_desc( /** Window definition for the road depot window. */ static WindowDesc _road_depot_desc( WindowPosition::Automatic, "depot_roadveh", 316, 97, - WC_VEHICLE_DEPOT, WC_NONE, + WindowClass::VehicleDepot, WindowClass::None, {}, _nested_train_depot_widgets ); @@ -105,7 +105,7 @@ static WindowDesc _road_depot_desc( /** Window definition for the ship depot window. */ static WindowDesc _ship_depot_desc( WindowPosition::Automatic, "depot_ship", 306, 99, - WC_VEHICLE_DEPOT, WC_NONE, + WindowClass::VehicleDepot, WindowClass::None, {}, _nested_train_depot_widgets ); @@ -113,7 +113,7 @@ static WindowDesc _ship_depot_desc( /** Window definition for the aircraft depot window. */ static WindowDesc _aircraft_depot_desc( WindowPosition::Automatic, "depot_aircraft", 332, 99, - WC_VEHICLE_DEPOT, WC_NONE, + WindowClass::VehicleDepot, WindowClass::None, {}, _nested_train_depot_widgets ); @@ -301,7 +301,7 @@ struct DepotWindow : Window { void Close([[maybe_unused]] int data = 0) override { - CloseWindowById(WC_BUILD_VEHICLE, this->window_number); + CloseWindowById(WindowClass::BuildVehicle, this->window_number); CloseWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, this->GetDestinationIndex()).ToWindowNumber(), false); OrderBackup::Reset(TileIndex(this->window_number)); this->Window::Close(); @@ -1182,7 +1182,7 @@ static void DepotSellAllConfirmationCallback(Window *win, bool confirmed) */ void ShowDepotWindow(TileIndex tile, VehicleType type) { - if (BringWindowToFrontById(WC_VEHICLE_DEPOT, tile) != nullptr) return; + if (BringWindowToFrontById(WindowClass::VehicleDepot, tile) != nullptr) return; switch (type) { default: NOT_REACHED(); @@ -1206,7 +1206,7 @@ void DeleteDepotHighlightOfVehicle(const Vehicle *v) */ if (_special_mouse_mode != WSM_DRAGDROP) return; - w = dynamic_cast(FindWindowById(WC_VEHICLE_DEPOT, v->tile)); + w = dynamic_cast(FindWindowById(WindowClass::VehicleDepot, v->tile)); if (w != nullptr) { if (w->sel == v->index) ResetObjectToPlace(); } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 7239347476..0f7c4dc687 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -110,7 +110,7 @@ struct BuildDocksToolbarWindow : Window { void Close([[maybe_unused]] int data = 0) override { if (_game_mode == GM_NORMAL && this->IsWidgetLowered(WID_DT_STATION)) SetViewportCatchmentStation(nullptr, true); - if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false); + if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WindowClass::ScenarioGenerateLandscape, 0, false); this->Window::Close(); } @@ -129,8 +129,8 @@ struct BuildDocksToolbarWindow : Window { WID_DT_STATION, WID_DT_BUOY); if (!can_build) { - CloseWindowById(WC_BUILD_STATION, TRANSPORT_WATER); - CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER); + CloseWindowById(WindowClass::BuildStation, TRANSPORT_WATER); + CloseWindowById(WindowClass::BuildDepot, TRANSPORT_WATER); } if (_game_mode != GM_EDITOR) { @@ -284,10 +284,10 @@ struct BuildDocksToolbarWindow : Window { this->RaiseButtons(); - CloseWindowById(WC_BUILD_STATION, TRANSPORT_WATER); - CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER); - CloseWindowById(WC_SELECT_STATION, 0); - CloseWindowByClass(WC_BUILD_BRIDGE); + CloseWindowById(WindowClass::BuildStation, TRANSPORT_WATER); + CloseWindowById(WindowClass::BuildDepot, TRANSPORT_WATER); + CloseWindowById(WindowClass::JoinStation, 0); + CloseWindowByClass(WindowClass::BuildBridge); } void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile_from) override @@ -359,7 +359,7 @@ static constexpr std::initializer_list _nested_build_docks_toolbar_ /** Window definition for the water/docks toolbar. */ static WindowDesc _build_docks_toolbar_desc( WindowPosition::Manual, "toolbar_water", 0, 0, - WC_BUILD_TOOLBAR, WC_NONE, + WindowClass::BuildToolbar, WindowClass::None, WindowDefaultFlag::Construction, _nested_build_docks_toolbar_widgets, &BuildDocksToolbarWindow::hotkeys @@ -376,7 +376,7 @@ Window *ShowBuildDocksToolbar() { if (!Company::IsValidID(_local_company)) return nullptr; - CloseWindowByClass(WC_BUILD_TOOLBAR); + CloseWindowByClass(WindowClass::BuildToolbar); return AllocateWindowDescFront(_build_docks_toolbar_desc, TRANSPORT_WATER); } @@ -403,7 +403,7 @@ static constexpr std::initializer_list _nested_build_docks_scen_too /** Window definition for the build docks in scenario editor window. */ static WindowDesc _build_docks_scen_toolbar_desc( WindowPosition::Automatic, "toolbar_water_scen", 0, 0, - WC_SCEN_BUILD_TOOLBAR, WC_NONE, + WindowClass::ScenarioBuildToolbar, WindowClass::None, WindowDefaultFlag::Construction, _nested_build_docks_scen_toolbar_widgets ); @@ -428,7 +428,7 @@ public: void Close([[maybe_unused]] int data = 0) override { - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); this->PickerWindowBase::Close(); } @@ -506,7 +506,7 @@ static constexpr std::initializer_list _nested_build_dock_station_w /** Window definition for the dock building window. */ static WindowDesc _build_dock_station_desc( WindowPosition::Automatic, {}, 0, 0, - WC_BUILD_STATION, WC_BUILD_TOOLBAR, + WindowClass::BuildStation, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_build_dock_station_widgets ); @@ -602,7 +602,7 @@ static constexpr std::initializer_list _nested_build_docks_depot_wi /** Window definition for the ship depot window. */ static WindowDesc _build_docks_depot_desc( WindowPosition::Automatic, {}, 0, 0, - WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, + WindowClass::BuildDepot, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_build_docks_depot_widgets ); diff --git a/src/dropdown.cpp b/src/dropdown.cpp index 5ea4838072..8d52a73a4f 100644 --- a/src/dropdown.cpp +++ b/src/dropdown.cpp @@ -116,7 +116,7 @@ static constexpr std::initializer_list _nested_dropdown_menu_widget /** Window description for dropdown menus. */ static WindowDesc _dropdown_desc( WindowPosition::Manual, {}, 0, 0, - WC_DROPDOWN_MENU, WC_NONE, + WindowClass::DropdownMenu, WindowClass::None, {}, _nested_dropdown_menu_widgets ); @@ -535,7 +535,7 @@ struct DropdownWindow : Window { void ReplaceDropDownList(Window *parent, DropDownList &&list, std::optional selected_result) { - DropdownWindow *ddw = dynamic_cast(parent->FindChildWindow(WC_DROPDOWN_MENU)); + DropdownWindow *ddw = dynamic_cast(parent->FindChildWindow(WindowClass::DropdownMenu)); if (ddw != nullptr) ddw->ReplaceList(std::move(list), selected_result); } @@ -569,7 +569,7 @@ Dimension GetDropDownListDimension(const DropDownList &list) */ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, WidgetID button, Rect wi_rect, Colours wi_colour, DropDownOptions options, std::string * const persistent_filter_text) { - CloseWindowByClass(WC_DROPDOWN_MENU); + CloseWindowByClass(WindowClass::DropdownMenu); new DropdownWindow(w, std::move(list), selected, button, wi_rect, wi_colour, options, persistent_filter_text); } diff --git a/src/economy.cpp b/src/economy.cpp index 2e7c5c4474..38dccc1d21 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -310,7 +310,7 @@ int UpdateCompanyRatingAndValue(Company *c, bool update) c->old_economy[0].company_value = CalculateCompanyValue(c); } - SetWindowDirty(WC_PERFORMANCE_DETAIL, 0); + SetWindowDirty(WindowClass::PerformanceDetail, 0); return score; } @@ -681,12 +681,12 @@ static void CompaniesGenStatistics() if (c->block_preview != 0) c->block_preview--; } - SetWindowDirty(WC_INCOME_GRAPH, 0); - SetWindowDirty(WC_OPERATING_PROFIT, 0); - SetWindowDirty(WC_DELIVERED_CARGO, 0); - SetWindowDirty(WC_PERFORMANCE_HISTORY, 0); - SetWindowDirty(WC_COMPANY_VALUE, 0); - SetWindowDirty(WC_COMPANY_LEAGUE, 0); + SetWindowDirty(WindowClass::IncomeGraph, 0); + SetWindowDirty(WindowClass::OperatingProfitGraph, 0); + SetWindowDirty(WindowClass::DeliveredCargoGraph, 0); + SetWindowDirty(WindowClass::PerformanceGraph, 0); + SetWindowDirty(WindowClass::CompanyValueGraph, 0); + SetWindowDirty(WindowClass::CompanyLeague, 0); } /** @@ -791,11 +791,11 @@ void RecomputePrices() cs->current_payment = (cs->initial_payment * (int64_t)_economy.inflation_payment) >> 16; } - SetWindowClassesDirty(WC_BUILD_VEHICLE); - SetWindowClassesDirty(WC_REPLACE_VEHICLE); - SetWindowClassesDirty(WC_VEHICLE_DETAILS); - SetWindowClassesDirty(WC_COMPANY_INFRASTRUCTURE); - InvalidateWindowData(WC_PAYMENT_RATES, 0); + SetWindowClassesDirty(WindowClass::BuildVehicle); + SetWindowClassesDirty(WindowClass::ReplaceVehicle); + SetWindowClassesDirty(WindowClass::VehicleDetails); + SetWindowClassesDirty(WindowClass::CompanyInfrastructure); + InvalidateWindowData(WindowClass::CargoPaymentRatesGraph, 0); } /** Let all companies pay the monthly interest on their loan. */ @@ -1146,7 +1146,7 @@ static void TriggerIndustryProduction(Industry *i) if (cbm.Test(IndustryCallbackMask::ProductionCargoArrival)) { IndustryProductionCallback(i, 0); } else { - SetWindowDirty(WC_INDUSTRY_VIEW, i->index); + SetWindowDirty(WindowClass::IndustryView, i->index); } } else { for (auto ita = std::begin(i->accepted); ita != std::end(i->accepted); ++ita) { @@ -1908,13 +1908,13 @@ static void LoadUnloadVehicle(Vehicle *front) if (dirty_vehicle) { SetWindowDirty(GetWindowClassForVehicleType(front->type), front->owner); - SetWindowDirty(WC_VEHICLE_DETAILS, front->index); + SetWindowDirty(WindowClass::VehicleDetails, front->index); front->MarkDirty(); } if (dirty_station) { st->MarkTilesDirty(true); - SetWindowDirty(WC_STATION_VIEW, st->index); - SetWindowDirty(WC_STATION_LIST, st->owner); + SetWindowDirty(WindowClass::StationView, st->index); + SetWindowDirty(WindowClass::StationList, st->owner); } } @@ -1997,11 +1997,11 @@ static void DoAcquireCompany(Company *c, bool hostile_takeover) if (c->is_ai) AI::Stop(c->index); CloseCompanyWindows(ci); - InvalidateWindowClassesData(WC_TRAINS_LIST, 0); - InvalidateWindowClassesData(WC_SHIPS_LIST, 0); - InvalidateWindowClassesData(WC_ROADVEH_LIST, 0); - InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0); - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowClassesData(WindowClass::TrainList, 0); + InvalidateWindowClassesData(WindowClass::ShipList, 0); + InvalidateWindowClassesData(WindowClass::RoadVehicleList, 0); + InvalidateWindowClassesData(WindowClass::AircraftList, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); delete c; } diff --git a/src/engine.cpp b/src/engine.cpp index 68e24749bf..c0d4204d51 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -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 _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); } } } diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index 395d3beaad..028bebb229 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -276,7 +276,7 @@ struct EnginePreviewWindow : Window { /** Window definition for the engine preview window. */ static WindowDesc _engine_preview_desc( WindowPosition::Center, {}, 0, 0, - WC_ENGINE_PREVIEW, WC_NONE, + WindowClass::EnginePreview, WindowClass::None, WindowDefaultFlag::Construction, _nested_engine_preview_widgets ); @@ -284,7 +284,7 @@ static WindowDesc _engine_preview_desc( void ShowEnginePreviewWindow(EngineID engine) { - EnginePreviewWindow *w = dynamic_cast(FindWindowByClass(WC_ENGINE_PREVIEW)); + EnginePreviewWindow *w = dynamic_cast(FindWindowByClass(WindowClass::EnginePreview)); if (w == nullptr) { new EnginePreviewWindow(_engine_preview_desc, engine); } else { diff --git a/src/error_gui.cpp b/src/error_gui.cpp index ca01131a68..5cdd9ac599 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -46,7 +46,7 @@ static constexpr std::initializer_list _nested_errmsg_widgets = { /** Window definition for the error message window. */ static WindowDesc _errmsg_desc( WindowPosition::Manual, {}, 0, 0, - WC_ERRMSG, WC_NONE, + WindowClass::ErrorMessage, WindowClass::None, {}, _nested_errmsg_widgets ); @@ -67,7 +67,7 @@ static constexpr std::initializer_list _nested_errmsg_face_widgets /** Window definition for the error message with company president face window. */ static WindowDesc _errmsg_face_desc( WindowPosition::Manual, {}, 0, 0, - WC_ERRMSG, WC_NONE, + WindowClass::ErrorMessage, WindowClass::None, {}, _nested_errmsg_face_widgets ); @@ -280,7 +280,7 @@ void ShowFirstError() */ void UnshowCriticalError() { - ErrmsgWindow *w = dynamic_cast(FindWindowById(WC_ERRMSG, 0)); + ErrmsgWindow *w = dynamic_cast(FindWindowById(WindowClass::ErrorMessage, 0)); if (_window_system_initialized && w != nullptr) { if (w->IsCritical()) _error_list.push_front(*w); _window_system_initialized = false; @@ -340,7 +340,7 @@ void ShowErrorMessage(EncodedString &&summary_msg, EncodedString &&detailed_msg, ErrorMessageData data(std::move(summary_msg), std::move(detailed_msg), is_critical, x, y, std::move(extra_msg), company); - ErrmsgWindow *w = dynamic_cast(FindWindowById(WC_ERRMSG, 0)); + ErrmsgWindow *w = dynamic_cast(FindWindowById(WindowClass::ErrorMessage, 0)); if (w != nullptr) { if (w->IsCritical()) { /* A critical error is currently shown. */ @@ -364,7 +364,7 @@ void ShowErrorMessage(EncodedString &&summary_msg, EncodedString &&detailed_msg, */ bool HideActiveErrorMessage() { - ErrmsgWindow *w = dynamic_cast(FindWindowById(WC_ERRMSG, 0)); + ErrmsgWindow *w = dynamic_cast(FindWindowById(WindowClass::ErrorMessage, 0)); if (w == nullptr) return false; w->Close(); return true; diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index e60aa1e3fb..67f495283b 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -460,7 +460,7 @@ public: if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) { Command::Post(PauseMode::SaveLoad, true); } - SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0); + SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WindowClass::MainWindow, 0); this->OnInvalidateData(SLIWD_RESCAN_FILES); @@ -983,7 +983,7 @@ public: /** Load game/scenario */ static WindowDesc _load_dialog_desc( WindowPosition::Center, "load_game", 500, 294, - WC_SAVELOAD, WC_NONE, + WindowClass::SaveLoad, WindowClass::None, {}, _nested_load_dialog_widgets ); @@ -991,7 +991,7 @@ static WindowDesc _load_dialog_desc( /** Load heightmap */ static WindowDesc _load_heightmap_dialog_desc( WindowPosition::Center, "load_heightmap", 257, 320, - WC_SAVELOAD, WC_NONE, + WindowClass::SaveLoad, WindowClass::None, {}, _nested_load_heightmap_dialog_widgets ); @@ -999,7 +999,7 @@ static WindowDesc _load_heightmap_dialog_desc( /** Load town data */ static WindowDesc _load_town_data_dialog_desc( WindowPosition::Center, "load_town_data", 257, 320, - WC_SAVELOAD, WC_NONE, + WindowClass::SaveLoad, WindowClass::None, {}, _nested_load_town_data_dialog_widgets ); @@ -1007,7 +1007,7 @@ static WindowDesc _load_town_data_dialog_desc( /** Save game/scenario */ static WindowDesc _save_dialog_desc( WindowPosition::Center, "save_game", 500, 294, - WC_SAVELOAD, WC_NONE, + WindowClass::SaveLoad, WindowClass::None, {}, _nested_save_dialog_widgets ); @@ -1019,7 +1019,7 @@ static WindowDesc _save_dialog_desc( */ void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop) { - CloseWindowById(WC_SAVELOAD, 0); + CloseWindowById(WindowClass::SaveLoad, 0); if (fop == SaveLoadOperation::Save) { new SaveLoadWindow(_save_dialog_desc, abstract_filetype, fop); diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp index 2c1a20f8a3..d69653959f 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -722,7 +722,7 @@ struct FramerateWindow : Window { /** Window definition for the frame rate window. */ static WindowDesc _framerate_display_desc( WindowPosition::Automatic, "framerate_display", 0, 0, - WC_FRAMERATE_DISPLAY, WC_NONE, + WindowClass::FramerateDisplay, WindowClass::None, {}, _framerate_window_widgets ); @@ -1018,7 +1018,7 @@ struct FrametimeGraphWindow : Window { /** Window definition for the frame rate graph window. */ static WindowDesc _frametime_graph_window_desc( WindowPosition::Automatic, "frametime_graph", 140, 90, - WC_FRAMETIME_GRAPH, WC_NONE, + WindowClass::FrametimeGraph, WindowClass::None, {}, _frametime_graph_window_widgets ); diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp index e9a4384da7..a1cf4ce7c0 100644 --- a/src/game/game_core.cpp +++ b/src/game/game_core.cpp @@ -91,7 +91,7 @@ Game::instance->LoadOnStack(config->GetToLoadData()); config->SetToLoadData(nullptr); - InvalidateWindowClassesData(WC_SCRIPT_DEBUG, -1); + InvalidateWindowClassesData(WindowClass::ScriptDebug, -1); } /* static */ void Game::Uninitialize(bool keepConfig) @@ -176,10 +176,10 @@ Game::scanner_library->RescanDir(); ResetConfig(); - InvalidateWindowData(WC_SCRIPT_LIST, 0, 1); - SetWindowClassesDirty(WC_SCRIPT_DEBUG); - InvalidateWindowClassesData(WC_SCRIPT_SETTINGS); - InvalidateWindowClassesData(WC_GAME_OPTIONS); + InvalidateWindowData(WindowClass::ScriptList, 0, 1); + SetWindowClassesDirty(WindowClass::ScriptDebug); + InvalidateWindowClassesData(WindowClass::ScriptSettings); + InvalidateWindowClassesData(WindowClass::GameOptions); } diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index 6235ec8d5c..43b325a70d 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -78,7 +78,7 @@ static constexpr std::initializer_list _nested_gs_config_widgets = /** Window definition for the configure GS window. */ static WindowDesc _gs_config_desc( WindowPosition::Center, "settings_gs_config", 500, 350, - WC_GAME_OPTIONS, WC_NONE, + WindowClass::GameOptions, WindowClass::None, {}, _nested_gs_config_widgets ); @@ -112,7 +112,7 @@ struct GSConfigWindow : public Window { void Close([[maybe_unused]] int data = 0) override { - CloseWindowByClass(WC_SCRIPT_LIST); + CloseWindowByClass(WindowClass::ScriptList); this->Window::Close(); } @@ -260,8 +260,8 @@ struct GSConfigWindow : public Window { int num = it - this->visible_settings.begin(); if (this->clicked_row != num) { - this->CloseChildWindows(WC_QUERY_STRING); - this->CloseChildWindows(WC_DROPDOWN_MENU); + this->CloseChildWindows(WindowClass::QueryString); + this->CloseChildWindows(WindowClass::DropdownMenu); this->clicked_row = num; this->clicked_dropdown = false; } @@ -277,7 +277,7 @@ struct GSConfigWindow : public Window { if (!bool_item && IsInsideMM(x, 0, SETTING_BUTTON_WIDTH) && config_item.complete_labels) { if (this->clicked_dropdown) { /* unclick the dropdown */ - this->CloseChildWindows(WC_DROPDOWN_MENU); + this->CloseChildWindows(WindowClass::DropdownMenu); this->clicked_dropdown = false; this->closing_dropdown = false; } else { @@ -400,8 +400,8 @@ struct GSConfigWindow : public Window { this->SetWidgetDisabledState(WID_GSC_TEXTFILE + tft, !config->GetTextfile(tft, OWNER_DEITY).has_value()); } this->RebuildVisibleSettings(); - this->CloseChildWindows(WC_DROPDOWN_MENU); - this->CloseChildWindows(WC_QUERY_STRING); + this->CloseChildWindows(WindowClass::DropdownMenu); + this->CloseChildWindows(WindowClass::QueryString); } private: bool IsEditableItem(const ScriptConfigItem &config_item) const @@ -424,6 +424,6 @@ private: /** Open the GS config window. */ void ShowGSConfigWindow() { - CloseWindowByClass(WC_GAME_OPTIONS); + CloseWindowByClass(WindowClass::GameOptions); new GSConfigWindow(); } diff --git a/src/genworld.cpp b/src/genworld.cpp index 90688566f6..43238c5711 100644 --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -87,7 +87,7 @@ static void CleanupGeneration() GenWorldInfo::proc = nullptr; GenWorldInfo::abortp = nullptr; - CloseWindowByClass(WC_MODAL_PROGRESS); + CloseWindowByClass(WindowClass::ModalProgress); ShowFirstError(); MarkWholeScreenDirty(); } @@ -106,7 +106,7 @@ static void _GenerateWorld() /* Set the Random() seed to generation_seed so we produce the same map with the same seed */ _random.SetSeed(_settings_game.game_creation.generation_seed); SetGeneratingWorldProgress(GenWorldProgress::Init, 2); - SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0); + SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WindowClass::MainWindow, 0); ScriptObject::InitializeRandomizers(); BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP); @@ -339,7 +339,7 @@ void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_setti /* Create toolbars */ SetupColoursAndInitialWindow(); - SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0); + SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WindowClass::MainWindow, 0); UnshowCriticalError(); CloseAllNonVitalWindows(); diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 437dddedce..7709b75628 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -70,8 +70,8 @@ static uint GetMapHeightLimit() void SetNewLandscapeType(LandscapeType landscape) { _settings_newgame.game_creation.landscape = landscape; - InvalidateWindowClassesData(WC_SELECT_GAME); - InvalidateWindowClassesData(WC_GENERATE_LANDSCAPE); + InvalidateWindowClassesData(WindowClass::SelectGame); + InvalidateWindowClassesData(WindowClass::GenerateLandscape); } /** Widgets of GenerateLandscapeWindow when generating world */ @@ -897,7 +897,7 @@ struct GenerateLandscapeWindow : public Window { case WID_GL_TOWNNAME_DROPDOWN: // Town names if (_game_mode == GM_MENU || Town::GetNumItems() == 0) { _settings_newgame.game_creation.town_name = index; - SetWindowDirty(WC_GAME_OPTIONS, GameOptionsWindowNumber::GameOptions); + SetWindowDirty(WindowClass::GameOptions, GameOptionsWindowNumber::GameOptions); } break; @@ -1019,7 +1019,7 @@ struct GenerateLandscapeWindow : public Window { /** Window definition for the landscape generation window. */ static WindowDesc _generate_landscape_desc( WindowPosition::Center, {}, 0, 0, - WC_GENERATE_LANDSCAPE, WC_NONE, + WindowClass::GenerateLandscape, WindowClass::None, {}, _nested_generate_landscape_widgets ); @@ -1027,7 +1027,7 @@ static WindowDesc _generate_landscape_desc( /** Window definition for the heightmap configuration window. */ static WindowDesc _heightmap_load_desc( WindowPosition::Center, {}, 0, 0, - WC_GENERATE_LANDSCAPE, WC_NONE, + WindowClass::GenerateLandscape, WindowClass::None, {}, _nested_heightmap_load_widgets ); @@ -1037,7 +1037,7 @@ static void _ShowGenerateLandscape(GenerateLandscapeWindowMode mode) uint x = 0; uint y = 0; - CloseWindowByClass(WC_GENERATE_LANDSCAPE); + CloseWindowByClass(WindowClass::GenerateLandscape); /* Generate a new seed when opening the window */ _settings_newgame.game_creation.generation_seed = InteractiveRandom(); @@ -1056,7 +1056,7 @@ static void _ShowGenerateLandscape(GenerateLandscapeWindowMode mode) w->name = _file_to_saveload.title; } - SetWindowDirty(WC_GENERATE_LANDSCAPE, mode); + SetWindowDirty(WindowClass::GenerateLandscape, mode); } /** Start with a normal game. */ @@ -1328,7 +1328,7 @@ static constexpr std::initializer_list _nested_create_scenario_widg /** Window definition for the create scenario window. */ static WindowDesc _create_scenario_desc( WindowPosition::Center, {}, 0, 0, - WC_GENERATE_LANDSCAPE, WC_NONE, + WindowClass::GenerateLandscape, WindowClass::None, {}, _nested_create_scenario_widgets ); @@ -1336,7 +1336,7 @@ static WindowDesc _create_scenario_desc( /** Show the window to create a scenario. */ void ShowCreateScenario() { - CloseWindowByClass(WC_GENERATE_LANDSCAPE); + CloseWindowByClass(WindowClass::GenerateLandscape); new CreateScenarioWindow(_create_scenario_desc, GLWM_SCENARIO); } @@ -1355,7 +1355,7 @@ static constexpr std::initializer_list _nested_generate_progress_wi /** Window definition for the map generation progress window. */ static WindowDesc _generate_progress_desc( WindowPosition::Center, {}, 0, 0, - WC_MODAL_PROGRESS, WC_NONE, + WindowClass::ModalProgress, WindowClass::None, WindowDefaultFlag::NoClose, _nested_generate_progress_widgets ); @@ -1474,7 +1474,7 @@ void PrepareGenerateWorldProgress() */ void ShowGenerateWorldProgress() { - if (BringWindowToFrontById(WC_MODAL_PROGRESS, 0)) return; + if (BringWindowToFrontById(WindowClass::ModalProgress, 0)) return; new GenerateProgressWindow(); } @@ -1527,7 +1527,7 @@ static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uin return; } - SetWindowDirty(WC_MODAL_PROGRESS, 0); + SetWindowDirty(WindowClass::ModalProgress, 0); VideoDriver::GetInstance()->GameLoopPause(); } diff --git a/src/goal.cpp b/src/goal.cpp index aa9d33e3b6..db07f6c5dc 100644 --- a/src/goal.cpp +++ b/src/goal.cpp @@ -88,11 +88,11 @@ std::tuple CmdCreateGoal(DoCommandFlags flags, CompanyID co Goal *g = Goal::Create(type, dest, company, text); if (g->company == CompanyID::Invalid()) { - InvalidateWindowClassesData(WC_GOALS_LIST); + InvalidateWindowClassesData(WindowClass::GoalList); } else { - InvalidateWindowData(WC_GOALS_LIST, g->company); + InvalidateWindowData(WindowClass::GoalList, g->company); } - if (Goal::GetNumItems() == 1) InvalidateWindowData(WC_MAIN_TOOLBAR, 0); + if (Goal::GetNumItems() == 1) InvalidateWindowData(WindowClass::MainToolbar, 0); return { CommandCost(), g->index }; } @@ -117,11 +117,11 @@ CommandCost CmdRemoveGoal(DoCommandFlags flags, GoalID goal) delete g; if (c == CompanyID::Invalid()) { - InvalidateWindowClassesData(WC_GOALS_LIST); + InvalidateWindowClassesData(WindowClass::GoalList); } else { - InvalidateWindowData(WC_GOALS_LIST, c); + InvalidateWindowData(WindowClass::GoalList, c); } - if (Goal::GetNumItems() == 0) InvalidateWindowData(WC_MAIN_TOOLBAR, 0); + if (Goal::GetNumItems() == 0) InvalidateWindowData(WindowClass::MainToolbar, 0); } return CommandCost(); @@ -168,9 +168,9 @@ CommandCost CmdSetGoalText(DoCommandFlags flags, GoalID goal, const EncodedStrin g->text = text; if (g->company == CompanyID::Invalid()) { - InvalidateWindowClassesData(WC_GOALS_LIST); + InvalidateWindowClassesData(WindowClass::GoalList); } else { - InvalidateWindowData(WC_GOALS_LIST, g->company); + InvalidateWindowData(WindowClass::GoalList, g->company); } } @@ -194,9 +194,9 @@ CommandCost CmdSetGoalProgress(DoCommandFlags flags, GoalID goal, const EncodedS g->progress = text; if (g->company == CompanyID::Invalid()) { - InvalidateWindowClassesData(WC_GOALS_LIST); + InvalidateWindowClassesData(WindowClass::GoalList); } else { - InvalidateWindowData(WC_GOALS_LIST, g->company); + InvalidateWindowData(WindowClass::GoalList, g->company); } } @@ -220,9 +220,9 @@ CommandCost CmdSetGoalCompleted(DoCommandFlags flags, GoalID goal, bool complete g->completed = completed; if (g->company == CompanyID::Invalid()) { - InvalidateWindowClassesData(WC_GOALS_LIST); + InvalidateWindowClassesData(WindowClass::GoalList); } else { - InvalidateWindowData(WC_GOALS_LIST, g->company); + InvalidateWindowData(WindowClass::GoalList, g->company); } } @@ -290,13 +290,13 @@ CommandCost CmdGoalQuestionAnswer(DoCommandFlags flags, uint16_t uniqueid, uint8 if (_current_company == OWNER_DEITY) { /* It has been requested to close this specific question on all clients */ - if (flags.Test(DoCommandFlag::Execute)) CloseWindowById(WC_GOAL_QUESTION, uniqueid); + if (flags.Test(DoCommandFlag::Execute)) CloseWindowById(WindowClass::GoalQuestion, uniqueid); return CommandCost(); } if (_networking && _local_company == _current_company) { /* Somebody in the same company answered the question. Close the window */ - if (flags.Test(DoCommandFlag::Execute)) CloseWindowById(WC_GOAL_QUESTION, uniqueid); + if (flags.Test(DoCommandFlag::Execute)) CloseWindowById(WindowClass::GoalQuestion, uniqueid); if (!_network_server) return CommandCost(); } diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index 5fffb34d1e..b18f73d448 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -299,7 +299,7 @@ static constexpr std::initializer_list _nested_goals_list_widgets = /** Window definition for the goal listing window. */ static WindowDesc _goals_list_desc( WindowPosition::Automatic, "list_goals", 500, 127, - WC_GOALS_LIST, WC_NONE, + WindowClass::GoalList, WindowClass::None, {}, _nested_goals_list_widgets ); @@ -442,25 +442,25 @@ static constexpr auto _nested_goal_question_widgets_error = NestedGoalWidgets static WindowDesc _goal_question_list_desc[] = { { WindowPosition::Center, {}, 0, 0, - WC_GOAL_QUESTION, WC_NONE, + WindowClass::GoalQuestion, WindowClass::None, WindowDefaultFlag::Construction, _nested_goal_question_widgets_question, }, { WindowPosition::Center, {}, 0, 0, - WC_GOAL_QUESTION, WC_NONE, + WindowClass::GoalQuestion, WindowClass::None, WindowDefaultFlag::Construction, _nested_goal_question_widgets_info, }, { WindowPosition::Center, {}, 0, 0, - WC_GOAL_QUESTION, WC_NONE, + WindowClass::GoalQuestion, WindowClass::None, WindowDefaultFlag::Construction, _nested_goal_question_widgets_warning, }, { WindowPosition::Center, {}, 0, 0, - WC_GOAL_QUESTION, WC_NONE, + WindowClass::GoalQuestion, WindowClass::None, WindowDefaultFlag::Construction, _nested_goal_question_widgets_error, }, diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 129d89d646..ecfefb63eb 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -88,11 +88,11 @@ struct GraphLegendWindow : Window { _legend_excluded_companies.Flip(static_cast(widget - WID_GL_FIRST_COMPANY)); this->ToggleWidgetLoweredState(widget); this->SetDirty(); - InvalidateWindowData(WC_INCOME_GRAPH, 0); - InvalidateWindowData(WC_OPERATING_PROFIT, 0); - InvalidateWindowData(WC_DELIVERED_CARGO, 0); - InvalidateWindowData(WC_PERFORMANCE_HISTORY, 0); - InvalidateWindowData(WC_COMPANY_VALUE, 0); + InvalidateWindowData(WindowClass::IncomeGraph, 0); + InvalidateWindowData(WindowClass::OperatingProfitGraph, 0); + InvalidateWindowData(WindowClass::DeliveredCargoGraph, 0); + InvalidateWindowData(WindowClass::PerformanceGraph, 0); + InvalidateWindowData(WindowClass::CompanyValueGraph, 0); SndClickBeep(); } @@ -148,7 +148,7 @@ static constexpr std::initializer_list _nested_graph_legend_widgets /** Window definition for the graph legend window. */ static WindowDesc _graph_legend_desc( WindowPosition::Automatic, "graph_legend", 0, 0, - WC_GRAPH_LEGEND, WC_NONE, + WindowClass::GraphLegend, WindowClass::None, {}, _nested_graph_legend_widgets ); @@ -635,7 +635,7 @@ protected: Window(desc), format_str_y_axis(format_str_y_axis) { - SetWindowDirty(WC_GRAPH_LEGEND, 0); + SetWindowDirty(WindowClass::GraphLegend, 0); } const IntervalTimer blink_interval = {TIMER_BLINK_INTERVAL, [this](auto) { @@ -965,7 +965,7 @@ static constexpr std::initializer_list _nested_operating_profit_wid /** Window definition for the operating profit graph window. */ static WindowDesc _operating_profit_desc( WindowPosition::Automatic, "graph_operating_profit", 0, 0, - WC_OPERATING_PROFIT, WC_NONE, + WindowClass::OperatingProfitGraph, WindowClass::None, {}, _nested_operating_profit_widgets ); @@ -1019,7 +1019,7 @@ static constexpr std::initializer_list _nested_income_graph_widgets /** Window definition for the income graph window. */ static WindowDesc _income_graph_desc( WindowPosition::Automatic, "graph_income", 0, 0, - WC_INCOME_GRAPH, WC_NONE, + WindowClass::IncomeGraph, WindowClass::None, {}, _nested_income_graph_widgets ); @@ -1071,7 +1071,7 @@ static constexpr std::initializer_list _nested_delivered_cargo_grap /** Window definition for the delivered cargo graph window. */ static WindowDesc _delivered_cargo_graph_desc( WindowPosition::Automatic, "graph_delivered_cargo", 0, 0, - WC_DELIVERED_CARGO, WC_NONE, + WindowClass::DeliveredCargoGraph, WindowClass::None, {}, _nested_delivered_cargo_graph_widgets ); @@ -1130,7 +1130,7 @@ static constexpr std::initializer_list _nested_performance_history_ /** Window definition for the performance history graph window. */ static WindowDesc _performance_history_desc( WindowPosition::Automatic, "graph_performance", 0, 0, - WC_PERFORMANCE_HISTORY, WC_NONE, + WindowClass::PerformanceGraph, WindowClass::None, {}, _nested_performance_history_widgets ); @@ -1182,7 +1182,7 @@ static constexpr std::initializer_list _nested_company_value_graph_ /** Window definition for the company value graph window. */ static WindowDesc _company_value_graph_desc( WindowPosition::Automatic, "graph_company_value", 0, 0, - WC_COMPANY_VALUE, WC_NONE, + WindowClass::CompanyValueGraph, WindowClass::None, {}, _nested_company_value_graph_widgets ); @@ -1471,7 +1471,7 @@ static constexpr std::initializer_list _nested_cargo_payment_rates_ /** Window definition for the cargo payment rates graph window. */ static WindowDesc _cargo_payment_rates_desc( WindowPosition::Automatic, "graph_cargo_payment_rates", 0, 0, - WC_PAYMENT_RATES, WC_NONE, + WindowClass::CargoPaymentRatesGraph, WindowClass::None, {}, _nested_cargo_payment_rates_widgets ); @@ -1876,7 +1876,7 @@ static constexpr std::initializer_list _nested_industry_production_ /** Window definition for the industry production graph window. */ static WindowDesc _industry_production_desc( WindowPosition::Automatic, "graph_industry_production", 0, 0, - WC_INDUSTRY_PRODUCTION, WC_INDUSTRY_VIEW, + WindowClass::IndustryProductionGraph, WindowClass::IndustryView, {}, _nested_industry_production_widgets ); @@ -2040,7 +2040,7 @@ static constexpr std::initializer_list _nested_town_cargo_graph_wid /** Window definition for the town cargo graph window. */ static WindowDesc _town_cargo_graph_desc( WindowPosition::Automatic, "graph_town_cargo", 0, 0, - WC_TOWN_CARGO_GRAPH, WC_TOWN_VIEW, + WindowClass::TownCargoGraph, WindowClass::TownView, {}, _nested_town_cargo_graph_widgets ); @@ -2104,7 +2104,7 @@ static constexpr std::initializer_list _nested_performance_rating_d /** Window definition for the performance rating details window. */ static WindowDesc _performance_rating_detail_desc( WindowPosition::Automatic, "league_details", 0, 0, - WC_PERFORMANCE_DETAIL, WC_NONE, + WindowClass::PerformanceDetail, WindowClass::None, {}, _nested_performance_rating_detail_widgets ); diff --git a/src/ground_vehicle.cpp b/src/ground_vehicle.cpp index 1c6f44648c..760aeb85a1 100644 --- a/src/ground_vehicle.cpp +++ b/src/ground_vehicle.cpp @@ -64,8 +64,8 @@ void GroundVehicle::PowerChanged() this->gcache.cached_power = total_power; this->gcache.cached_max_te = max_te; - SetWindowDirty(WC_VEHICLE_DETAILS, this->index); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); + SetWindowDirty(WindowClass::VehicleDetails, this->index); + SetWindowWidgetDirty(WindowClass::VehicleView, this->index, WID_VV_START_STOP); } this->gcache.cached_max_track_speed = max_track_speed; diff --git a/src/ground_vehicle.hpp b/src/ground_vehicle.hpp index 10cee275b0..2ef3f6fb1e 100644 --- a/src/ground_vehicle.hpp +++ b/src/ground_vehicle.hpp @@ -361,7 +361,7 @@ struct GroundVehicle : public SpecializedVehicle { inline void SetLastSpeed() { if (this->cur_speed != this->gcache.last_speed) { - SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, this->index, WID_VV_START_STOP); this->gcache.last_speed = this->cur_speed; } } diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index 9347206f29..9051bbc07c 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -377,7 +377,7 @@ std::tuple CmdCreateGroup(DoCommandFlags flags, VehicleTyp } InvalidateWindowData(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, _current_company).ToWindowNumber()); - InvalidateWindowData(WC_COMPANY_COLOUR, g->owner, g->vehicle_type); + InvalidateWindowData(WindowClass::CompanyLivery, g->owner, g->vehicle_type); return { CommandCost(), g->index }; } @@ -429,11 +429,11 @@ CommandCost CmdDeleteGroup(DoCommandFlags flags, GroupID group_id) VehicleType vt = g->vehicle_type; /* Delete the Replace Vehicle Windows */ - CloseWindowById(WC_REPLACE_VEHICLE, g->vehicle_type); + CloseWindowById(WindowClass::ReplaceVehicle, g->vehicle_type); delete g; InvalidateWindowData(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, _current_company).ToWindowNumber()); - InvalidateWindowData(WC_COMPANY_COLOUR, _current_company, vt); + InvalidateWindowData(WindowClass::CompanyLivery, _current_company, vt); } return CommandCost(); @@ -507,11 +507,11 @@ CommandCost CmdAlterGroup(DoCommandFlags flags, AlterGroupMode mode, GroupID gro } if (flags.Test(DoCommandFlag::Execute)) { - InvalidateWindowData(WC_REPLACE_VEHICLE, g->vehicle_type, 1); + InvalidateWindowData(WindowClass::ReplaceVehicle, g->vehicle_type, 1); InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VL_GROUP_LIST, g->vehicle_type, _current_company).ToWindowNumber()); - InvalidateWindowData(WC_COMPANY_COLOUR, g->owner, g->vehicle_type); - InvalidateWindowClassesData(WC_VEHICLE_VIEW); - InvalidateWindowClassesData(WC_VEHICLE_DETAILS); + InvalidateWindowData(WindowClass::CompanyLivery, g->owner, g->vehicle_type); + InvalidateWindowClassesData(WindowClass::VehicleView); + InvalidateWindowClassesData(WindowClass::VehicleDetails); } return CommandCost(); @@ -546,8 +546,8 @@ static void AddVehicleToGroup(Vehicle *v, GroupID new_g) break; } - InvalidateWindowData(WC_VEHICLE_VIEW, v->index); - InvalidateWindowData(WC_VEHICLE_DETAILS, v->index); + InvalidateWindowData(WindowClass::VehicleView, v->index); + InvalidateWindowData(WindowClass::VehicleDetails, v->index); GroupStatistics::CountVehicle(v, 1); } @@ -606,13 +606,13 @@ std::tuple CmdAddVehicleGroup(DoCommandFlags flags, GroupI } } - SetWindowDirty(WC_VEHICLE_DEPOT, v->tile); + SetWindowDirty(WindowClass::VehicleDepot, v->tile); } GroupStatistics::UpdateAutoreplace(_current_company); /* Update the Replace Vehicle Windows */ - SetWindowDirty(WC_REPLACE_VEHICLE, vtype); + SetWindowDirty(WindowClass::ReplaceVehicle, vtype); InvalidateWindowData(GetWindowClassForVehicleType(vtype), VehicleListIdentifier(VL_GROUP_LIST, vtype, _current_company).ToWindowNumber()); } @@ -756,7 +756,7 @@ CommandCost CmdSetGroupFlag(DoCommandFlags flags, GroupID group_id, GroupFlag fl SetGroupFlag(g, flag, value, recursive); SetWindowDirty(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VL_GROUP_LIST, g->vehicle_type, _current_company).ToWindowNumber()); - InvalidateWindowData(WC_REPLACE_VEHICLE, g->vehicle_type); + InvalidateWindowData(WindowClass::ReplaceVehicle, g->vehicle_type); } return CommandCost(); @@ -785,7 +785,7 @@ void SetTrainGroupID(Train *v, GroupID new_g) /* Update the Replace Vehicle Windows */ GroupStatistics::UpdateAutoreplace(v->owner); - SetWindowDirty(WC_REPLACE_VEHICLE, VehicleType::Train); + SetWindowDirty(WindowClass::ReplaceVehicle, VehicleType::Train); } @@ -811,7 +811,7 @@ void UpdateTrainGroupID(Train *v) /* Update the Replace Vehicle Windows */ GroupStatistics::UpdateAutoreplace(v->owner); - SetWindowDirty(WC_REPLACE_VEHICLE, VehicleType::Train); + SetWindowDirty(WindowClass::ReplaceVehicle, VehicleType::Train); } /** diff --git a/src/group_gui.cpp b/src/group_gui.cpp index bdbb091206..4d3ac084d3 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -543,14 +543,14 @@ public: /* Process ID-invalidation in command-scope as well */ if (this->group_rename != GroupID::Invalid() && !Group::IsValidID(this->group_rename)) { - CloseWindowByClass(WC_QUERY_STRING); + CloseWindowByClass(WindowClass::QueryString); this->group_rename = GroupID::Invalid(); } GroupID group = this->vli.ToGroupID(); if (!(IsAllGroupID(group) || IsDefaultGroupID(group) || Group::IsValidID(group))) { this->vli.SetIndex(ALL_GROUP); - this->CloseChildWindows(WC_DROPDOWN_MENU); + this->CloseChildWindows(WindowClass::DropdownMenu); } this->SetDirty(); } @@ -595,7 +595,7 @@ public: /* The drop down menu is out, *but* it may not be used, retract it. */ if (this->vehicles.empty() && this->IsWidgetLowered(WID_GL_MANAGE_VEHICLES_DROPDOWN)) { this->RaiseWidget(WID_GL_MANAGE_VEHICLES_DROPDOWN); - this->CloseChildWindows(WC_DROPDOWN_MENU); + this->CloseChildWindows(WindowClass::DropdownMenu); } /* Disable all lists management button when the list is empty */ @@ -1194,25 +1194,25 @@ public: static VehicleTypeIndexArray _vehicle_group_desc = {{ WindowDesc{ WindowPosition::Automatic, "list_groups_train", 525, 246, - WC_TRAINS_LIST, WC_NONE, + WindowClass::TrainList, WindowClass::None, {}, _nested_group_widgets }, WindowDesc{ WindowPosition::Automatic, "list_groups_roadveh", 460, 246, - WC_ROADVEH_LIST, WC_NONE, + WindowClass::RoadVehicleList, WindowClass::None, {}, _nested_group_widgets }, WindowDesc{ WindowPosition::Automatic, "list_groups_ship", 460, 246, - WC_SHIPS_LIST, WC_NONE, + WindowClass::ShipList, WindowClass::None, {}, _nested_group_widgets }, WindowDesc{ WindowPosition::Automatic, "list_groups_aircraft", 460, 246, - WC_AIRCRAFT_LIST, WC_NONE, + WindowClass::AircraftList, WindowClass::None, {}, _nested_group_widgets }, diff --git a/src/help_gui.cpp b/src/help_gui.cpp index 63ac29a272..a2cf35ee0e 100644 --- a/src/help_gui.cpp +++ b/src/help_gui.cpp @@ -205,7 +205,7 @@ static constexpr std::initializer_list _nested_helpwin_widgets = { /** Window definition for the help window. */ static WindowDesc _helpwin_desc( WindowPosition::Center, {}, 0, 0, - WC_HELPWIN, WC_NONE, + WindowClass::Help, WindowClass::None, {}, _nested_helpwin_widgets ); diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index b6d31f0adf..48df861f3c 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -228,7 +228,7 @@ static constexpr std::initializer_list _nested_highscore_widgets = /** Window definition for the highscore window. */ static WindowDesc _highscore_desc( WindowPosition::Manual, {}, 0, 0, - WC_HIGHSCORE, WC_NONE, + WindowClass::Highscore, WindowClass::None, {}, _nested_highscore_widgets ); @@ -236,7 +236,7 @@ static WindowDesc _highscore_desc( /** Window definition for the endgame window. */ static WindowDesc _endgame_desc( WindowPosition::Manual, {}, 0, 0, - WC_ENDSCREEN, WC_NONE, + WindowClass::Endscreen, WindowClass::None, {}, _nested_highscore_widgets ); @@ -250,7 +250,7 @@ static WindowDesc _endgame_desc( */ void ShowHighscoreTable(int difficulty, int8_t ranking) { - CloseWindowByClass(WC_HIGHSCORE); + CloseWindowByClass(WindowClass::Highscore); new HighScoreWindow(_highscore_desc, difficulty, ranking); } @@ -264,7 +264,7 @@ void ShowEndGameChart() if (_network_dedicated || (!_networking && !Company::IsValidID(_local_company))) return; HideVitalWindows(); - CloseWindowByClass(WC_ENDSCREEN); + CloseWindowByClass(WindowClass::Endscreen); new EndGameWindow(_endgame_desc); } diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index a7fecac203..3bb2fb2600 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -197,8 +197,8 @@ Industry::~Industry() industries.erase(this->index); DeleteIndustryNews(this->index); - CloseWindowById(WC_INDUSTRY_VIEW, this->index); - CloseWindowById(WC_INDUSTRY_PRODUCTION, this->index); + CloseWindowById(WindowClass::IndustryView, this->index); + CloseWindowById(WindowClass::IndustryProductionGraph, this->index); DeleteNewGRFInspectWindow(GrfSpecFeature::Industries, this->index); Source src{this->index, SourceType::Industry}; @@ -216,8 +216,8 @@ Industry::~Industry() */ void Industry::PostDestructor(size_t) { - InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_FORCE_REBUILD); - SetWindowDirty(WC_BUILD_INDUSTRY, 0); + InvalidateWindowData(WindowClass::IndustryDirectory, 0, IDIWD_FORCE_REBUILD); + SetWindowDirty(WindowClass::BuildIndustry, 0); } @@ -1975,8 +1975,8 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, if (GetIndustrySpec(i->type)->behaviour.Test(IndustryBehaviour::PlantOnBuild)) { for (uint j = 0; j != 50; j++) PlantRandomFarmField(i); } - InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_FORCE_REBUILD); - SetWindowDirty(WC_BUILD_INDUSTRY, 0); + InvalidateWindowData(WindowClass::IndustryDirectory, 0, IDIWD_FORCE_REBUILD); + SetWindowDirty(WindowClass::BuildIndustry, 0); if (!_generating_world) PopulateStationsNearby(i); } @@ -2268,7 +2268,7 @@ CommandCost CmdIndustrySetText(DoCommandFlags flags, IndustryID ind_id, const En if (flags.Test(DoCommandFlag::Execute)) { ind->text.clear(); if (!text.empty()) ind->text = text; - InvalidateWindowData(WC_INDUSTRY_VIEW, ind->index); + InvalidateWindowData(WindowClass::IndustryView, ind->index); } return CommandCost(); @@ -3034,7 +3034,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) /* Close if needed and allowed */ if (closeit && !CheckIndustryCloseDownProtection(i->type) && !i->ctlflags.Test(IndustryControlFlag::NoClosure)) { i->prod_level = PRODLEVEL_CLOSURE; - SetWindowDirty(WC_INDUSTRY_VIEW, i->index); + SetWindowDirty(WindowClass::IndustryView, i->index); str = indspec->closure_text; } @@ -3109,13 +3109,13 @@ static const IntervalTimer _economy_industries_daily({TimerGam Industry *i = Industry::GetRandom(); if (i != nullptr) { ChangeIndustryProduction(i, false); - SetWindowDirty(WC_INDUSTRY_VIEW, i->index); + SetWindowDirty(WindowClass::IndustryView, i->index); } } } /* production-change */ - InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_PRODUCTION_CHANGE); + InvalidateWindowData(WindowClass::IndustryDirectory, 0, IDIWD_PRODUCTION_CHANGE); }); /** Economy monthly loop for industries. */ @@ -3131,12 +3131,12 @@ static const IntervalTimer _economy_industries_monthly({TimerG delete i; } else { ChangeIndustryProduction(i, true); - SetWindowDirty(WC_INDUSTRY_VIEW, i->index); + SetWindowDirty(WindowClass::IndustryView, i->index); } } /* production-change */ - InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_PRODUCTION_CHANGE); + InvalidateWindowData(WindowClass::IndustryDirectory, 0, IDIWD_PRODUCTION_CHANGE); }); diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index c752badac4..b1abac884c 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -292,7 +292,7 @@ static constexpr std::initializer_list _nested_build_industry_widge /** Window definition of the dynamic place industries gui */ static WindowDesc _build_industry_desc( WindowPosition::Automatic, "build_industry", 170, 212, - WC_BUILD_INDUSTRY, WC_NONE, + WindowClass::BuildIndustry, WindowClass::None, WindowDefaultFlag::Construction, _nested_build_industry_widgets ); @@ -765,7 +765,7 @@ public: void ShowBuildIndustryWindow() { if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return; - if (BringWindowToFrontById(WC_BUILD_INDUSTRY, 0)) return; + if (BringWindowToFrontById(WindowClass::BuildIndustry, 0)) return; new BuildIndustryWindow(); } @@ -824,7 +824,7 @@ public: /** Close the industry production window. */ ~IndustryViewWindow() override { - CloseWindowById(WC_INDUSTRY_PRODUCTION, this->window_number, false); + CloseWindowById(WindowClass::IndustryProductionGraph, this->window_number, false); } void OnInit() override @@ -1222,7 +1222,7 @@ static constexpr std::initializer_list _nested_industry_view_widget /** Window definition of the view industry gui */ static WindowDesc _industry_view_desc( WindowPosition::Automatic, "view_industry", 260, 120, - WC_INDUSTRY_VIEW, WC_NONE, + WindowClass::IndustryView, WindowClass::None, {}, _nested_industry_view_widgets ); @@ -1916,7 +1916,7 @@ CargoType IndustryDirectoryWindow::produced_cargo_filter = CargoFilterCriteria:: /** Window definition of the industry directory gui */ static WindowDesc _industry_directory_desc( WindowPosition::Automatic, "list_industries", 428, 190, - WC_INDUSTRY_DIRECTORY, WC_NONE, + WindowClass::IndustryDirectory, WindowClass::None, {}, _nested_industry_directory_widgets, &IndustryDirectoryWindow::hotkeys @@ -1955,7 +1955,7 @@ static constexpr std::initializer_list _nested_industry_cargoes_wid /** Window description for the industry cargoes window. */ static WindowDesc _industry_cargoes_desc( WindowPosition::Automatic, "industry_cargoes", 300, 210, - WC_INDUSTRY_CARGOES, WC_NONE, + WindowClass::IndustryCargoes, WindowClass::None, {}, _nested_industry_cargoes_widgets ); @@ -2786,7 +2786,7 @@ struct IndustryCargoesWindow : public Window { /* Only notify the smallmap window if it exists. In particular, do not * bring it to the front to prevent messing up any nice layout of the user. */ - InvalidateWindowClassesData(WC_SMALLMAP, 0); + InvalidateWindowClassesData(WindowClass::SmallMap, 0); } /** @@ -3076,7 +3076,7 @@ struct IndustryCargoesWindow : public Window { SndClickBeep(); if (this->IsWidgetLowered(WID_IC_NOTIFY)) { - if (FindWindowByClass(WC_SMALLMAP) == nullptr) ShowSmallMap(); + if (FindWindowByClass(WindowClass::SmallMap) == nullptr) ShowSmallMap(); this->NotifySmallmap(); } break; @@ -3190,7 +3190,7 @@ static void ShowIndustryCargoesWindow(IndustryType id) if (id >= NUM_INDUSTRYTYPES) return; } - Window *w = BringWindowToFrontById(WC_INDUSTRY_CARGOES, 0); + Window *w = BringWindowToFrontById(WindowClass::IndustryCargoes, 0); if (w != nullptr) { w->InvalidateData(id); return; diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 295e6e1e1c..8d25d376a2 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -391,7 +391,7 @@ static constexpr std::initializer_list _nested_select_game_widgets /** Window definition for the select game window. */ static WindowDesc _select_game_desc( WindowPosition::Center, {}, 0, 0, - WC_SELECT_GAME, WC_NONE, + WindowClass::SelectGame, WindowClass::None, WindowDefaultFlag::NoClose, _nested_select_game_widgets ); diff --git a/src/league_cmd.cpp b/src/league_cmd.cpp index aa749400a8..5fd5d905df 100644 --- a/src/league_cmd.cpp +++ b/src/league_cmd.cpp @@ -90,7 +90,7 @@ std::tuple CmdCreateLeagueTableElement(DoComm if (flags.Test(DoCommandFlag::Execute)) { LeagueTableElement *lte = LeagueTableElement::Create(table, rating, company, text, score, link); - InvalidateWindowData(WC_COMPANY_LEAGUE, table); + InvalidateWindowData(WindowClass::CompanyLeague, table); return { CommandCost(), lte->index }; } return { CommandCost(), LeagueTableElementID::Invalid() }; @@ -119,7 +119,7 @@ CommandCost CmdUpdateLeagueTableElementData(DoCommandFlags flags, LeagueTableEle lte->company = company; lte->text = text; lte->link = link; - InvalidateWindowData(WC_COMPANY_LEAGUE, lte->table); + InvalidateWindowData(WindowClass::CompanyLeague, lte->table); } return CommandCost(); } @@ -141,7 +141,7 @@ CommandCost CmdUpdateLeagueTableElementScore(DoCommandFlags flags, LeagueTableEl if (flags.Test(DoCommandFlag::Execute)) { lte->rating = rating; lte->score = score; - InvalidateWindowData(WC_COMPANY_LEAGUE, lte->table); + InvalidateWindowData(WindowClass::CompanyLeague, lte->table); } return CommandCost(); } @@ -161,7 +161,7 @@ CommandCost CmdRemoveLeagueTableElement(DoCommandFlags flags, LeagueTableElement if (flags.Test(DoCommandFlag::Execute)) { auto table = lte->table; delete lte; - InvalidateWindowData(WC_COMPANY_LEAGUE, table); + InvalidateWindowData(WindowClass::CompanyLeague, table); } return CommandCost(); } diff --git a/src/league_gui.cpp b/src/league_gui.cpp index 28f4fb135f..c8c7a3dd4d 100644 --- a/src/league_gui.cpp +++ b/src/league_gui.cpp @@ -194,7 +194,7 @@ static constexpr std::initializer_list _nested_performance_league_w /** Window definition for the performance league window. */ static WindowDesc _performance_league_desc( WindowPosition::Automatic, "performance_league", 0, 0, - WC_COMPANY_LEAGUE, WC_NONE, + WindowClass::CompanyLeague, WindowClass::None, {}, _nested_performance_league_widgets ); @@ -431,7 +431,7 @@ static constexpr std::initializer_list _nested_script_league_widget /** Window definition for the script league window. */ static WindowDesc _script_league_desc( WindowPosition::Automatic, "script_league", 0, 0, - WC_COMPANY_LEAGUE, WC_NONE, + WindowClass::CompanyLeague, WindowClass::None, {}, _nested_script_league_widgets ); diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 65eee899a0..4d86cee089 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -535,7 +535,7 @@ static_assert(WID_LGL_SATURATION_LAST - WID_LGL_SATURATION_FIRST == /** Window definition for the linkgraph toolbar. */ static WindowDesc _linkgraph_legend_desc( WindowPosition::Automatic, "toolbar_linkgraph", 0, 0, - WC_LINKGRAPH_LEGEND, WC_NONE, + WindowClass::LinkGraphLegend, WindowClass::None, {}, _nested_linkgraph_legend_widgets ); diff --git a/src/linkgraph/linkgraphjob.cpp b/src/linkgraph/linkgraphjob.cpp index 95a65e42aa..e96eff07cc 100644 --- a/src/linkgraph/linkgraphjob.cpp +++ b/src/linkgraph/linkgraphjob.cpp @@ -172,7 +172,7 @@ LinkGraphJob::~LinkGraphJob() } geflows.insert(flows.begin(), flows.end()); if (ge.GetData().IsEmpty()) ge.ClearData(); - InvalidateWindowData(WC_STATION_VIEW, st->index, this->Cargo()); + InvalidateWindowData(WindowClass::StationView, st->index, this->Cargo()); } } diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 7e620e50c3..eb1a00da31 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -475,7 +475,7 @@ struct MainWindow : Window { if (!gui_scope) return; /* Forward the message to the appropriate toolbar (ingame or scenario editor) */ - InvalidateWindowData(WC_MAIN_TOOLBAR, 0, data, true); + InvalidateWindowData(WindowClass::MainToolbar, 0, data, true); } static inline HotkeyList hotkeys{"global", { @@ -528,7 +528,7 @@ struct MainWindow : Window /** Window definition for the main window. */ static WindowDesc _main_window_desc( WindowPosition::Manual, {}, 0, 0, - WC_MAIN_WINDOW, WC_NONE, + WindowClass::MainWindow, WindowClass::None, WindowDefaultFlag::NoClose, _nested_main_window_widgets, &MainWindow::hotkeys diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp index 314b3cef4c..cb491a8b6c 100644 --- a/src/misc_cmd.cpp +++ b/src/misc_cmd.cpp @@ -212,8 +212,8 @@ CommandCost CmdPause(DoCommandFlags flags, PauseMode mode, bool pause) VideoDriver::GetInstance()->SetScreensaverInhibited(_pause_mode.None()); } - SetWindowDirty(WC_STATUS_BAR, 0); - SetWindowDirty(WC_MAIN_TOOLBAR, 0); + SetWindowDirty(WindowClass::Statusbar, 0); + SetWindowDirty(WindowClass::MainToolbar, 0); } return CommandCost(); } diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index b977952539..3a234ecbd5 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -57,7 +57,7 @@ static constexpr std::initializer_list _nested_land_info_widgets = /** Window definition for the land information window. */ static WindowDesc _land_info_desc( WindowPosition::Automatic, {}, 0, 0, - WC_LAND_INFO, WC_NONE, + WindowClass::LandInfo, WindowClass::None, {}, _nested_land_info_widgets ); @@ -314,7 +314,7 @@ public: */ void ShowLandInfo(TileIndex tile) { - CloseWindowById(WC_LAND_INFO, 0); + CloseWindowById(WindowClass::LandInfo, 0); new LandInfoWindow(tile); } @@ -337,7 +337,7 @@ static constexpr std::initializer_list _nested_about_widgets = { /** Window definition for the about window. */ static WindowDesc _about_desc( WindowPosition::Center, {}, 0, 0, - WC_GAME_OPTIONS, WC_NONE, + WindowClass::GameOptions, WindowClass::None, {}, _nested_about_widgets ); @@ -477,7 +477,7 @@ struct AboutWindow : public Window { void ShowAboutWindow() { - CloseWindowByClass(WC_GAME_OPTIONS); + CloseWindowByClass(WindowClass::GameOptions); new AboutWindow(); } @@ -594,7 +594,7 @@ static constexpr std::initializer_list _nested_tooltips_widgets = { /** Window definition for the tool tip window. */ static WindowDesc _tool_tips_desc( WindowPosition::Manual, {}, 0, 0, // Coordinates and sizes are not used, - WC_TOOLTIPS, WC_NONE, + WindowClass::ToolTips, WindowClass::None, {WindowDefaultFlag::NoFocus, WindowDefaultFlag::NoClose}, _nested_tooltips_widgets ); @@ -689,7 +689,7 @@ struct TooltipsWindow : public Window */ void GuiShowTooltips(Window *parent, EncodedString &&text, TooltipCloseCondition close_tooltip) { - CloseWindowById(WC_TOOLTIPS, 0); + CloseWindowById(WindowClass::ToolTips, 0); if (text.empty() || !_cursor.in_window) return; @@ -702,7 +702,7 @@ void QueryString::HandleEditBox(Window *w, WidgetID wid) w->SetWidgetDirty(wid); /* For the OSK also invalidate the parent window */ - if (w->window_class == WC_OSK) w->InvalidateData(); + if (w->window_class == WindowClass::OnScreenKeyboard) w->InvalidateData(); } } @@ -887,7 +887,7 @@ void QueryString::ClickEditBox(Window *w, Point pt, WidgetID wid, int click_coun return; } - if (w->window_class != WC_OSK && _settings_client.gui.osk_activation != OskActivation::Disabled && + if (w->window_class != WindowClass::OnScreenKeyboard && _settings_client.gui.osk_activation != OskActivation::Disabled && (!focus_changed || _settings_client.gui.osk_activation == OskActivation::Immediately) && (click_count == 2 || _settings_client.gui.osk_activation != OskActivation::DoubleClick)) { /* Open the OSK window */ @@ -996,8 +996,8 @@ private: /** Clear parent window station/waypoint viewport rect. */ void ClearViewportRect() { - if (this->parent->window_class == WC_STATION_VIEW) SetViewportStationRect(Station::Get(this->parent->window_number), false); - if (this->parent->window_class == WC_WAYPOINT_VIEW) SetViewportWaypointRect(Waypoint::Get(this->parent->window_number), false); + if (this->parent->window_class == WindowClass::StationView) SetViewportStationRect(Station::Get(this->parent->window_number), false); + if (this->parent->window_class == WindowClass::WaypointView) SetViewportWaypointRect(Waypoint::Get(this->parent->window_number), false); } public: @@ -1049,7 +1049,7 @@ static constexpr std::initializer_list _nested_query_string_widgets /** Window definition for the string query window. */ static WindowDesc _query_string_desc( WindowPosition::Center, {}, 0, 0, - WC_QUERY_STRING, WC_NONE, + WindowClass::QueryString, WindowClass::None, {}, _nested_query_string_widgets ); @@ -1067,7 +1067,7 @@ void ShowQueryString(std::string_view str, StringID caption, uint maxsize, Windo { assert(parent != nullptr); - CloseWindowByClass(WC_QUERY_STRING); + CloseWindowByClass(WindowClass::QueryString); new QueryStringWindow(str, caption, (flags.Test(QueryStringFlag::LengthIsInChars) ? MAX_CHAR_LENGTH : 1) * maxsize, maxsize, _query_string_desc, parent, afilter, flags); } @@ -1077,7 +1077,7 @@ void ShowQueryString(std::string_view str, StringID caption, uint maxsize, Windo */ void UpdateQueryStringDefault(std::string_view str) { - QueryStringWindow *w = dynamic_cast(FindWindowByClass(WC_QUERY_STRING)); + QueryStringWindow *w = dynamic_cast(FindWindowByClass(WindowClass::QueryString)); if (w != nullptr) w->editbox.orig = str; } @@ -1199,7 +1199,7 @@ static constexpr std::initializer_list _nested_query_widgets = { /** Window definition for the query window. */ static WindowDesc _query_desc( WindowPosition::Center, {}, 0, 0, - WC_CONFIRM_POPUP_QUERY, WC_NONE, + WindowClass::ConfirmPopupQuery, WindowClass::None, WindowDefaultFlag::Modal, _nested_query_widgets ); @@ -1210,7 +1210,7 @@ static WindowDesc _query_desc( * @param caption string shown as window caption * @param message string that will be shown for the window * @param parent pointer to parent window, if this pointer is nullptr the parent becomes - * the main window WC_MAIN_WINDOW + * the main window WindowClass::MainWindow * @param callback callback function pointer to set in the window descriptor * @param focus whether the window should be focussed (by default false) */ @@ -1219,7 +1219,7 @@ void ShowQuery(EncodedString &&caption, EncodedString &&message, Window *parent, if (parent == nullptr) parent = GetMainWindow(); for (Window *w : Window::Iterate()) { - if (w->window_class != WC_CONFIRM_POPUP_QUERY) continue; + if (w->window_class != WindowClass::ConfirmPopupQuery) continue; QueryWindow *qw = dynamic_cast(w); assert(qw != nullptr); diff --git a/src/music_gui.cpp b/src/music_gui.cpp index c04f6bf6fa..4e347b1d5f 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -159,8 +159,8 @@ void MusicSystem::ChangePlaylist(PlaylistChoices pl) if (_settings_client.music.playing) this->Play(); } - InvalidateWindowData(WC_MUSIC_TRACK_SELECTION, 0); - InvalidateWindowData(WC_MUSIC_WINDOW, 0); + InvalidateWindowData(WindowClass::MusicTrackSelection, 0); + InvalidateWindowData(WindowClass::Music, 0); } /** @@ -175,9 +175,9 @@ void MusicSystem::ChangeMusicSet(const std::string &set_name) this->BuildPlaylists(); this->ChangePlaylist(this->selected_playlist); - InvalidateWindowData(WC_GAME_OPTIONS, GameOptionsWindowNumber::GameOptions, 0, true); - InvalidateWindowData(WC_MUSIC_TRACK_SELECTION, 0, 1, true); - InvalidateWindowData(WC_MUSIC_WINDOW, 0, 1, true); + InvalidateWindowData(WindowClass::GameOptions, GameOptionsWindowNumber::GameOptions, 0, true); + InvalidateWindowData(WindowClass::MusicTrackSelection, 0, 1, true); + InvalidateWindowData(WindowClass::Music, 0, 1, true); } /** @@ -216,8 +216,8 @@ void MusicSystem::Shuffle() } this->SetPositionBySetIndex(set_index); - InvalidateWindowData(WC_MUSIC_TRACK_SELECTION, 0); - InvalidateWindowData(WC_MUSIC_WINDOW, 0); + InvalidateWindowData(WindowClass::MusicTrackSelection, 0); + InvalidateWindowData(WindowClass::Music, 0); } /** @@ -231,8 +231,8 @@ void MusicSystem::Unshuffle() this->active_playlist = this->standard_playlists[this->selected_playlist]; this->SetPositionBySetIndex(set_index); - InvalidateWindowData(WC_MUSIC_TRACK_SELECTION, 0); - InvalidateWindowData(WC_MUSIC_WINDOW, 0); + InvalidateWindowData(WindowClass::MusicTrackSelection, 0); + InvalidateWindowData(WindowClass::Music, 0); } /** Start/restart playback at current song */ @@ -251,7 +251,7 @@ void MusicSystem::Play() if (_game_mode == GM_MENU && this->selected_playlist == PLCH_THEMEONLY) song.loop = true; MusicDriver::GetInstance()->PlaySong(song); - InvalidateWindowData(WC_MUSIC_WINDOW, 0); + InvalidateWindowData(WindowClass::Music, 0); } /** Stop playback and set flag that we don't intend to play music */ @@ -260,7 +260,7 @@ void MusicSystem::Stop() MusicDriver::GetInstance()->StopSong(); _settings_client.music.playing = false; - InvalidateWindowData(WC_MUSIC_WINDOW, 0); + InvalidateWindowData(WindowClass::Music, 0); } /** Skip to next track */ @@ -269,7 +269,7 @@ void MusicSystem::Next() this->ChangePlaylistPosition(+1); if (_settings_client.music.playing) this->Play(); - InvalidateWindowData(WC_MUSIC_WINDOW, 0); + InvalidateWindowData(WindowClass::Music, 0); } /** Skip to previous track */ @@ -278,7 +278,7 @@ void MusicSystem::Prev() this->ChangePlaylistPosition(-1); if (_settings_client.music.playing) this->Play(); - InvalidateWindowData(WC_MUSIC_WINDOW, 0); + InvalidateWindowData(WindowClass::Music, 0); } /** Check that music is playing if it should, and that appropriate playlist is active for game/main menu */ @@ -366,7 +366,7 @@ void MusicSystem::PlaylistAdd(size_t song_index) this->SaveCustomPlaylist(this->selected_playlist); - InvalidateWindowData(WC_MUSIC_TRACK_SELECTION, 0); + InvalidateWindowData(WindowClass::MusicTrackSelection, 0); } /** @@ -400,7 +400,7 @@ void MusicSystem::PlaylistRemove(size_t song_index) this->SaveCustomPlaylist(this->selected_playlist); - InvalidateWindowData(WC_MUSIC_TRACK_SELECTION, 0); + InvalidateWindowData(WindowClass::MusicTrackSelection, 0); } /** @@ -673,7 +673,7 @@ static constexpr std::initializer_list _nested_music_track_selectio /** Window definition for the music track selection window. */ static WindowDesc _music_track_selection_desc( WindowPosition::Automatic, {}, 0, 0, - WC_MUSIC_TRACK_SELECTION, WC_NONE, + WindowClass::MusicTrackSelection, WindowClass::None, {}, _nested_music_track_selection_widgets ); @@ -841,7 +841,7 @@ struct MusicWindow : public Window { SetEffectVolume(vol); } this->SetWidgetDirty(widget); - SetWindowClassesDirty(WC_GAME_OPTIONS); + SetWindowClassesDirty(WindowClass::GameOptions); } if (click_count > 0) this->mouse_capture_widget = widget; @@ -933,7 +933,7 @@ static constexpr std::initializer_list _nested_music_window_widgets /** Window definition for the music window. */ static WindowDesc _music_window_desc( WindowPosition::Automatic, "music", 0, 0, - WC_MUSIC_WINDOW, WC_NONE, + WindowClass::Music, WindowClass::None, {}, _nested_music_window_widgets ); diff --git a/src/network/network.cpp b/src/network/network.cpp index 25c2b6edf5..338f5b68c7 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -107,7 +107,7 @@ bool HasClients() NetworkClientInfo::~NetworkClientInfo() { /* Delete the chat window, if you were chatting with this client. */ - InvalidateWindowData(WC_SEND_NETWORK_MSG, NetworkChatDestinationType::Client, this->client_id); + InvalidateWindowData(WindowClass::NetworkChat, NetworkChatDestinationType::Client, this->client_id); } /** @@ -583,7 +583,7 @@ NetworkAddress ParseConnectionString(std::string_view connection_string, uint16_ ServerNetworkGameSocketHandler *cs = ServerNetworkGameSocketHandler::Create(s); cs->client_address = address; // Save the IP of the client - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); } /** @@ -1048,7 +1048,7 @@ void NetworkDisconnect(bool close_admins) } } - CloseWindowById(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::Join); + CloseWindowById(WindowClass::NetworkStatus, NetworkStatusWindowNumber::Join); NetworkClose(close_admins); diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index c1d817a0f4..b6b48ba186 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -178,7 +178,7 @@ void NetworkDrawChatMessage() Blitter *blitter = BlitterFactory::GetCurrentBlitter(); if (!_chatmessage_dirty) return; - const Window *w = FindWindowByClass(WC_SEND_NETWORK_MSG); + const Window *w = FindWindowByClass(WindowClass::NetworkChat); bool show_all = (w != nullptr); /* First undraw if needed */ @@ -324,14 +324,14 @@ struct NetworkChatWindow : public Window { this->FinishInitNested(type); this->SetFocusedWidget(WID_NC_TEXTBOX); - InvalidateWindowData(WC_NEWS_WINDOW, 0, this->height); + InvalidateWindowData(WindowClass::News, 0, this->height); PositionNetworkChatWindow(this); } void Close([[maybe_unused]] int data = 0) override { - InvalidateWindowData(WC_NEWS_WINDOW, 0, 0); + InvalidateWindowData(WindowClass::News, 0, 0); this->Window::Close(); } @@ -352,7 +352,7 @@ struct NetworkChatWindow : public Window { Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override { - Point pt = { 0, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height }; + Point pt = { 0, _screen.height - sm_height - FindWindowById(WindowClass::Statusbar, 0)->height }; return pt; } @@ -426,7 +426,7 @@ static constexpr std::initializer_list _nested_chat_window_widgets /** The description of the chat window. */ static WindowDesc _chat_window_desc( WindowPosition::Manual, {}, 0, 0, - WC_SEND_NETWORK_MSG, WC_NONE, + WindowClass::NetworkChat, WindowClass::None, {}, _nested_chat_window_widgets ); @@ -439,6 +439,6 @@ static WindowDesc _chat_window_desc( */ void ShowNetworkChatQueryWindow(NetworkChatDestinationType type, int dest) { - CloseWindowByClass(WC_SEND_NETWORK_MSG); + CloseWindowByClass(WindowClass::NetworkChat); new NetworkChatWindow(_chat_window_desc, type, dest); } diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index d53ec07c6a..92bc4d3579 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -153,7 +153,7 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res) this->CloseConnection(res); _networking = false; - CloseWindowById(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::Join); + CloseWindowById(WindowClass::NetworkStatus, NetworkStatusWindowNumber::Join); return; } @@ -183,7 +183,7 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res) ClientNetworkEmergencySave(); } - CloseWindowById(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::Join); + CloseWindowById(WindowClass::NetworkStatus, NetworkStatusWindowNumber::Join); if (_game_mode != GM_MENU) _switch_mode = SM_MENU; _networking = false; @@ -292,7 +292,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendJoin() my_client->status = STATUS_JOIN; Debug(net, 9, "Client::join_status = Authorizing"); _network_join_status = NetworkJoinStatus::Authorizing; - SetWindowDirty(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::Join); + SetWindowDirty(WindowClass::NetworkStatus, NetworkStatusWindowNumber::Join); auto p = std::make_unique(my_client, PacketGameType::ClientJoin); p->Send_string(GetNetworkRevisionString()); @@ -588,7 +588,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::ReceiveServerClientInfo(Packet ci->client_name = std::move(name); ci->public_key = std::move(public_key); - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); return NETWORK_RECV_STATUS_OKAY; } @@ -608,7 +608,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::ReceiveServerClientInfo(Packet ci->client_name = std::move(name); ci->public_key = std::move(public_key); - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); return NETWORK_RECV_STATUS_OKAY; } @@ -788,7 +788,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::ReceiveServerWaitForMap(Packet Debug(net, 9, "Client::join_status = Waiting"); _network_join_status = NetworkJoinStatus::Waiting; _network_join_waiting = p.Recv_uint8(); - SetWindowDirty(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::Join); + SetWindowDirty(WindowClass::NetworkStatus, NetworkStatusWindowNumber::Join); return NETWORK_RECV_STATUS_OKAY; } @@ -812,7 +812,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::ReceiveServerMapBegin(Packet & Debug(net, 9, "Client::join_status = Downloading"); _network_join_status = NetworkJoinStatus::Downloading; - SetWindowDirty(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::Join); + SetWindowDirty(WindowClass::NetworkStatus, NetworkStatusWindowNumber::Join); return NETWORK_RECV_STATUS_OKAY; } @@ -823,7 +823,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::ReceiveServerMapSize(Packet &p if (this->savegame == nullptr) return NETWORK_RECV_STATUS_MALFORMED_PACKET; _network_join_bytes_total = p.Recv_uint32(); - SetWindowDirty(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::Join); + SetWindowDirty(WindowClass::NetworkStatus, NetworkStatusWindowNumber::Join); Debug(net, 9, "Client::ReceiveServerMapSize(): bytes_total={}", _network_join_bytes_total); @@ -839,7 +839,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::ReceiveServerMapData(Packet &p this->savegame->AddPacket(p); _network_join_bytes = static_cast(this->savegame->buffer.size()); - SetWindowDirty(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::Join); + SetWindowDirty(WindowClass::NetworkStatus, NetworkStatusWindowNumber::Join); return NETWORK_RECV_STATUS_OKAY; } @@ -853,7 +853,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::ReceiveServerMapDone(Packet &) Debug(net, 9, "Client::join_status = Processing"); _network_join_status = NetworkJoinStatus::Processing; - SetWindowDirty(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::Join); + SetWindowDirty(WindowClass::NetworkStatus, NetworkStatusWindowNumber::Join); this->savegame->Reset(); @@ -1061,7 +1061,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::ReceiveServerErrorQuit(Packet delete ci; } - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); return NETWORK_RECV_STATUS_OKAY; } @@ -1082,7 +1082,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::ReceiveServerQuit(Packet &p) Debug(net, 1, "Unknown client ({}) is leaving the game", client_id); } - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); /* If we come here it means we could not locate the client.. strange :s */ return NETWORK_RECV_STATUS_OKAY; @@ -1101,7 +1101,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::ReceiveServerClientJoined(Pack NetworkTextMessage(NetworkAction::ClientJoin, CC_DEFAULT, false, ci->client_name); } - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); return NETWORK_RECV_STATUS_OKAY; } @@ -1193,7 +1193,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::ReceiveServerConfigurationUpda _network_server_max_companies = p.Recv_uint8(); _network_server_name = p.Recv_string(NETWORK_NAME_LENGTH); - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); Debug(net, 9, "Client::ReceiveServerConfigurationUpdate(): max_companies={}", _network_server_max_companies); @@ -1352,7 +1352,7 @@ void NetworkUpdateClientName(const std::string &client_name) NetworkTextMessage(NetworkAction::ClientNameChange, CC_DEFAULT, false, ci->client_name, temporary_name); ci->client_name = std::move(temporary_name); NetworkUpdateClientInfo(CLIENT_ID_SERVER); - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); } } } diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index d1921cd58c..c97252f56a 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -467,7 +467,7 @@ bool ClientNetworkContentSocketHandler::ReceiveServerContent(Packet &p) return fwrite(buffer.data(), 1, buffer.size(), *this->cur_file); }; if (to_read != 0 && p.TransferOut(write_to_disk) != to_read) { - CloseWindowById(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::ContentDownload); + CloseWindowById(WindowClass::NetworkStatus, NetworkStatusWindowNumber::ContentDownload); ShowErrorMessage( GetEncodedString(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD), GetEncodedString(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD_FILE_NOT_WRITABLE), @@ -502,7 +502,7 @@ bool ClientNetworkContentSocketHandler::BeforeDownload() std::string filename = GetFullFilename(*this->cur_info, true); if (filename.empty() || !(this->cur_file = FileHandle::Open(filename, "wb")).has_value()) { /* Unless that fails of course... */ - CloseWindowById(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::ContentDownload); + CloseWindowById(WindowClass::NetworkStatus, NetworkStatusWindowNumber::ContentDownload); ShowErrorMessage( GetEncodedString(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD), GetEncodedString(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD_FILE_NOT_WRITABLE), diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 4e8d629763..f2f10dfd65 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -95,7 +95,7 @@ struct ContentTextfileWindow : public TextfileWindow { */ static void ShowContentTextfileWindow(Window *parent, TextfileType file_type, const ContentInfo *ci) { - parent->CloseChildWindowById(WC_TEXTFILE, file_type); + parent->CloseChildWindowById(WindowClass::Textfile, file_type); new ContentTextfileWindow(parent, file_type, ci); } @@ -114,7 +114,7 @@ static constexpr std::initializer_list _nested_network_content_down /** Window description for the download window */ static WindowDesc _network_content_download_status_window_desc( WindowPosition::Center, {}, 0, 0, - WC_NETWORK_STATUS_WINDOW, WC_NONE, + WindowClass::NetworkStatus, WindowClass::None, WindowDefaultFlag::Modal, _nested_network_content_download_status_window_widgets ); @@ -210,7 +210,7 @@ public: */ NetworkContentDownloadStatusWindow() : BaseNetworkContentDownloadStatusWindow(_network_content_download_status_window_desc) { - this->parent = FindWindowById(WC_NETWORK_WINDOW, NetworkWindowNumber::ContentList); + this->parent = FindWindowById(WindowClass::Network, NetworkWindowNumber::ContentList); } void Close([[maybe_unused]] int data = 0) override @@ -264,17 +264,17 @@ public: case ContentType::BaseGraphics: BaseGraphics::FindSets(); - SetWindowDirty(WC_GAME_OPTIONS, GameOptionsWindowNumber::GameOptions); + SetWindowDirty(WindowClass::GameOptions, GameOptionsWindowNumber::GameOptions); break; case ContentType::BaseSounds: BaseSounds::FindSets(); - SetWindowDirty(WC_GAME_OPTIONS, GameOptionsWindowNumber::GameOptions); + SetWindowDirty(WindowClass::GameOptions, GameOptionsWindowNumber::GameOptions); break; case ContentType::BaseMusic: BaseMusic::FindSets(); - SetWindowDirty(WC_GAME_OPTIONS, GameOptionsWindowNumber::GameOptions); + SetWindowDirty(WindowClass::GameOptions, GameOptionsWindowNumber::GameOptions); break; case ContentType::NewGRF: @@ -284,7 +284,7 @@ public: case ContentType::Scenario: case ContentType::Heightmap: ScanScenarios(); - InvalidateWindowData(WC_SAVELOAD, 0, 0); + InvalidateWindowData(WindowClass::SaveLoad, 0, 0); break; default: @@ -293,7 +293,7 @@ public: } /* Always invalidate the download window; tell it we are going to be gone */ - InvalidateWindowData(WC_NETWORK_WINDOW, NetworkWindowNumber::ContentList, 2); + InvalidateWindowData(WindowClass::Network, NetworkWindowNumber::ContentList, 2); this->BaseNetworkContentDownloadStatusWindow::Close(); } @@ -307,7 +307,7 @@ public: } else { /* If downloading succeeded, close the online content window. This will close * the current window as well. */ - CloseWindowById(WC_NETWORK_WINDOW, NetworkWindowNumber::ContentList); + CloseWindowById(WindowClass::Network, NetworkWindowNumber::ContentList); } } } @@ -870,7 +870,7 @@ public: break; case WID_NCL_DOWNLOAD: - if (BringWindowToFrontById(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::ContentDownload) == nullptr) new NetworkContentDownloadStatusWindow(); + if (BringWindowToFrontById(WindowClass::NetworkStatus, NetworkStatusWindowNumber::ContentDownload) == nullptr) new NetworkContentDownloadStatusWindow(); break; case WID_NCL_SEARCH_EXTERNAL: @@ -1005,7 +1005,7 @@ public: } /* If data == 2 then the status window caused this OnInvalidate */ - this->SetWidgetDisabledState(WID_NCL_DOWNLOAD, this->filesize_sum == 0 || (FindWindowById(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::ContentDownload) != nullptr && data != 2)); + this->SetWidgetDisabledState(WID_NCL_DOWNLOAD, this->filesize_sum == 0 || (FindWindowById(WindowClass::NetworkStatus, NetworkStatusWindowNumber::ContentDownload) != nullptr && data != 2)); this->SetWidgetDisabledState(WID_NCL_UNSELECT, this->filesize_sum == 0); this->SetWidgetDisabledState(WID_NCL_SELECT_ALL, !show_select_all); this->SetWidgetDisabledState(WID_NCL_SELECT_UPDATE, !show_select_upgrade || !this->filter_data.string_filter.IsEmpty()); @@ -1120,7 +1120,7 @@ static constexpr std::initializer_list _nested_network_content_list /** Window description of the content list */ static WindowDesc _network_content_list_desc( WindowPosition::Center, "list_content", 630, 460, - WC_NETWORK_WINDOW, WC_NONE, + WindowClass::Network, WindowClass::None, {}, _nested_network_content_list_widgets ); @@ -1149,7 +1149,7 @@ void ShowNetworkContentListWindow(ContentVector *cv, ContentType type1, ContentT _network_content_client.RequestContentList(cv, true); } - CloseWindowById(WC_NETWORK_WINDOW, NetworkWindowNumber::ContentList); + CloseWindowById(WindowClass::Network, NetworkWindowNumber::ContentList); new NetworkContentListWindow(_network_content_list_desc, cv != nullptr, types); #else ShowErrorMessage( diff --git a/src/network/network_coordinator.cpp b/src/network/network_coordinator.cpp index ece5d1bfed..a6e182f6d7 100644 --- a/src/network/network_coordinator.cpp +++ b/src/network/network_coordinator.cpp @@ -199,7 +199,7 @@ bool ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorRegisterAck(Pa * attempt to re-use when registering again. */ _network_server_invite_code = _settings_client.network.server_invite_code; - SetWindowDirty(WC_CLIENT_LIST, 0); + SetWindowDirty(WindowClass::NetworkClientList, 0); if (_network_dedicated) { std::string connection_type; @@ -454,7 +454,7 @@ NetworkRecvStatus ClientNetworkCoordinatorSocketHandler::CloseConnection(bool er this->CloseAllConnections(); - SetWindowDirty(WC_CLIENT_LIST, 0); + SetWindowDirty(WindowClass::NetworkClientList, 0); return NETWORK_RECV_STATUS_OKAY; } @@ -467,7 +467,7 @@ void ClientNetworkCoordinatorSocketHandler::Register() _network_server_connection_type = CONNECTION_TYPE_UNKNOWN; this->next_update = {}; - SetWindowDirty(WC_CLIENT_LIST, 0); + SetWindowDirty(WindowClass::NetworkClientList, 0); this->Connect(); @@ -672,7 +672,7 @@ void ClientNetworkCoordinatorSocketHandler::CloseStunHandler(std::string_view to */ void ClientNetworkCoordinatorSocketHandler::CloseTurnHandler(std::string_view token) { - CloseWindowByClass(WC_NETWORK_ASK_RELAY, NRWCD_HANDLED); + CloseWindowByClass(WindowClass::NetworkAskRelay, NRWCD_HANDLED); auto turn_it = this->turn_handlers.find(token); if (turn_it == this->turn_handlers.end()) return; diff --git a/src/network/network_gamelist.cpp b/src/network/network_gamelist.cpp index f63f81807f..22e8687bb0 100644 --- a/src/network/network_gamelist.cpp +++ b/src/network/network_gamelist.cpp @@ -99,5 +99,5 @@ void NetworkAfterNewGRFScan() } } - InvalidateWindowClassesData(WC_NETWORK_WINDOW); + InvalidateWindowClassesData(WindowClass::Network); } diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 3ef0130222..93b748be89 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -65,7 +65,7 @@ static CompanyID _admin_company_id = CompanyID::Invalid(); ///< For what company */ void UpdateNetworkGameWindow() { - InvalidateWindowData(WC_NETWORK_WINDOW, NetworkWindowNumber::Game, 0); + InvalidateWindowData(WindowClass::Network, NetworkWindowNumber::Game, 0); } /** @@ -953,7 +953,7 @@ static constexpr std::initializer_list _nested_network_game_widgets /** Description of the NetworkGameWindow. */ static WindowDesc _network_game_window_desc( WindowPosition::Center, "list_servers", 1000, 730, - WC_NETWORK_WINDOW, WC_NONE, + WindowClass::Network, WindowClass::None, {}, _nested_network_game_widgets ); @@ -962,7 +962,7 @@ static WindowDesc _network_game_window_desc( void ShowNetworkGameWindow() { static bool first = true; - CloseWindowById(WC_NETWORK_WINDOW, NetworkWindowNumber::StartServer); + CloseWindowById(WindowClass::Network, NetworkWindowNumber::StartServer); /* Only show once */ if (first) { @@ -1230,7 +1230,7 @@ static constexpr std::initializer_list _nested_network_start_server /** Description of the NetworkStartServerWindow. */ static WindowDesc _network_start_server_window_desc( WindowPosition::Center, {}, 0, 0, - WC_NETWORK_WINDOW, WC_NONE, + WindowClass::Network, WindowClass::None, {}, _nested_network_start_server_window_widgets ); @@ -1240,7 +1240,7 @@ static void ShowNetworkStartServerWindow() { if (!NetworkValidateOurClientName()) return; - CloseWindowById(WC_NETWORK_WINDOW, NetworkWindowNumber::Game); + CloseWindowById(WindowClass::Network, NetworkWindowNumber::Game); new NetworkStartServerWindow(_network_start_server_window_desc); } @@ -1307,7 +1307,7 @@ static constexpr std::initializer_list _nested_client_list_widgets /** Description of the NetworkClientListWindow. */ static WindowDesc _client_list_desc( WindowPosition::Automatic, "list_clients", 220, 300, - WC_CLIENT_LIST, WC_NONE, + WindowClass::NetworkClientList, WindowClass::None, {}, _nested_client_list_widgets ); @@ -2092,7 +2092,7 @@ struct NetworkJoinStatusWindow : Window { */ NetworkJoinStatusWindow(WindowDesc &desc) : Window(desc) { - this->parent = FindWindowById(WC_NETWORK_WINDOW, NetworkWindowNumber::Game); + this->parent = FindWindowById(WindowClass::Network, NetworkWindowNumber::Game); this->InitNested(NetworkStatusWindowNumber::Join); } @@ -2209,7 +2209,7 @@ static constexpr std::initializer_list _nested_network_join_status_ /** Description of the NetworkJoinStatusWindow. */ static WindowDesc _network_join_status_window_desc( WindowPosition::Center, {}, 0, 0, - WC_NETWORK_STATUS_WINDOW, WC_NONE, + WindowClass::NetworkStatus, WindowClass::None, WindowDefaultFlag::Modal, _nested_network_join_status_window_widgets ); @@ -2217,7 +2217,7 @@ static WindowDesc _network_join_status_window_desc( /** Open the window showing the status of joining the server. */ void ShowJoinStatusWindow() { - CloseWindowById(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::Join); + CloseWindowById(WindowClass::NetworkStatus, NetworkStatusWindowNumber::Join); new NetworkJoinStatusWindow(_network_join_status_window_desc); } @@ -2227,7 +2227,7 @@ void ShowJoinStatusWindow() */ void ShowNetworkNeedPassword(std::shared_ptr request) { - NetworkJoinStatusWindow *w = dynamic_cast(FindWindowById(WC_NETWORK_STATUS_WINDOW, NetworkStatusWindowNumber::Join)); + NetworkJoinStatusWindow *w = dynamic_cast(FindWindowById(WindowClass::NetworkStatus, NetworkStatusWindowNumber::Join)); if (w == nullptr) return; w->request = std::move(request); @@ -2331,7 +2331,7 @@ static constexpr std::initializer_list _nested_network_ask_relay_wi /** Description of the NetworkAskRelayWindow. */ static WindowDesc _network_ask_relay_desc( WindowPosition::Center, {}, 0, 0, - WC_NETWORK_ASK_RELAY, WC_NONE, + WindowClass::NetworkAskRelay, WindowClass::None, WindowDefaultFlag::Modal, _nested_network_ask_relay_widgets ); @@ -2344,7 +2344,7 @@ static WindowDesc _network_ask_relay_desc( */ void ShowNetworkAskRelay(std::string_view server_connection_string, std::string &&relay_connection_string, std::string &&token) { - CloseWindowByClass(WC_NETWORK_ASK_RELAY, NRWCD_HANDLED); + CloseWindowByClass(WindowClass::NetworkAskRelay, NRWCD_HANDLED); Window *parent = GetMainWindow(); new NetworkAskRelayWindow(_network_ask_relay_desc, parent, server_connection_string, std::move(relay_connection_string), std::move(token)); @@ -2436,7 +2436,7 @@ static constexpr std::initializer_list _nested_network_ask_survey_w /** Description of the NetworkAskSurveyWindow. */ static WindowDesc _network_ask_survey_desc( WindowPosition::Center, {}, 0, 0, - WC_NETWORK_ASK_SURVEY, WC_NONE, + WindowClass::NetworkAskSurvey, WindowClass::None, WindowDefaultFlag::Modal, _nested_network_ask_survey_widgets ); @@ -2449,7 +2449,7 @@ void ShowNetworkAskSurvey() /* If we can't send a survey, don't ask the question. */ if constexpr (!NetworkSurveyHandler::IsSurveyPossible()) return; - CloseWindowByClass(WC_NETWORK_ASK_SURVEY); + CloseWindowByClass(WindowClass::NetworkAskSurvey); Window *parent = GetMainWindow(); new NetworkAskSurveyWindow(_network_ask_survey_desc, parent); @@ -2480,6 +2480,6 @@ struct SurveyResultTextfileWindow : public TextfileWindow { */ void ShowSurveyResultTextfileWindow(Window *parent) { - parent->CloseChildWindowById(WC_TEXTFILE, TFT_SURVEY_RESULT); + parent->CloseChildWindowById(WindowClass::Textfile, TFT_SURVEY_RESULT); new SurveyResultTextfileWindow(parent, TFT_SURVEY_RESULT); } diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 3fdf658222..73d2c4f04a 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -218,7 +218,7 @@ ServerNetworkGameSocketHandler::~ServerNetworkGameSocketHandler() this->savegame = nullptr; } - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); } std::unique_ptr ServerNetworkGameSocketHandler::ReceivePacket() @@ -1071,7 +1071,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::ReceiveClientMapOk(Packet &) std::string client_name = this->GetClientName(); NetworkTextMessage(NetworkAction::ClientJoin, CC_DEFAULT, false, client_name, "", this->client_id); - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); Debug(net, 3, "[{}] Client #{} ({}) joined as {}", ServerNetworkGameSocketHandler::GetName(), this->client_id, this->GetClientIP(), client_name); @@ -1489,7 +1489,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::ReceiveClientSetName(Packet &p NetworkTextMessage(NetworkAction::ClientNameChange, CC_DEFAULT, false, ci->client_name, client_name); ci->client_name = std::move(client_name); NetworkUpdateClientInfo(ci->client_id); - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); } } return NETWORK_RECV_STATUS_OKAY; @@ -2067,7 +2067,7 @@ void NetworkServerDoMove(ClientID client_id, CompanyID company_id) NetworkServerSendChat(NetworkAction::CompanyJoin, NetworkChatDestinationType::Broadcast, 0, company_name, client_id); } - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); } /** diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index fe518dcabc..c6757a0ffa 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -193,7 +193,7 @@ void GRFConfig::SetValue(const GRFParameterInfo &info, uint32_t value) SB(this->param[info.param_nr], info.first_bit, info.num_bit, value); } - SetWindowDirty(WC_GAME_OPTIONS, GameOptionsWindowNumber::NewGRFState); + SetWindowDirty(WindowClass::GameOptions, GameOptionsWindowNumber::NewGRFState); } /** @@ -566,11 +566,11 @@ void DoScanNewGRFFiles(NewGRFScanCallback *callback) NetworkAfterNewGRFScan(); /* Yes... these are the NewGRF windows */ - InvalidateWindowClassesData(WC_SAVELOAD, 0, true); - InvalidateWindowData(WC_GAME_OPTIONS, GameOptionsWindowNumber::NewGRFState, GOID_NEWGRF_RESCANNED, true); + InvalidateWindowClassesData(WindowClass::SaveLoad, 0, true); + InvalidateWindowData(WindowClass::GameOptions, GameOptionsWindowNumber::NewGRFState, GOID_NEWGRF_RESCANNED, true); if (!_exit_game && callback != nullptr) callback->OnNewGRFsScanned(); - CloseWindowByClass(WC_MODAL_PROGRESS); + CloseWindowByClass(WindowClass::ModalProgress); SetModalProgress(false); MarkWholeScreenDirty(); } diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 5b030d4b31..f40740cee2 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -681,7 +681,7 @@ static constexpr std::initializer_list _nested_newgrf_inspect_widge /** Window definition for the NewGRF chain inspection window. */ static WindowDesc _newgrf_inspect_chain_desc( WindowPosition::Automatic, "newgrf_inspect_chain", 400, 300, - WC_NEWGRF_INSPECT, WC_NONE, + WindowClass::NewGRFInspect, WindowClass::None, {}, _nested_newgrf_inspect_chain_widgets ); @@ -689,7 +689,7 @@ static WindowDesc _newgrf_inspect_chain_desc( /** Window definition for the NewGRF inspection window. */ static WindowDesc _newgrf_inspect_desc( WindowPosition::Automatic, "newgrf_inspect", 400, 300, - WC_NEWGRF_INSPECT, WC_NONE, + WindowClass::NewGRFInspect, WindowClass::None, {}, _nested_newgrf_inspect_widgets ); @@ -726,7 +726,7 @@ void InvalidateNewGRFInspectWindow(GrfSpecFeature feature, uint index) if (feature == GrfSpecFeature::Invalid) return; WindowNumber wno = GetInspectWindowNumber(feature, index); - InvalidateWindowData(WC_NEWGRF_INSPECT, wno); + InvalidateWindowData(WindowClass::NewGRFInspect, wno); } /** @@ -742,12 +742,12 @@ void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index) if (feature == GrfSpecFeature::Invalid) return; WindowNumber wno = GetInspectWindowNumber(feature, index); - CloseWindowById(WC_NEWGRF_INSPECT, wno); + CloseWindowById(WindowClass::NewGRFInspect, wno); /* Reinitialise the land information window to remove the "debug" sprite if needed. * Note: Since we might be called from a command here, it is important to not execute * the invalidation immediately. The landinfo window tests commands itself. */ - InvalidateWindowData(WC_LAND_INFO, 0, 1); + InvalidateWindowData(WindowClass::LandInfo, 0, 1); } /** @@ -1188,7 +1188,7 @@ static constexpr std::initializer_list _nested_sprite_aligner_widge /** Window definition for the sprite aligner window. */ static WindowDesc _sprite_aligner_desc( WindowPosition::Automatic, "sprite_aligner", 400, 300, - WC_SPRITE_ALIGNER, WC_NONE, + WindowClass::SpriteAligner, WindowClass::None, {}, _nested_sprite_aligner_widgets ); diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index f50221a5d9..54445b8f51 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -335,7 +335,7 @@ struct NewGRFParametersWindow : public Window { if (this->editable && !this->action14present && !this->grf_config.param.empty()) { this->grf_config.param.pop_back(); this->InvalidateData(); - SetWindowDirty(WC_GAME_OPTIONS, GameOptionsWindowNumber::NewGRFState); + SetWindowDirty(WindowClass::GameOptions, GameOptionsWindowNumber::NewGRFState); } break; @@ -343,7 +343,7 @@ struct NewGRFParametersWindow : public Window { if (this->editable && !this->action14present && this->grf_config.param.size() < this->grf_config.num_valid_params) { this->grf_config.param.emplace_back(0); this->InvalidateData(); - SetWindowDirty(WC_GAME_OPTIONS, GameOptionsWindowNumber::NewGRFState); + SetWindowDirty(WindowClass::GameOptions, GameOptionsWindowNumber::NewGRFState); } break; @@ -353,8 +353,8 @@ struct NewGRFParametersWindow : public Window { if (num >= this->vscroll->GetCount()) break; if (this->clicked_row != num) { - this->CloseChildWindows(WC_QUERY_STRING); - this->CloseChildWindows(WC_DROPDOWN_MENU); + this->CloseChildWindows(WindowClass::QueryString); + this->CloseChildWindows(WindowClass::DropdownMenu); this->clicked_row = num; this->clicked_dropdown = false; } @@ -370,7 +370,7 @@ struct NewGRFParametersWindow : public Window { if (par_info.type != GRFParameterType::Bool && IsInsideMM(x, 0, SETTING_BUTTON_WIDTH) && par_info.complete_labels) { if (this->clicked_dropdown) { /* unclick the dropdown */ - this->CloseChildWindows(WC_DROPDOWN_MENU); + this->CloseChildWindows(WindowClass::DropdownMenu); this->clicked_dropdown = false; this->closing_dropdown = false; } else { @@ -430,7 +430,7 @@ struct NewGRFParametersWindow : public Window { if (!this->editable) break; this->grf_config.SetParameterDefaults(); this->InvalidateData(); - SetWindowDirty(WC_GAME_OPTIONS, GameOptionsWindowNumber::NewGRFState); + SetWindowDirty(WindowClass::GameOptions, GameOptionsWindowNumber::NewGRFState); break; } } @@ -487,7 +487,7 @@ struct NewGRFParametersWindow : public Window { this->vscroll->SetCount(this->action14present ? this->grf_config.num_valid_params : this->grf_config.param.size()); if (this->clicked_row != INT32_MAX && this->clicked_row >= this->vscroll->GetCount()) { this->clicked_row = INT32_MAX; - this->CloseChildWindows(WC_QUERY_STRING); + this->CloseChildWindows(WindowClass::QueryString); } } @@ -534,14 +534,14 @@ static constexpr std::initializer_list _nested_newgrf_parameter_wid /** Window definition for the change grf parameters window */ static WindowDesc _newgrf_parameters_desc( WindowPosition::Center, "settings_newgrf_config", 500, 208, - WC_GRF_PARAMETERS, WC_NONE, + WindowClass::NewGRFParameters, WindowClass::None, {}, _nested_newgrf_parameter_widgets ); void OpenGRFParameterWindow(bool is_baseset, GRFConfig &c, bool editable) { - CloseWindowByClass(WC_GRF_PARAMETERS); + CloseWindowByClass(WindowClass::NewGRFParameters); new NewGRFParametersWindow(_newgrf_parameters_desc, is_baseset, c, editable); } @@ -569,7 +569,7 @@ struct NewGRFTextfileWindow : public TextfileWindow { void ShowNewGRFTextfileWindow(Window *parent, TextfileType file_type, const GRFConfig *c) { - parent->CloseChildWindowById(WC_TEXTFILE, file_type); + parent->CloseChildWindowById(WindowClass::Textfile, file_type); new NewGRFTextfileWindow(parent, file_type, c); } @@ -662,8 +662,8 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { void Close([[maybe_unused]] int data = 0) override { - CloseWindowByClass(WC_GRF_PARAMETERS); - CloseWindowByClass(WC_SAVE_PRESET); + CloseWindowByClass(WindowClass::NewGRFParameters); + CloseWindowByClass(WindowClass::SavePreset); if (this->editable && this->modified && !this->execute && !_exit_game) { CopyGRFConfigList(this->orig_list, this->actives, true); @@ -718,8 +718,8 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { d->SetParameterDefaults(); } if (this->active_sel == c->get()) { - CloseWindowByClass(WC_GRF_PARAMETERS); - this->CloseChildWindows(WC_TEXTFILE); + CloseWindowByClass(WindowClass::NewGRFParameters); + this->CloseChildWindows(WindowClass::Textfile); this->active_sel = nullptr; } *c = std::move(d); @@ -943,7 +943,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { list.push_back(MakeDropDownListStringItem(std::string{this->grf_presets[i]}, i)); } - this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window + this->CloseChildWindows(WindowClass::QueryString); // Remove the parameter query window ShowDropDownList(this, std::move(list), this->preset, WID_NS_PRESET_LIST, 0, DropDownOption::Filterable); break; } @@ -966,7 +966,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->grf_presets = GetGRFPresetList(); this->preset = -1; this->InvalidateData(); - this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window + this->CloseChildWindows(WindowClass::QueryString); // Remove the parameter query window break; case WID_NS_MOVE_UP: { // Move GRF up @@ -1008,8 +1008,8 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->active_sel = nullptr; } if (this->active_sel != old_sel) { - CloseWindowByClass(WC_GRF_PARAMETERS); - this->CloseChildWindows(WC_TEXTFILE); + CloseWindowByClass(WindowClass::NewGRFParameters); + this->CloseChildWindows(WindowClass::Textfile); } this->avail_sel = nullptr; this->avail_pos = -1; @@ -1025,8 +1025,8 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { case WID_NS_REMOVE: { // Remove GRF if (this->active_sel == nullptr || !this->editable) break; - CloseWindowByClass(WC_GRF_PARAMETERS); - this->CloseChildWindows(WC_TEXTFILE); + CloseWindowByClass(WindowClass::NewGRFParameters); + this->CloseChildWindows(WindowClass::Textfile); /* Choose the next GRF file to be the selected file. */ int pos = this->GetCurrentActivePosition(); @@ -1061,9 +1061,9 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { auto it = this->vscroll2->GetScrolledItemFromWidget(this->avails, pt.y, this, WID_NS_AVAIL_LIST, WidgetDimensions::scaled.framerect.top); this->active_sel = nullptr; - CloseWindowByClass(WC_GRF_PARAMETERS); + CloseWindowByClass(WindowClass::NewGRFParameters); if (it != std::end(this->avails)) { - if (this->avail_sel != *it) this->CloseChildWindows(WC_TEXTFILE); + if (this->avail_sel != *it) this->CloseChildWindows(WindowClass::Textfile); this->avail_sel = *it; this->avail_pos = static_cast(std::distance(std::begin(this->avails), it)); } @@ -1092,7 +1092,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { NewGRFConfirmationCallback ); - this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window + this->CloseChildWindows(WindowClass::QueryString); // Remove the parameter query window break; case WID_NS_VIEW_PARAMETERS: @@ -1117,7 +1117,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { if (!_network_available) { ShowErrorMessage(GetEncodedString(STR_NETWORK_ERROR_NOTAVAILABLE), {}, WL_ERROR); } else { - this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window + this->CloseChildWindows(WindowClass::QueryString); // Remove the parameter query window ShowMissingContentWindow(this->actives); } @@ -1132,11 +1132,11 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { void OnNewGRFsScanned() override { - if (this->active_sel == nullptr) this->CloseChildWindows(WC_TEXTFILE); + if (this->active_sel == nullptr) this->CloseChildWindows(WindowClass::Textfile); this->avail_sel = nullptr; this->avail_pos = -1; this->avails.ForceRebuild(); - this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window + this->CloseChildWindows(WindowClass::QueryString); // Remove the parameter query window } void OnDropdownSelect(WidgetID widget, int index, int) override @@ -1153,8 +1153,8 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->avails.ForceRebuild(); ResetObjectToPlace(); - CloseWindowByClass(WC_GRF_PARAMETERS); - this->CloseChildWindows(WC_TEXTFILE); + CloseWindowByClass(WindowClass::NewGRFParameters); + this->CloseChildWindows(WindowClass::Textfile); this->active_sel = nullptr; this->InvalidateData(GOID_NEWGRF_CHANGES_MADE); } @@ -1299,8 +1299,8 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { if (this->avail_pos >= 0) { this->active_sel = nullptr; - CloseWindowByClass(WC_GRF_PARAMETERS); - if (this->avail_sel != this->avails[this->avail_pos]) this->CloseChildWindows(WC_TEXTFILE); + CloseWindowByClass(WindowClass::NewGRFParameters); + if (this->avail_sel != this->avails[this->avail_pos]) this->CloseChildWindows(WindowClass::Textfile); this->avail_sel = this->avails[this->avail_pos]; this->vscroll2->ScrollTowards(this->avail_pos); this->InvalidateData(0); @@ -1463,7 +1463,7 @@ private: { if (this->avail_sel == nullptr || !this->editable || this->avail_sel->flags.Test(GRFConfigFlag::Invalid)) return false; - this->CloseChildWindows(WC_TEXTFILE); + this->CloseChildWindows(WindowClass::Textfile); /* Get number of non-static NewGRFs. */ size_t count = std::ranges::count_if(this->actives, [](const auto &gc) { return !gc->flags.Test(GRFConfigFlag::Static); }); @@ -1907,7 +1907,7 @@ static constexpr std::initializer_list _nested_newgrf_widgets = { /** Window definition of the manage newgrfs window. */ static WindowDesc _newgrf_desc( WindowPosition::Center, "settings_newgrf", 300, 263, - WC_GAME_OPTIONS, WC_NONE, + WindowClass::GameOptions, WindowClass::None, {}, _nested_newgrf_widgets ); @@ -1920,8 +1920,8 @@ static WindowDesc _newgrf_desc( static void NewGRFConfirmationCallback(Window *w, bool confirmed) { if (confirmed) { - CloseWindowByClass(WC_GRF_PARAMETERS); - w->CloseChildWindows(WC_TEXTFILE); + CloseWindowByClass(WindowClass::NewGRFParameters); + w->CloseChildWindows(WindowClass::Textfile); NewGRFWindow *nw = dynamic_cast(w); assert(nw != nullptr); @@ -1951,7 +1951,7 @@ static void NewGRFConfirmationCallback(Window *w, bool confirmed) w->InvalidateData(); ReInitAllWindows(false); - CloseWindowByClass(WC_BUILD_OBJECT); + CloseWindowByClass(WindowClass::BuildObject); } } @@ -1967,7 +1967,7 @@ static void NewGRFConfirmationCallback(Window *w, bool confirmed) */ void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfigList &config) { - CloseWindowByClass(WC_GAME_OPTIONS); + CloseWindowByClass(WindowClass::GameOptions); new NewGRFWindow(_newgrf_desc, editable, show_params, exec_changes, config); } @@ -1998,7 +1998,7 @@ static constexpr std::initializer_list _nested_save_preset_widgets /** Window description of the preset save window. */ static WindowDesc _save_preset_desc( WindowPosition::Center, "save_preset", 140, 110, - WC_SAVE_PRESET, WC_GAME_OPTIONS, + WindowClass::SavePreset, WindowClass::GameOptions, WindowDefaultFlag::Modal, _nested_save_preset_widgets ); @@ -2097,7 +2097,7 @@ struct SavePresetWindow : public Window { } case WID_SVP_SAVE: { - Window *w = FindWindowById(WC_GAME_OPTIONS, GameOptionsWindowNumber::NewGRFState); + Window *w = FindWindowById(WindowClass::GameOptions, GameOptionsWindowNumber::NewGRFState); if (w != nullptr) { auto text = this->presetname_editbox.text.GetText(); if (!text.empty()) w->OnQueryTextFinished(std::string{text}); @@ -2120,7 +2120,7 @@ struct SavePresetWindow : public Window { */ static void ShowSavePresetWindow(std::string_view initial_text) { - CloseWindowByClass(WC_SAVE_PRESET); + CloseWindowByClass(WindowClass::SavePreset); new SavePresetWindow(initial_text); } @@ -2139,7 +2139,7 @@ static constexpr std::initializer_list _nested_scan_progress_widget /** Description of the widgets and other settings of the window. */ static WindowDesc _scan_progress_desc( WindowPosition::Center, {}, 0, 0, - WC_MODAL_PROGRESS, WC_NONE, + WindowClass::ModalProgress, WindowClass::None, {}, _nested_scan_progress_widgets ); @@ -2219,7 +2219,7 @@ struct ScanProgressWindow : public Window { */ void UpdateNewGRFScanStatus(uint num, std::string &&name) { - ScanProgressWindow *w = dynamic_cast(FindWindowByClass(WC_MODAL_PROGRESS)); + ScanProgressWindow *w = dynamic_cast(FindWindowByClass(WindowClass::ModalProgress)); if (w == nullptr) w = new ScanProgressWindow(); w->UpdateNewGRFScanStatus(num, std::move(name)); } diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 9f4f159a23..e6eeecb8bc 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -674,7 +674,7 @@ void IndustryProductionCallback(Industry *ind, int reason) SB(object.callback_param2, 24, 8, again); } - SetWindowDirty(WC_INDUSTRY_VIEW, ind->index); + SetWindowDirty(WindowClass::IndustryView, ind->index); } /** diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 11b6815ec0..9cbe1f7fe8 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -129,7 +129,7 @@ static constexpr std::initializer_list _nested_normal_news_widgets /** Window definition for the normal news window. */ static WindowDesc _normal_news_desc( WindowPosition::Manual, {}, 0, 0, - WC_NEWS_WINDOW, WC_NONE, + WindowClass::News, WindowClass::None, {}, _nested_normal_news_widgets ); @@ -178,7 +178,7 @@ static constexpr std::initializer_list _nested_vehicle_news_widgets /** Window definition for the vehicle news window. */ static WindowDesc _vehicle_news_desc( WindowPosition::Manual, {}, 0, 0, - WC_NEWS_WINDOW, WC_NONE, + WindowClass::News, WindowClass::None, {}, _nested_vehicle_news_widgets ); @@ -224,7 +224,7 @@ static constexpr std::initializer_list _nested_company_news_widgets /** Window definition for the company news window. */ static WindowDesc _company_news_desc( WindowPosition::Manual, {}, 0, 0, - WC_NEWS_WINDOW, WC_NONE, + WindowClass::News, WindowClass::None, {}, _nested_company_news_widgets ); @@ -259,7 +259,7 @@ static constexpr std::initializer_list _nested_thin_news_widgets = /** Window definition for the thin news window. */ static WindowDesc _thin_news_desc( WindowPosition::Manual, {}, 0, 0, - WC_NEWS_WINDOW, WC_NONE, + WindowClass::News, WindowClass::None, {}, _nested_thin_news_widgets ); @@ -298,7 +298,7 @@ static constexpr std::initializer_list _nested_small_news_widgets = /** Window definition for the small news window. */ static WindowDesc _small_news_desc( WindowPosition::Manual, {}, 0, 0, - WC_NEWS_WINDOW, WC_NONE, + WindowClass::News, WindowClass::None, {}, _nested_small_news_widgets ); @@ -367,9 +367,9 @@ struct NewsWindow : Window { NewsWindow(WindowDesc &desc, const NewsItem *ni) : Window(desc), ni(ni) { NewsWindow::duration = 16650; - const Window *w = FindWindowByClass(WC_SEND_NETWORK_MSG); + const Window *w = FindWindowByClass(WindowClass::NetworkChat); this->chat_height = (w != nullptr) ? w->height : 0; - this->status_height = FindWindowById(WC_STATUS_BAR, 0)->height; + this->status_height = FindWindowById(WindowClass::Statusbar, 0)->height; this->flags.Set(WindowFlag::DisableVpScroll); @@ -718,7 +718,7 @@ static void ShowTicker(NewsIterator ni) if (_settings_client.sound.news_ticker) SndPlayFx(SND_16_NEWS_TICKER); _statusbar_news = ni; - InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SHOW_TICKER); + InvalidateWindowData(WindowClass::Statusbar, 0, SBI_SHOW_TICKER); } /** Initialize the news-items data structures */ @@ -756,7 +756,7 @@ static bool ReadyForNextNewsItem() if (_forced_news == std::end(_news) && _current_news == std::end(_news)) return true; /* neither newsticker nor newspaper are running */ - return (NewsWindow::duration <= 0 || FindWindowById(WC_NEWS_WINDOW, 0) == nullptr); + return (NewsWindow::duration <= 0 || FindWindowById(WindowClass::News, 0) == nullptr); } /** Move to the next ticker item */ @@ -765,7 +765,7 @@ static void MoveToNextTickerItem() /* There is no status bar, so no reason to show news; * especially important with the end game screen when * there is no status bar but possible news. */ - if (FindWindowById(WC_STATUS_BAR, 0) == nullptr) return; + if (FindWindowById(WindowClass::Statusbar, 0) == nullptr) return; /* No news to move to. */ if (std::empty(_news)) return; @@ -781,7 +781,7 @@ static void MoveToNextTickerItem() switch (_news_type_data[to_underlying(type)].GetDisplay()) { default: NOT_REACHED(); case NewsDisplay::Off: // Show nothing only a small reminder in the status bar. - InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SHOW_REMINDER); + InvalidateWindowData(WindowClass::Statusbar, 0, SBI_SHOW_REMINDER); return; case NewsDisplay::Summary: // Show ticker. @@ -800,9 +800,9 @@ static void MoveToNextNewsItem() /* There is no status bar, so no reason to show news; * especially important with the end game screen when * there is no status bar but possible news. */ - if (FindWindowById(WC_STATUS_BAR, 0) == nullptr) return; + if (FindWindowById(WindowClass::Statusbar, 0) == nullptr) return; - CloseWindowById(WC_NEWS_WINDOW, 0); // close the newspapers window if shown + CloseWindowById(WindowClass::News, 0); // close the newspapers window if shown _forced_news = std::end(_news); /* No news to move to. */ @@ -865,7 +865,7 @@ static std::list::iterator DeleteNewsItem(std::list::iterato if (update_statusbar_news) { /* About to remove the currently displayed item (ticker, or just a reminder) */ - InvalidateWindowData(WC_STATUS_BAR, 0, SBI_NEWS_DELETED); // invalidate the statusbar + InvalidateWindowData(WindowClass::Statusbar, 0, SBI_NEWS_DELETED); // invalidate the statusbar MoveToNextTickerItem(); } @@ -928,7 +928,7 @@ void AddNewsItem(EncodedString &&headline, NewsType type, NewsStyle style, NewsF DeleteNewsItem(std::prev(std::end(_news))); } - InvalidateWindowData(WC_MESSAGE_HISTORY, 0); + InvalidateWindowData(WindowClass::MessageHistory, 0); } /** @@ -1010,7 +1010,7 @@ void DeleteNews(Tpredicate predicate) ++it; } } - if (dirty) InvalidateWindowData(WC_MESSAGE_HISTORY, 0); + if (dirty) InvalidateWindowData(WindowClass::MessageHistory, 0); } template @@ -1133,13 +1133,13 @@ static void ShowNewsMessage(NewsIterator ni) assert(!std::empty(_news)); /* Delete the news window */ - CloseWindowById(WC_NEWS_WINDOW, 0); + CloseWindowById(WindowClass::News, 0); /* setup forced news item */ _forced_news = ni; if (_forced_news != std::end(_news)) { - CloseWindowById(WC_NEWS_WINDOW, 0); + CloseWindowById(WindowClass::News, 0); ShowNewspaper(&*ni); } } @@ -1150,7 +1150,7 @@ static void ShowNewsMessage(NewsIterator ni) */ bool HideActiveNewsMessage() { - NewsWindow *w = dynamic_cast(FindWindowById(WC_NEWS_WINDOW, 0)); + NewsWindow *w = dynamic_cast(FindWindowById(WindowClass::News, 0)); if (w == nullptr) return false; w->Close(); return true; @@ -1170,7 +1170,7 @@ void ShowLastNewsMessage() * Treat this as if _forced_news reached the oldest news; so, wrap around and start anew with the latest. */ ni = std::begin(_news); } else { - const Window *w = FindWindowById(WC_NEWS_WINDOW, 0); + const Window *w = FindWindowById(WindowClass::News, 0); ni = (w == nullptr || (std::next(_current_news) == std::end(_news))) ? _current_news : std::next(_current_news); } } else if (std::next(_forced_news) == std::end(_news)) { @@ -1317,7 +1317,7 @@ static constexpr std::initializer_list _nested_message_history = { /** Window definition for the news message history window. */ static WindowDesc _message_history_desc( WindowPosition::Automatic, "list_news", 400, 140, - WC_MESSAGE_HISTORY, WC_NONE, + WindowClass::MessageHistory, WindowClass::None, {}, _nested_message_history ); @@ -1325,6 +1325,6 @@ static WindowDesc _message_history_desc( /** Display window with news messages history */ void ShowMessageHistory() { - CloseWindowById(WC_MESSAGE_HISTORY, 0); + CloseWindowById(WindowClass::MessageHistory, 0); new MessageHistoryWindow(_message_history_desc); } diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index 47d5addc83..b9e0dc612b 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -350,7 +350,7 @@ CommandCost CmdBuildObject(DoCommandFlags flags, TileIndex tile, ObjectType type if (flags.Test(DoCommandFlag::Execute)) { hq_score = UpdateCompanyRatingAndValue(c, false); c->location_of_HQ = tile; - SetWindowDirty(WC_COMPANY, c->index); + SetWindowDirty(WindowClass::Company, c->index); } break; } @@ -592,7 +592,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlags flags) Company *c = Company::Get(GetTileOwner(tile)); if (flags.Test(DoCommandFlag::Execute)) { c->location_of_HQ = INVALID_TILE; // reset HQ position - SetWindowDirty(WC_COMPANY, c->index); + SetWindowDirty(WindowClass::Company, c->index); CargoPacket::InvalidateAllFrom({c->index, SourceType::Headquarters}); } @@ -605,7 +605,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlags flags) if (flags.Test(DoCommandFlag::Execute)) { Town *town = o->town; town->statues.Reset(GetTileOwner(tile)); - SetWindowDirty(WC_TOWN_AUTHORITY, town->index); + SetWindowDirty(WindowClass::TownAuthority, town->index); } break; @@ -959,7 +959,7 @@ static void ChangeTileOwner_Object(TileIndex tile, Owner old_owner, Owner new_ow do_clear = true; } - SetWindowDirty(WC_TOWN_AUTHORITY, t->index); + SetWindowDirty(WindowClass::TownAuthority, t->index); } else { do_clear = true; } diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 96b2739c4d..0898603da3 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -411,7 +411,7 @@ static constexpr std::initializer_list _nested_build_object_widgets /** Window definition for the build object window. */ static WindowDesc _build_object_desc( WindowPosition::Automatic, "build_object", 0, 0, - WC_BUILD_OBJECT, WC_BUILD_TOOLBAR, + WindowClass::BuildObject, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_build_object_widgets, &BuildObjectWindow::hotkeys diff --git a/src/openttd.cpp b/src/openttd.cpp index 9cce15312d..047c4abe06 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1178,13 +1178,13 @@ void SwitchToMode(SwitchMode new_mode) if (SaveOrLoad(_file_to_saveload.name, SaveLoadOperation::Save, DetailedFileType::GameFile, Subdirectory::None) != SaveLoadResult::Ok) { ShowErrorMessage(GetSaveLoadErrorType(), GetSaveLoadErrorMessage(), WL_ERROR); } else { - CloseWindowById(WC_SAVELOAD, 0); + CloseWindowById(WindowClass::SaveLoad, 0); } break; case SM_SAVE_HEIGHTMAP: // Save heightmap. MakeHeightmapScreenshot(_file_to_saveload.name); - CloseWindowById(WC_SAVELOAD, 0); + CloseWindowById(WindowClass::SaveLoad, 0); break; case SM_GENRANDLAND: // Generate random land within scenario editor @@ -1290,13 +1290,13 @@ static IntervalTimer _autosave_interval({std::chrono::millise _pause_mode.Reset(PauseMode::CommandDuringPause); _do_autosave = true; - SetWindowDirty(WC_STATUS_BAR, 0); + SetWindowDirty(WindowClass::Statusbar, 0); static FiosNumberedSaveName _autosave_ctr("autosave"); DoAutoOrNetsave(_autosave_ctr); _do_autosave = false; - SetWindowDirty(WC_STATUS_BAR, 0); + SetWindowDirty(WindowClass::Statusbar, 0); }); /** diff --git a/src/order_backup.cpp b/src/order_backup.cpp index 5617c62f23..66067e29bc 100644 --- a/src/order_backup.cpp +++ b/src/order_backup.cpp @@ -70,7 +70,7 @@ void OrderBackup::DoRestore(Vehicle *v) } else if (!this->orders.empty() && OrderList::CanAllocateItem()) { v->orders = OrderList::Create(std::move(this->orders), v); /* Make sure buoys/oil rigs are updated in the station list. */ - InvalidateWindowClassesData(WC_STATION_LIST, 0); + InvalidateWindowClassesData(WindowClass::StationList, 0); } /* Remove backed up name if it's no longer unique. */ diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 4e56324b9c..14d69a05cb 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -212,17 +212,17 @@ uint16_t Order::MapOldOrder() const */ void InvalidateVehicleOrder(const Vehicle *v, int data) { - InvalidateWindowData(WC_VEHICLE_VIEW, v->index); + InvalidateWindowData(WindowClass::VehicleView, v->index); if (data != 0) { /* Calls SetDirty() too */ - InvalidateWindowData(WC_VEHICLE_ORDERS, v->index, data); - InvalidateWindowData(WC_VEHICLE_TIMETABLE, v->index, data); + InvalidateWindowData(WindowClass::VehicleOrders, v->index, data); + InvalidateWindowData(WindowClass::VehicleTimetable, v->index, data); return; } - SetWindowDirty(WC_VEHICLE_ORDERS, v->index); - SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index); + SetWindowDirty(WindowClass::VehicleOrders, v->index); + SetWindowDirty(WindowClass::VehicleTimetable, v->index); } /** @@ -297,7 +297,7 @@ void OrderList::FreeChain(bool keep_orderlist) if (order.IsType(OT_GOTO_STATION) || order.IsType(OT_GOTO_WAYPOINT)) { BaseStation *bs = BaseStation::GetIfValid(order.GetDestination().ToStationID()); if (bs != nullptr && bs->owner == OWNER_NONE) { - InvalidateWindowClassesData(WC_STATION_LIST, 0); + InvalidateWindowClassesData(WindowClass::StationList, 0); break; } } @@ -426,7 +426,7 @@ void OrderList::InsertOrderAt(Order &&order, VehicleOrderID index) * the list of stations. So, we need to invalidate that window if needed. */ if (new_order->IsType(OT_GOTO_STATION) || new_order->IsType(OT_GOTO_WAYPOINT)) { BaseStation *bs = BaseStation::Get(new_order->GetDestination().ToStationID()); - if (bs->owner == OWNER_NONE) InvalidateWindowClassesData(WC_STATION_LIST, 0); + if (bs->owner == OWNER_NONE) InvalidateWindowClassesData(WindowClass::StationList, 0); } } @@ -1059,8 +1059,8 @@ CommandCost CmdSkipToOrder(DoCommandFlags flags, VehicleID veh_id, VehicleOrderI InvalidateVehicleOrder(v, VIWD_MODIFY_ORDERS); /* We have an aircraft/ship, they have a mini-schedule, so update them all */ - if (v->type == VehicleType::Aircraft) SetWindowClassesDirty(WC_AIRCRAFT_LIST); - if (v->type == VehicleType::Ship) SetWindowClassesDirty(WC_SHIPS_LIST); + if (v->type == VehicleType::Aircraft) SetWindowClassesDirty(WindowClass::AircraftList); + if (v->type == VehicleType::Ship) SetWindowClassesDirty(WindowClass::ShipList); } return CommandCost(); @@ -1773,7 +1773,7 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool if ((v->type == VehicleType::Aircraft && v->current_order.IsType(OT_GOTO_DEPOT) && !hangar ? OT_GOTO_STATION : v->current_order.GetType()) == type && (!hangar || v->type == VehicleType::Aircraft) && v->current_order.GetDestination() == destination) { v->current_order.MakeDummy(); - InvalidateWindowData(WC_VEHICLE_VIEW, v->index); + InvalidateWindowData(WindowClass::VehicleView, v->index); } if (v->orders == nullptr) continue; diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 0002767b71..55a46a45de 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -1645,7 +1645,7 @@ static constexpr std::initializer_list _nested_orders_train_widgets /** Window definition for the train orders window. */ static WindowDesc _orders_train_desc( WindowPosition::Automatic, "view_vehicle_orders_train", 384, 100, - WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, + WindowClass::VehicleOrders, WindowClass::VehicleView, WindowDefaultFlag::Construction, _nested_orders_train_widgets, &OrdersWindow::hotkeys @@ -1719,7 +1719,7 @@ static constexpr std::initializer_list _nested_orders_widgets = { /** Window definition for the orders window for road vehicles, ships and aircraft. */ static WindowDesc _orders_desc( WindowPosition::Automatic, "view_vehicle_orders", 384, 100, - WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, + WindowClass::VehicleOrders, WindowClass::VehicleView, WindowDefaultFlag::Construction, _nested_orders_widgets, &OrdersWindow::hotkeys @@ -1747,7 +1747,7 @@ static constexpr std::initializer_list _nested_other_orders_widgets /** Window definition for the orders window for other companies. */ static WindowDesc _other_orders_desc( WindowPosition::Automatic, "view_vehicle_orders_competitor", 384, 86, - WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, + WindowClass::VehicleOrders, WindowClass::VehicleView, WindowDefaultFlag::Construction, _nested_other_orders_widgets, &OrdersWindow::hotkeys @@ -1755,9 +1755,9 @@ static WindowDesc _other_orders_desc( void ShowOrdersWindow(const Vehicle *v) { - CloseWindowById(WC_VEHICLE_DETAILS, v->index, false); - CloseWindowById(WC_VEHICLE_TIMETABLE, v->index, false); - if (BringWindowToFrontById(WC_VEHICLE_ORDERS, v->index) != nullptr) return; + CloseWindowById(WindowClass::VehicleDetails, v->index, false); + CloseWindowById(WindowClass::VehicleTimetable, v->index, false); + if (BringWindowToFrontById(WindowClass::VehicleOrders, v->index) != nullptr) return; /* Using a different WindowDescs for _local_company causes problems. * Due to this we have to close order windows in ChangeWindowOwner/CloseCompanyWindows, diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 2156bba7a6..e919faed32 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -341,7 +341,7 @@ static constexpr std::initializer_list _nested_osk_widgets = { /** Window definition for the on screen keyboard window. */ static WindowDesc _osk_desc( WindowPosition::Center, {}, 0, 0, - WC_OSK, WC_NONE, + WindowClass::OnScreenKeyboard, WindowClass::None, {}, _nested_osk_widgets ); @@ -391,7 +391,7 @@ void GetKeyboardLayout() */ void ShowOnScreenKeyboard(Window *parent, WidgetID button) { - CloseWindowById(WC_OSK, 0); + CloseWindowById(WindowClass::OnScreenKeyboard, 0); GetKeyboardLayout(); new OskWindow(_osk_desc, parent, button); @@ -406,7 +406,7 @@ void ShowOnScreenKeyboard(Window *parent, WidgetID button) */ void UpdateOSKOriginalText(const Window *parent, WidgetID button) { - OskWindow *osk = dynamic_cast(FindWindowById(WC_OSK, 0)); + OskWindow *osk = dynamic_cast(FindWindowById(WindowClass::OnScreenKeyboard, 0)); if (osk == nullptr || osk->parent != parent || osk->text_btn != button) return; osk->orig_str = osk->qs->text.GetText(); @@ -422,6 +422,6 @@ void UpdateOSKOriginalText(const Window *parent, WidgetID button) */ bool IsOSKOpenedFor(const Window *w, WidgetID button) { - OskWindow *osk = dynamic_cast(FindWindowById(WC_OSK, 0)); + OskWindow *osk = dynamic_cast(FindWindowById(WindowClass::OnScreenKeyboard, 0)); return osk != nullptr && osk->parent == w && osk->text_btn == button; } diff --git a/src/picker_gui.cpp b/src/picker_gui.cpp index 919966a8f3..7fd1a4fc0c 100644 --- a/src/picker_gui.cpp +++ b/src/picker_gui.cpp @@ -464,7 +464,7 @@ void PickerWindow::OnClick(Point pt, WidgetID widget, int) this->InvalidateData({PickerInvalidation::Type, PickerInvalidation::Position, PickerInvalidation::Validate}); } SndClickBeep(); - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); break; } @@ -522,13 +522,13 @@ void PickerWindow::OnClick(Point pt, WidgetID widget, int) this->InvalidateData(PickerInvalidation::Position); } SndClickBeep(); - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); break; } case WID_PW_COLEC_LIST: { ShowDropDownList(this, this->BuildCollectionDropDownList(), -1, widget, 0, DropDownOption::Filterable); - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); break; } @@ -539,7 +539,7 @@ void PickerWindow::OnClick(Point pt, WidgetID widget, int) case WID_PW_COLEC_RENAME: if (this->callbacks.saved.contains(this->callbacks.sel_collection)) { - CloseChildWindows(WC_CONFIRM_POPUP_QUERY); + CloseChildWindows(WindowClass::ConfirmPopupQuery); this->callbacks.edit_collection = this->callbacks.sel_collection; this->callbacks.rename_collection = true; ShowQueryString(this->callbacks.sel_collection, STR_PICKER_COLLECTION_RENAME_QUERY, MAX_LENGTH_GROUP_NAME_CHARS, this, CS_ALPHANUMERAL, QueryStringFlag::LengthIsInChars); @@ -548,7 +548,7 @@ void PickerWindow::OnClick(Point pt, WidgetID widget, int) case WID_PW_COLEC_DELETE: if (this->callbacks.saved.contains(this->callbacks.sel_collection)) { - CloseChildWindows(WC_QUERY_STRING); + CloseChildWindows(WindowClass::QueryString); this->callbacks.edit_collection = this->callbacks.sel_collection; this->inactive.contains(this->callbacks.sel_collection) ? @@ -628,7 +628,7 @@ void PickerWindow::OnDropdownSelect(WidgetID widget, int index, int click_result if (reopen) { ReplaceDropDownList(this, BuildBadgeClassConfigurationList(this->badge_classes, 1, {}, Colours::DarkGreen), -1); } else { - this->CloseChildWindows(WC_DROPDOWN_MENU); + this->CloseChildWindows(WindowClass::DropdownMenu); } /* We need to refresh if a filter is removed. */ @@ -1009,10 +1009,10 @@ std::unique_ptr MakePickerTypeWidgets() void InvalidateAllPickerWindows() { - InvalidateWindowClassesData(WC_BUS_STATION, PickerWindow::PICKER_INVALIDATION_ALL); - InvalidateWindowClassesData(WC_TRUCK_STATION, PickerWindow::PICKER_INVALIDATION_ALL); - InvalidateWindowClassesData(WC_SELECT_STATION, PickerWindow::PICKER_INVALIDATION_ALL); - InvalidateWindowClassesData(WC_BUILD_WAYPOINT, PickerWindow::PICKER_INVALIDATION_ALL); - InvalidateWindowClassesData(WC_BUILD_OBJECT, PickerWindow::PICKER_INVALIDATION_ALL); - InvalidateWindowClassesData(WC_BUILD_HOUSE, PickerWindow::PICKER_INVALIDATION_ALL); + InvalidateWindowClassesData(WindowClass::BuildBusStation, PickerWindow::PICKER_INVALIDATION_ALL); + InvalidateWindowClassesData(WindowClass::BuildTruckStation, PickerWindow::PICKER_INVALIDATION_ALL); + InvalidateWindowClassesData(WindowClass::JoinStation, PickerWindow::PICKER_INVALIDATION_ALL); + InvalidateWindowClassesData(WindowClass::BuildWaypoint, PickerWindow::PICKER_INVALIDATION_ALL); + InvalidateWindowClassesData(WindowClass::BuildObject, PickerWindow::PICKER_INVALIDATION_ALL); + InvalidateWindowClassesData(WindowClass::BuildHouse, PickerWindow::PICKER_INVALIDATION_ALL); } diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index a23e29bf74..faa07003af 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1641,8 +1641,8 @@ CommandCost CmdConvertRail(DoCommandFlags flags, TileIndex tile, TileIndex area_ YapfNotifyTrackLayoutChange(tile, GetRailDepotTrack(tile)); /* Update build vehicle window related to this depot */ - InvalidateWindowData(WC_VEHICLE_DEPOT, tile); - InvalidateWindowData(WC_BUILD_VEHICLE, tile); + InvalidateWindowData(WindowClass::VehicleDepot, tile); + InvalidateWindowData(WindowClass::BuildVehicle, tile); } found_convertible_track = true; cost.AddCost(RailConvertCost(type, totype)); @@ -3016,7 +3016,7 @@ static VehicleEnterTileStates VehicleEnterTile_Rail(Vehicle *v, TileIndex tile, } v->tile = tile; - InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); + InvalidateWindowData(WindowClass::VehicleDepot, v->tile); return VehicleEnterTileState::EnteredWormhole; } diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index e03348006c..51589ff857 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -275,7 +275,7 @@ static void GenericPlaceSignals(TileIndex tile) } } - if (FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr) { + if (FindWindowById(WindowClass::BuildSignal, 0) != nullptr) { /* signal GUI is used */ Command::Post(_convert_signal_button ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL, tile, track, _cur_signal_type, _cur_signal_variant, _convert_signal_button, false, _ctrl_pressed, cycle_start, cycle_end, 0, 0); @@ -325,7 +325,7 @@ void CcBuildRailTunnel(Commands, const CommandCost &result, TileIndex tile) */ static void ToggleRailButton_Remove(Window *w) { - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); w->ToggleWidgetLoweredState(WID_RAT_REMOVE); w->SetWidgetDirty(WID_RAT_REMOVE); _remove_button_clicked = w->IsWidgetLowered(WID_RAT_REMOVE); @@ -431,7 +431,7 @@ static void HandleAutoSignalPlacement() Command::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, _ctrl_pressed); } else { - bool sig_gui = FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr; + bool sig_gui = FindWindowById(WindowClass::BuildSignal, 0) != nullptr; SignalType sigtype = sig_gui ? _cur_signal_type : _settings_client.gui.default_signal_type; SignalVariant sigvar = sig_gui ? _cur_signal_variant : (TimerGameCalendar::year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC); Command::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL, @@ -459,8 +459,8 @@ struct BuildRailToolbarWindow : Window { { if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) SetViewportCatchmentStation(nullptr, true); if (this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT)) SetViewportCatchmentWaypoint(nullptr, true); - if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false); - CloseWindowById(WC_SELECT_STATION, 0); + if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WindowClass::ScenarioGenerateLandscape, 0, false); + CloseWindowById(WindowClass::JoinStation, 0); this->Window::Close(); } @@ -484,11 +484,11 @@ struct BuildRailToolbarWindow : Window { bool can_build = CanBuildVehicleInfrastructure(VehicleType::Train); for (const WidgetID widget : can_build_widgets) this->SetWidgetDisabledState(widget, !can_build); if (!can_build) { - CloseWindowById(WC_BUILD_SIGNAL, TRANSPORT_RAIL); - CloseWindowById(WC_BUILD_STATION, TRANSPORT_RAIL); - CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_RAIL); - CloseWindowById(WC_BUILD_WAYPOINT, TRANSPORT_RAIL); - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::BuildSignal, TRANSPORT_RAIL); + CloseWindowById(WindowClass::BuildStation, TRANSPORT_RAIL); + CloseWindowById(WindowClass::BuildDepot, TRANSPORT_RAIL); + CloseWindowById(WindowClass::BuildWaypoint, TRANSPORT_RAIL); + CloseWindowById(WindowClass::JoinStation, 0); } } @@ -736,7 +736,7 @@ struct BuildRailToolbarWindow : Window { void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override { /* no dragging if you have pressed the convert button */ - if (FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr && _convert_signal_button && this->IsWidgetLowered(WID_RAT_BUILD_SIGNALS)) return; + if (FindWindowById(WindowClass::BuildSignal, 0) != nullptr && _convert_signal_button && this->IsWidgetLowered(WID_RAT_BUILD_SIGNALS)) return; VpSelectTilesWithMethod(pt.x, pt.y, select_method); } @@ -817,12 +817,12 @@ struct BuildRailToolbarWindow : Window { this->DisableWidget(WID_RAT_REMOVE); this->SetWidgetDirty(WID_RAT_REMOVE); - CloseWindowById(WC_BUILD_SIGNAL, TRANSPORT_RAIL); - CloseWindowById(WC_BUILD_STATION, TRANSPORT_RAIL); - CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_RAIL); - CloseWindowById(WC_BUILD_WAYPOINT, TRANSPORT_RAIL); - CloseWindowById(WC_SELECT_STATION, 0); - CloseWindowByClass(WC_BUILD_BRIDGE); + CloseWindowById(WindowClass::BuildSignal, TRANSPORT_RAIL); + CloseWindowById(WindowClass::BuildStation, TRANSPORT_RAIL); + CloseWindowById(WindowClass::BuildDepot, TRANSPORT_RAIL); + CloseWindowById(WindowClass::BuildWaypoint, TRANSPORT_RAIL); + CloseWindowById(WindowClass::JoinStation, 0); + CloseWindowByClass(WindowClass::BuildBridge); } void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile) override @@ -861,7 +861,7 @@ struct BuildRailToolbarWindow : Window { /* Update cursor and all sub windows. */ if (_thd.GetCallbackWnd() == this) SetCursor(this->GetCursorForWidget(this->last_user_action), PAL_NONE); - for (WindowClass cls : {WC_BUILD_STATION, WC_BUILD_SIGNAL, WC_BUILD_WAYPOINT, WC_BUILD_DEPOT}) SetWindowDirty(cls, TRANSPORT_RAIL); + for (WindowClass cls : {WindowClass::BuildStation, WindowClass::BuildSignal, WindowClass::BuildWaypoint, WindowClass::BuildDepot}) SetWindowDirty(cls, TRANSPORT_RAIL); return ES_HANDLED; } @@ -945,7 +945,7 @@ static constexpr std::initializer_list _nested_build_rail_widgets = /** Window definition for the rail toolbar. */ static WindowDesc _build_rail_desc( WindowPosition::Manual, "toolbar_rail", 0, 0, - WC_BUILD_TOOLBAR, WC_NONE, + WindowClass::BuildToolbar, WindowClass::None, WindowDefaultFlag::Construction, _nested_build_rail_widgets, &BuildRailToolbarWindow::hotkeys @@ -965,7 +965,7 @@ Window *ShowBuildRailToolbar(RailType railtype) if (!Company::IsValidID(_local_company)) return nullptr; if (!ValParamRailType(railtype)) return nullptr; - CloseWindowByClass(WC_BUILD_TOOLBAR); + CloseWindowByClass(WindowClass::BuildToolbar); _cur_railtype = railtype; _remove_button_clicked = false; return new BuildRailToolbarWindow(_build_rail_desc, railtype); @@ -1155,7 +1155,7 @@ public: void Close([[maybe_unused]] int data = 0) override { - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); this->PickerWindow::Close(); } @@ -1286,7 +1286,7 @@ public: this->LowerWidget(WID_BRAS_PLATFORM_DIR_X + _station_gui.axis); SndClickBeep(); this->SetDirty(); - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); break; case WID_BRAS_PLATFORM_NUM_1: @@ -1318,7 +1318,7 @@ public: this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN); SndClickBeep(); this->SetDirty(); - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); break; } @@ -1351,7 +1351,7 @@ public: this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN); SndClickBeep(); this->SetDirty(); - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); break; } @@ -1385,7 +1385,7 @@ public: this->SetWidgetLoweredState(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN, !_settings_client.gui.station_dragdrop); SndClickBeep(); this->SetDirty(); - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); break; } @@ -1419,7 +1419,7 @@ public: static EventState BuildRailStationGlobalHotkeys(int hotkey) { if (_game_mode == GM_MENU) return ES_NOT_HANDLED; - Window *w = ShowStationBuilder(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL)); + Window *w = ShowStationBuilder(FindWindowById(WindowClass::BuildToolbar, TRANSPORT_RAIL)); if (w == nullptr) return ES_NOT_HANDLED; return w->OnHotkey(hotkey); } @@ -1485,7 +1485,7 @@ static constexpr std::initializer_list _nested_station_builder_widg /** High level window description of the station-build window (default & newGRF) */ static WindowDesc _station_builder_desc( WindowPosition::Automatic, "build_station_rail", 0, 0, - WC_BUILD_STATION, WC_BUILD_TOOLBAR, + WindowClass::BuildStation, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_station_builder_widgets, &BuildRailStationWindow::hotkeys @@ -1626,7 +1626,7 @@ public: /* If 'remove' button of rail build toolbar is active, disable it. */ if (_remove_button_clicked) { - Window *w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL); + Window *w = FindWindowById(WindowClass::BuildToolbar, TRANSPORT_RAIL); if (w != nullptr) ToggleRailButton_Remove(w); } @@ -1641,14 +1641,14 @@ public: case WID_BS_DRAG_SIGNALS_DENSITY_DECREASE: if (_settings_client.gui.drag_signals_density > 1) { _settings_client.gui.drag_signals_density--; - SetWindowDirty(WC_GAME_OPTIONS, GameOptionsWindowNumber::GameSettings); + SetWindowDirty(WindowClass::GameOptions, GameOptionsWindowNumber::GameSettings); } break; case WID_BS_DRAG_SIGNALS_DENSITY_INCREASE: if (_settings_client.gui.drag_signals_density < 20) { _settings_client.gui.drag_signals_density++; - SetWindowDirty(WC_GAME_OPTIONS, GameOptionsWindowNumber::GameSettings); + SetWindowDirty(WindowClass::GameOptions, GameOptionsWindowNumber::GameSettings); } break; @@ -1743,7 +1743,7 @@ static constexpr std::initializer_list _nested_signal_builder_widge /** Signal selection window description */ static WindowDesc _signal_builder_desc( WindowPosition::Automatic, {}, 0, 0, - WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, + WindowClass::BuildSignal, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_signal_builder_widgets ); @@ -1826,7 +1826,7 @@ static constexpr std::initializer_list _nested_build_depot_widgets /** Window definition for the build rail depot window. */ static WindowDesc _build_depot_desc( WindowPosition::Automatic, {}, 0, 0, - WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, + WindowClass::BuildDepot, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_build_depot_widgets ); @@ -1947,7 +1947,7 @@ static constexpr std::initializer_list _nested_build_waypoint_widge /** Window definition for the build rail waypoint window. */ static WindowDesc _build_waypoint_desc( WindowPosition::Automatic, "build_waypoint", 0, 0, - WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR, + WindowClass::BuildWaypoint, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_build_waypoint_widgets, &BuildRailWaypointWindow::hotkeys @@ -1979,7 +1979,7 @@ void ReinitGuiAfterToggleElrail(bool disable) { if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) { _last_built_railtype = _cur_railtype = RAILTYPE_RAIL; - BuildRailToolbarWindow *w = dynamic_cast(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL)); + BuildRailToolbarWindow *w = dynamic_cast(FindWindowById(WindowClass::BuildToolbar, TRANSPORT_RAIL)); if (w != nullptr) w->ModifyRailType(_cur_railtype); } MarkWholeScreenDirty(); @@ -2027,7 +2027,7 @@ void SetDefaultRailGui() } _last_built_railtype = _cur_railtype = rt; - BuildRailToolbarWindow *w = dynamic_cast(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL)); + BuildRailToolbarWindow *w = dynamic_cast(FindWindowById(WindowClass::BuildToolbar, TRANSPORT_RAIL)); if (w != nullptr) w->ModifyRailType(_cur_railtype); } @@ -2040,7 +2040,7 @@ void ResetSignalVariant(int32_t) SignalVariant new_variant = (TimerGameCalendar::year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC); if (new_variant != _cur_signal_variant) { - Window *w = FindWindowById(WC_BUILD_SIGNAL, 0); + Window *w = FindWindowById(WindowClass::BuildSignal, 0); if (w != nullptr) { w->SetDirty(); w->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? WID_BS_ELECTRIC_NORM : WID_BS_SEMAPHORE_NORM) + _cur_signal_type); diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 430d520578..b13857ce7c 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -2308,7 +2308,7 @@ static VehicleEnterTileStates VehicleEnterTile_Road(Vehicle *v, TileIndex tile, if (rv->Next() == nullptr) VehicleEnterDepot(rv->First()); rv->tile = tile; - InvalidateWindowData(WC_VEHICLE_DEPOT, rv->tile); + InvalidateWindowData(WindowClass::VehicleDepot, rv->tile); return VehicleEnterTileState::EnteredWormhole; } break; @@ -2579,8 +2579,8 @@ CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_ if (IsRoadDepotTile(tile)) { /* Update build vehicle window related to this depot */ - InvalidateWindowData(WC_VEHICLE_DEPOT, tile); - InvalidateWindowData(WC_BUILD_VEHICLE, tile); + InvalidateWindowData(WindowClass::VehicleDepot, tile); + InvalidateWindowData(WindowClass::BuildVehicle, tile); } } } else { diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 545971e227..65e1000382 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -368,7 +368,7 @@ struct BuildRoadToolbarWindow : Window { void Close([[maybe_unused]] int data = 0) override { if (_game_mode == GM_NORMAL && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true); - if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false); + if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WindowClass::ScenarioGenerateLandscape, 0, false); this->Window::Close(); } @@ -396,10 +396,10 @@ struct BuildRoadToolbarWindow : Window { WID_ROT_BUS_STATION, WID_ROT_TRUCK_STATION); if (!can_build) { - CloseWindowById(WC_BUS_STATION, TRANSPORT_ROAD); - CloseWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD); - CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD); - CloseWindowById(WC_BUILD_WAYPOINT, TRANSPORT_ROAD); + CloseWindowById(WindowClass::BuildBusStation, TRANSPORT_ROAD); + CloseWindowById(WindowClass::BuildTruckStation, TRANSPORT_ROAD); + CloseWindowById(WindowClass::BuildDepot, TRANSPORT_ROAD); + CloseWindowById(WindowClass::BuildWaypoint, TRANSPORT_ROAD); } if (_game_mode != GM_EDITOR) { @@ -603,7 +603,7 @@ struct BuildRoadToolbarWindow : Window { case WID_ROT_REMOVE: if (this->IsWidgetDisabled(WID_ROT_REMOVE)) return; - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); ToggleRoadButton_Remove(this); SndClickBeep(); break; @@ -634,7 +634,7 @@ struct BuildRoadToolbarWindow : Window { this->ModifyRoadType(_cur_roadtype); if (_thd.GetCallbackWnd() == this) SetCursor(this->GetCursorForWidget(this->last_started_action), PAL_NONE); - for (WindowClass cls : {WC_BUS_STATION, WC_TRUCK_STATION, WC_BUILD_WAYPOINT, WC_BUILD_DEPOT}) SetWindowDirty(cls, TRANSPORT_ROAD); + for (WindowClass cls : {WindowClass::BuildBusStation, WindowClass::BuildTruckStation, WindowClass::BuildWaypoint, WindowClass::BuildDepot}) SetWindowDirty(cls, TRANSPORT_ROAD); return ES_HANDLED; } @@ -721,12 +721,12 @@ struct BuildRoadToolbarWindow : Window { this->SetWidgetDirty(WID_ROT_ONE_WAY); } - CloseWindowById(WC_BUS_STATION, TRANSPORT_ROAD); - CloseWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD); - CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD); - CloseWindowById(WC_BUILD_WAYPOINT, TRANSPORT_ROAD); - CloseWindowById(WC_SELECT_STATION, 0); - CloseWindowByClass(WC_BUILD_BRIDGE); + CloseWindowById(WindowClass::BuildBusStation, TRANSPORT_ROAD); + CloseWindowById(WindowClass::BuildTruckStation, TRANSPORT_ROAD); + CloseWindowById(WindowClass::BuildDepot, TRANSPORT_ROAD); + CloseWindowById(WindowClass::BuildWaypoint, TRANSPORT_ROAD); + CloseWindowById(WindowClass::JoinStation, 0); + CloseWindowByClass(WindowClass::BuildBridge); } void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override @@ -997,7 +997,7 @@ static constexpr std::initializer_list _nested_build_road_widgets = /** Window definition for the road toolbar. */ static WindowDesc _build_road_desc( WindowPosition::Manual, "toolbar_road", 0, 0, - WC_BUILD_TOOLBAR, WC_NONE, + WindowClass::BuildToolbar, WindowClass::None, WindowDefaultFlag::Construction, _nested_build_road_widgets, &BuildRoadToolbarWindow::road_hotkeys @@ -1043,7 +1043,7 @@ static constexpr std::initializer_list _nested_build_tramway_widget /** Window definition for the tram toolbar. */ static WindowDesc _build_tramway_desc( WindowPosition::Manual, "toolbar_tramway", 0, 0, - WC_BUILD_TOOLBAR, WC_NONE, + WindowClass::BuildToolbar, WindowClass::None, WindowDefaultFlag::Construction, _nested_build_tramway_widgets, &BuildRoadToolbarWindow::tram_hotkeys @@ -1062,7 +1062,7 @@ Window *ShowBuildRoadToolbar(RoadType roadtype) if (!Company::IsValidID(_local_company)) return nullptr; if (!ValParamRoadType(roadtype)) return nullptr; - CloseWindowByClass(WC_BUILD_TOOLBAR); + CloseWindowByClass(WindowClass::BuildToolbar); _cur_roadtype = roadtype; return AllocateWindowDescFront(RoadTypeIsRoad(_cur_roadtype) ? _build_road_desc : _build_tramway_desc, TRANSPORT_ROAD); @@ -1102,7 +1102,7 @@ static constexpr std::initializer_list _nested_build_road_scen_widg /** Window definition for the road toolbar of the scenario editor. */ static WindowDesc _build_road_scen_desc( WindowPosition::Automatic, "toolbar_road_scen", 0, 0, - WC_SCEN_BUILD_TOOLBAR, WC_NONE, + WindowClass::ScenarioBuildToolbar, WindowClass::None, WindowDefaultFlag::Construction, _nested_build_road_scen_widgets, &BuildRoadToolbarWindow::road_hotkeys @@ -1140,7 +1140,7 @@ static constexpr std::initializer_list _nested_build_tramway_scen_w /** Window definition for the tram toolbar of the scenario editor. */ static WindowDesc _build_tramway_scen_desc( WindowPosition::Automatic, "toolbar_tram_scen", 0, 0, - WC_SCEN_BUILD_TOOLBAR, WC_NONE, + WindowClass::ScenarioBuildToolbar, WindowClass::None, WindowDefaultFlag::Construction, _nested_build_tramway_scen_widgets, &BuildRoadToolbarWindow::tram_hotkeys @@ -1153,7 +1153,7 @@ static WindowDesc _build_tramway_scen_desc( */ Window *ShowBuildRoadScenToolbar(RoadType roadtype) { - CloseWindowById(WC_SCEN_BUILD_TOOLBAR, TRANSPORT_ROAD); + CloseWindowById(WindowClass::ScenarioBuildToolbar, TRANSPORT_ROAD); _cur_roadtype = roadtype; return AllocateWindowDescFront(RoadTypeIsRoad(_cur_roadtype) ? _build_road_scen_desc : _build_tramway_scen_desc, TRANSPORT_ROAD); @@ -1239,7 +1239,7 @@ static constexpr std::initializer_list _nested_build_road_depot_wid /** Window definition for the build road depot window. */ static WindowDesc _build_road_depot_desc( WindowPosition::Automatic, {}, 0, 0, - WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, + WindowClass::BuildDepot, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_build_road_depot_widgets ); @@ -1385,7 +1385,7 @@ private: _roadstop_gui.orientation = DIAGDIR_END; this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation); this->SetDirty(); - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); } } @@ -1410,12 +1410,12 @@ public: this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation); this->LowerWidget(WID_BROS_LT_OFF + _settings_client.gui.station_show_coverage); - this->window_class = (rs == RoadStopType::Bus) ? WC_BUS_STATION : WC_TRUCK_STATION; + this->window_class = (rs == RoadStopType::Bus) ? WindowClass::BuildBusStation : WindowClass::BuildTruckStation; } void Close([[maybe_unused]] int data = 0) override { - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); this->PickerWindow::Close(); } @@ -1434,7 +1434,7 @@ public: this->DrawWidgets(); - int rad = _settings_game.station.modified_catchment ? ((this->window_class == WC_BUS_STATION) ? CA_BUS : CA_TRUCK) : CA_UNMODIFIED; + int rad = _settings_game.station.modified_catchment ? ((this->window_class == WindowClass::BuildBusStation) ? CA_BUS : CA_TRUCK) : CA_UNMODIFIED; if (_settings_client.gui.station_show_coverage) { SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); } else { @@ -1444,7 +1444,7 @@ public: if (this->IsShaded()) return; /* 'Accepts' and 'Supplies' texts. */ - StationCoverageType sct = (this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY; + StationCoverageType sct = (this->window_class == WindowClass::BuildBusStation) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY; Rect r = this->GetWidget(WID_BROS_ACCEPTANCE)->GetCurrentRect(); const int bottom = r.bottom; r.bottom = INT_MAX; // Allow overflow as we want to know the required height. @@ -1491,8 +1491,8 @@ public: StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const { switch (window_class) { - case WC_BUS_STATION: return StationType::Bus; - case WC_TRUCK_STATION: return StationType::Truck; + case WindowClass::BuildBusStation: return StationType::Bus; + case WindowClass::BuildTruckStation: return StationType::Truck; default: NOT_REACHED(); } } @@ -1547,7 +1547,7 @@ public: this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation); SndClickBeep(); this->SetDirty(); - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); break; case WID_BROS_LT_OFF: @@ -1637,7 +1637,7 @@ static constexpr std::initializer_list _nested_road_station_picker_ /** Window definition for the build road station window. */ static WindowDesc _road_station_picker_desc( WindowPosition::Automatic, "build_station_road", 0, 0, - WC_BUS_STATION, WC_BUILD_TOOLBAR, + WindowClass::BuildBusStation, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_road_station_picker_widgets, &BuildRoadStationWindow::road_hotkeys @@ -1678,7 +1678,7 @@ static constexpr std::initializer_list _nested_tram_station_picker_ /** Window definition for the build tram station window. */ static WindowDesc _tram_station_picker_desc( WindowPosition::Automatic, "build_station_tram", 0, 0, - WC_BUS_STATION, WC_BUILD_TOOLBAR, + WindowClass::BuildBusStation, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_tram_station_picker_widgets, &BuildRoadStationWindow::tram_hotkeys @@ -1801,7 +1801,7 @@ static constexpr std::initializer_list _nested_build_road_waypoint_ /** Window definition for the build road waypoint window. */ static WindowDesc _build_road_waypoint_desc( WindowPosition::Automatic, "build_road_waypoint", 0, 0, - WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR, + WindowClass::BuildWaypoint, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_build_road_waypoint_widgets, &BuildRoadWaypointWindow::hotkeys @@ -1826,7 +1826,7 @@ void InitializeRoadGui() */ void InitializeRoadGUI() { - BuildRoadToolbarWindow *w = dynamic_cast(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_ROAD)); + BuildRoadToolbarWindow *w = dynamic_cast(FindWindowById(WindowClass::BuildToolbar, TRANSPORT_ROAD)); if (w != nullptr) w->ModifyRoadType(_cur_roadtype); } diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 521893882f..9b1ec6d092 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1049,7 +1049,7 @@ bool RoadVehLeaveDepot(RoadVehicle *v, bool first) v->UpdatePosition(); v->UpdateInclination(true, true); - InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); + InvalidateWindowData(WindowClass::VehicleDepot, v->tile); return true; } @@ -1552,7 +1552,7 @@ again: if (IsBayRoadStopTile(v->tile)) rs->SetEntranceBusy(true); StartRoadVehSound(v); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } /* Check tile position conditions - i.e. stop position in depot, @@ -1699,7 +1699,7 @@ static void CheckIfRoadVehNeedsService(RoadVehicle *v) * suddenly moved farther away, we continue our normal * schedule? */ v->current_order.MakeDummy(); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } return; } @@ -1715,7 +1715,7 @@ static void CheckIfRoadVehNeedsService(RoadVehicle *v) SetBit(v->gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS); v->current_order.MakeGoToDepot(depot, OrderDepotTypeFlag::Service); v->SetDestTile(rfdd.tile); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } /** Calender day handler */ @@ -1747,8 +1747,8 @@ void RoadVehicle::OnNewEconomyDay() SubtractMoneyFromCompanyFract(this->owner, cost); - SetWindowDirty(WC_VEHICLE_DETAILS, this->index); - SetWindowClassesDirty(WC_ROADVEH_LIST); + SetWindowDirty(WindowClass::VehicleDetails, this->index); + SetWindowClassesDirty(WindowClass::RoadVehicleList); } Trackdir RoadVehicle::GetVehicleTrackdir() const diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 5f6ba6524a..eadd1bf409 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -3499,10 +3499,10 @@ void ReloadNewGRFData() /* Delete news referring to no longer existing entities */ DeleteInvalidEngineNews(); /* Update livery selection windows */ - for (CompanyID i = CompanyID::Begin(); i < MAX_COMPANIES; ++i) InvalidateWindowData(WC_COMPANY_COLOUR, i); + for (CompanyID i = CompanyID::Begin(); i < MAX_COMPANIES; ++i) InvalidateWindowData(WindowClass::CompanyLivery, i); /* Update company infrastructure counts. */ - InvalidateWindowClassesData(WC_COMPANY_INFRASTRUCTURE); - InvalidateWindowClassesData(WC_BUILD_TOOLBAR); + InvalidateWindowClassesData(WindowClass::CompanyInfrastructure); + InvalidateWindowClassesData(WindowClass::BuildToolbar); InvalidateAllPickerWindows(); /* redraw the whole screen */ MarkWholeScreenDirty(); diff --git a/src/saveload/misc_sl.cpp b/src/saveload/misc_sl.cpp index 7ecd57fdff..9917a9327b 100644 --- a/src/saveload/misc_sl.cpp +++ b/src/saveload/misc_sl.cpp @@ -40,7 +40,7 @@ ZoomLevel _saved_scrollpos_zoom; void SaveViewportBeforeSaveGame() { /* Don't use GetMainWindow() in case the window does not exist. */ - const Window *w = FindWindowById(WC_MAIN_WINDOW, 0); + const Window *w = FindWindowById(WindowClass::MainWindow, 0); if (w == nullptr || w->viewport == nullptr) { /* Ensure saved position is clearly invalid. */ _saved_scrollpos_x = INT_MAX; diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 910577ec74..1b813c5960 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -2963,7 +2963,7 @@ static void SaveFileStart() { SetMouseCursorBusy(true); - InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_START); + InvalidateWindowData(WindowClass::Statusbar, 0, SBI_SAVELOAD_START); _sl.saveinprogress = true; } @@ -2972,7 +2972,7 @@ static void SaveFileDone() { SetMouseCursorBusy(false); - InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_FINISH); + InvalidateWindowData(WindowClass::Statusbar, 0, SBI_SAVELOAD_FINISH); _sl.saveinprogress = false; #ifdef __EMSCRIPTEN__ diff --git a/src/screenshot_gui.cpp b/src/screenshot_gui.cpp index abc10f4093..b5178669a6 100644 --- a/src/screenshot_gui.cpp +++ b/src/screenshot_gui.cpp @@ -67,14 +67,14 @@ static constexpr std::initializer_list _nested_screenshot = { /** Window definition for the screenshot window. */ static WindowDesc _screenshot_window_desc( WindowPosition::Automatic, "take_a_screenshot", 200, 100, - WC_SCREENSHOT, WC_NONE, + WindowClass::Screenshot, WindowClass::None, {}, _nested_screenshot ); void ShowScreenshotWindow() { - CloseWindowById(WC_SCREENSHOT, 0); + CloseWindowById(WindowClass::Screenshot, 0); new ScreenshotWindow(_screenshot_window_desc); } @@ -84,7 +84,7 @@ void ShowScreenshotWindow() */ void SetScreenshotWindowVisibility(bool hide) { - ScreenshotWindow *scw = dynamic_cast(FindWindowById(WC_SCREENSHOT, 0)); + ScreenshotWindow *scw = dynamic_cast(FindWindowById(WindowClass::Screenshot, 0)); if (scw == nullptr) return; diff --git a/src/script/api/script_log.cpp b/src/script/api/script_log.cpp index 3ba21ad899..b9d9980d30 100644 --- a/src/script/api/script_log.cpp +++ b/src/script/api/script_log.cpp @@ -57,5 +57,5 @@ /* Also still print to debug window */ Debug(script, level, "[{}] [{}] {}", ScriptObject::GetRootCompany(), logc, line.text); - InvalidateWindowClassesData(WC_SCRIPT_DEBUG, ScriptObject::GetRootCompany()); + InvalidateWindowClassesData(WindowClass::ScriptDebug, ScriptObject::GetRootCompany()); } diff --git a/src/script/api/script_window.hpp.in b/src/script/api/script_window.hpp.in index d08cb703d0..3b343fcb5b 100644 --- a/src/script/api/script_window.hpp.in +++ b/src/script/api/script_window.hpp.in @@ -17,9 +17,9 @@ ${INCLUDES} /** * Class that handles window interaction. A Window in OpenTTD has two important * values. The WindowClass, and a Window number. The first indicates roughly - * which window it is. WC_TOWN_VIEW for example, is the view of a town. + * which window it is. WindowClass::TownView for example, is the view of a town. * The Window number is a bit more complex, as it depends mostly on the - * WindowClass. For example for WC_TOWN_VIEW it is the TownID. In general a + * WindowClass. For example for WindowClass::TownView it is the TownID. In general a * good rule of thumb is: either the number is always 0, or the ID of the * object in question. * In the comment at the widget enum, it is mentioned how the number is used. diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index 714f29031d..979041199c 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -186,11 +186,11 @@ struct ScriptListWindow : public Window { } } } - InvalidateWindowData(WC_GAME_OPTIONS, this->slot == OWNER_DEITY ? GameOptionsWindowNumber::GS : GameOptionsWindowNumber::AI); - InvalidateWindowClassesData(WC_SCRIPT_SETTINGS); - InvalidateWindowClassesData(WC_SCRIPT_DEBUG, -1); - CloseWindowByClass(WC_QUERY_STRING); - InvalidateWindowClassesData(WC_TEXTFILE); + InvalidateWindowData(WindowClass::GameOptions, this->slot == OWNER_DEITY ? GameOptionsWindowNumber::GS : GameOptionsWindowNumber::AI); + InvalidateWindowClassesData(WindowClass::ScriptSettings); + InvalidateWindowClassesData(WindowClass::ScriptDebug, -1); + CloseWindowByClass(WindowClass::QueryString); + InvalidateWindowClassesData(WindowClass::Textfile); } void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override @@ -265,7 +265,7 @@ static constexpr std::initializer_list _nested_script_list_widgets /** Window definition for the ai list window. */ static WindowDesc _script_list_desc( WindowPosition::Center, "settings_script_list", 200, 234, - WC_SCRIPT_LIST, WC_NONE, + WindowClass::ScriptList, WindowClass::None, {}, _nested_script_list_widgets ); @@ -277,7 +277,7 @@ static WindowDesc _script_list_desc( */ void ShowScriptListWindow(CompanyID slot, bool show_all) { - CloseWindowByClass(WC_SCRIPT_LIST); + CloseWindowByClass(WindowClass::ScriptList); new ScriptListWindow(_script_list_desc, slot, show_all); } @@ -405,8 +405,8 @@ struct ScriptSettingsWindow : public Window { int num = it - this->visible_settings.begin(); if (this->clicked_row != num) { - this->CloseChildWindows(WC_QUERY_STRING); - this->CloseChildWindows(WC_DROPDOWN_MENU); + this->CloseChildWindows(WindowClass::QueryString); + this->CloseChildWindows(WindowClass::DropdownMenu); this->clicked_row = num; this->clicked_dropdown = false; } @@ -422,7 +422,7 @@ struct ScriptSettingsWindow : public Window { if (!bool_item && IsInsideMM(x, 0, SETTING_BUTTON_WIDTH) && config_item.complete_labels) { if (this->clicked_dropdown) { /* unclick the dropdown */ - this->CloseChildWindows(WC_DROPDOWN_MENU); + this->CloseChildWindows(WindowClass::DropdownMenu); this->clicked_dropdown = false; this->closing_dropdown = false; } else { @@ -531,8 +531,8 @@ struct ScriptSettingsWindow : public Window { this->script_config = GetConfig(this->slot); if (this->script_config->GetConfigList()->empty()) this->Close(); this->RebuildVisibleSettings(); - this->CloseChildWindows(WC_DROPDOWN_MENU); - this->CloseChildWindows(WC_QUERY_STRING); + this->CloseChildWindows(WindowClass::DropdownMenu); + this->CloseChildWindows(WindowClass::QueryString); } private: @@ -576,7 +576,7 @@ static constexpr std::initializer_list _nested_script_settings_widg /** Window definition for the Script settings window. */ static WindowDesc _script_settings_desc( WindowPosition::Center, "settings_script", 500, 208, - WC_SCRIPT_SETTINGS, WC_NONE, + WindowClass::ScriptSettings, WindowClass::None, {}, _nested_script_settings_widgets ); @@ -587,8 +587,8 @@ static WindowDesc _script_settings_desc( */ void ShowScriptSettingsWindow(CompanyID slot) { - CloseWindowByClass(WC_SCRIPT_LIST); - CloseWindowByClass(WC_SCRIPT_SETTINGS); + CloseWindowByClass(WindowClass::ScriptList); + CloseWindowByClass(WindowClass::ScriptSettings); new ScriptSettingsWindow(_script_settings_desc, slot); } @@ -631,7 +631,7 @@ struct ScriptTextfileWindow : public TextfileWindow { */ void ShowScriptTextfileWindow(Window *parent, TextfileType file_type, CompanyID slot) { - parent->CloseChildWindowById(WC_TEXTFILE, file_type); + parent->CloseChildWindowById(WindowClass::Textfile, file_type); new ScriptTextfileWindow(parent, file_type, slot); } @@ -991,7 +991,7 @@ struct ScriptDebugWindow : public Window { this->highlight_row = -1; // The highlight of one Script make little sense for another Script. /* Close AI settings window to prevent confusion */ - CloseWindowByClass(WC_SCRIPT_SETTINGS); + CloseWindowByClass(WindowClass::ScriptSettings); this->InvalidateData(-1); @@ -1253,7 +1253,7 @@ EndContainer(), /** Window definition for the Script debug window. */ static WindowDesc _script_debug_desc( WindowPosition::Automatic, "script_debug", 600, 450, - WC_SCRIPT_DEBUG, WC_NONE, + WindowClass::ScriptDebug, WindowClass::None, {}, _nested_script_debug_widgets, &ScriptDebugWindow::hotkeys @@ -1271,17 +1271,17 @@ Window *ShowScriptDebugWindow(CompanyID show_company, bool new_window) int i = 0; if (new_window) { /* find next free window number for script debug */ - while (FindWindowById(WC_SCRIPT_DEBUG, i) != nullptr) i++; + while (FindWindowById(WindowClass::ScriptDebug, i) != nullptr) i++; } else { /* Find existing window showing show_company. */ for (Window *w : Window::Iterate()) { - if (w->window_class == WC_SCRIPT_DEBUG && static_cast(w)->filter.script_debug_company == show_company) { + if (w->window_class == WindowClass::ScriptDebug && static_cast(w)->filter.script_debug_company == show_company) { return BringWindowToFrontById(w->window_class, w->window_number); } } /* Maybe there's a window showing a different company which can be switched. */ - ScriptDebugWindow *w = static_cast(FindWindowByClass(WC_SCRIPT_DEBUG)); + ScriptDebugWindow *w = static_cast(FindWindowByClass(WindowClass::ScriptDebug)); if (w != nullptr) { BringWindowToFrontById(w->window_class, w->window_number); w->ChangeToScript(show_company); diff --git a/src/settings.cpp b/src/settings.cpp index 82bfc89b76..ff01ffd18a 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1465,7 +1465,7 @@ void LoadFromConfig(bool startup) /* Display scheduled errors */ ScheduleErrorMessage(_settings_error_list); - if (FindWindowById(WC_ERRMSG, 0) == nullptr) ShowFirstError(); + if (FindWindowById(WindowClass::ErrorMessage, 0) == nullptr) ShowFirstError(); } } @@ -1628,8 +1628,8 @@ void IntSettingDesc::ChangeValue(const void *object, int32_t newval) const _gamelog.StopAction(); } - SetWindowClassesDirty(WC_GAME_OPTIONS); - if (this->flags.Test(SettingFlag::Sandbox)) SetWindowClassesDirty(WC_CHEATS); + SetWindowClassesDirty(WindowClass::GameOptions); + if (this->flags.Test(SettingFlag::Sandbox)) SetWindowClassesDirty(WindowClass::Cheat); if (_save_config) SaveToConfig(); } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 4c5bf4fe8f..da7cffe11e 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -127,7 +127,7 @@ struct BaseSetTextfileWindow : public TextfileWindow { template void ShowBaseSetTextfileWindow(Window *parent, TextfileType file_type, const TBaseSet *baseset, StringID content_type) { - parent->CloseChildWindowById(WC_TEXTFILE, file_type); + parent->CloseChildWindowById(WindowClass::Textfile, file_type); new BaseSetTextfileWindow(parent, file_type, baseset->name, *baseset->GetTextfile(file_type), content_type); } @@ -460,7 +460,7 @@ struct GameOptionsWindow : Window { void Close([[maybe_unused]] int data = 0) override { - CloseWindowById(WC_CUSTOM_CURRENCY, 0); + CloseWindowById(WindowClass::CustomCurrenty, 0); if (this->reload) _switch_mode = SM_MENU; this->Window::Close(); } @@ -1115,7 +1115,7 @@ struct GameOptionsWindow : Window { SetEffectVolume(vol); } this->SetWidgetDirty(widget); - SetWindowClassesDirty(WC_MUSIC_WINDOW); + SetWindowClassesDirty(WindowClass::Music); } if (click_count > 0) this->mouse_capture_widget = widget; @@ -1272,7 +1272,7 @@ struct GameOptionsWindow : Window { if (this->valuedropdown_entry == pe) { /* unclick the dropdown */ - this->CloseChildWindows(WC_DROPDOWN_MENU); + this->CloseChildWindows(WindowClass::DropdownMenu); this->closing_dropdown = false; this->valuedropdown_entry->SetButtons({}); this->valuedropdown_entry = nullptr; @@ -1437,7 +1437,7 @@ struct GameOptionsWindow : Window { case WID_GO_LANG_DROPDOWN: // Change interface language ReadLanguagePack(&_languages[index]); - CloseWindowByClass(WC_QUERY_STRING); + CloseWindowByClass(WindowClass::QueryString); CheckForMissingGlyphs(); ClearAllCachedNames(); UpdateAllVirtCoords(); @@ -1463,7 +1463,7 @@ struct GameOptionsWindow : Window { case WID_GO_BASE_GRF_DROPDOWN: if (_game_mode == GM_MENU) { - CloseWindowByClass(WC_GRF_PARAMETERS); + CloseWindowByClass(WindowClass::NewGRFParameters); auto set = BaseGraphics::GetSet(index); BaseGraphics::SetSet(set); this->reload = true; @@ -1855,7 +1855,7 @@ static constexpr std::initializer_list _nested_game_options_widgets /** Window definition for the game options window. */ static WindowDesc _game_options_desc( WindowPosition::Center, "game_options", 0, 0, - WC_GAME_OPTIONS, WC_NONE, + WindowClass::GameOptions, WindowClass::None, {}, _nested_game_options_widgets ); @@ -1863,7 +1863,7 @@ static WindowDesc _game_options_desc( /** Open the game options window. */ void ShowGameOptions() { - CloseWindowByClass(WC_GAME_OPTIONS); + CloseWindowByClass(WindowClass::GameOptions); new GameOptionsWindow(_game_options_desc); } @@ -2199,7 +2199,7 @@ static constexpr std::initializer_list _nested_cust_currency_widget /** Window definition for the custom currency window. */ static WindowDesc _cust_currency_desc( WindowPosition::Center, {}, 0, 0, - WC_CUSTOM_CURRENCY, WC_NONE, + WindowClass::CustomCurrenty, WindowClass::None, {}, _nested_cust_currency_widgets ); @@ -2207,6 +2207,6 @@ static WindowDesc _cust_currency_desc( /** Open custom currency window. */ static void ShowCustCurrency() { - CloseWindowById(WC_CUSTOM_CURRENCY, 0); + CloseWindowById(WindowClass::CustomCurrenty, 0); new CustomCurrencyWindow(_cust_currency_desc); } diff --git a/src/settings_table.cpp b/src/settings_table.cpp index a56ea460d4..bda87c94ee 100644 --- a/src/settings_table.cpp +++ b/src/settings_table.cpp @@ -163,7 +163,7 @@ static void RedrawSmallmap(int32_t) { BuildLandLegend(); BuildOwnerLegend(); - SetWindowClassesDirty(WC_SMALLMAP); + SetWindowClassesDirty(WindowClass::SmallMap); } /** Redraw linkgraph links after a colour scheme change. */ @@ -175,8 +175,8 @@ static void UpdateLinkgraphColours(int32_t) static void StationSpreadChanged(int32_t) { - InvalidateWindowData(WC_SELECT_STATION, 0); - InvalidateWindowData(WC_BUILD_STATION, 0); + InvalidateWindowData(WindowClass::JoinStation, 0); + InvalidateWindowData(WindowClass::BuildStation, 0); } static void UpdateConsists(int32_t) @@ -185,7 +185,7 @@ static void UpdateConsists(int32_t) /* Update the consist of all trains so the maximum speed is set correctly. */ if (t->IsFrontEngine() || t->IsFreeWagon()) t->ConsistChanged(CCF_TRACK); } - InvalidateWindowClassesData(WC_BUILD_VEHICLE, 0); + InvalidateWindowClassesData(WindowClass::BuildVehicle, 0); } /** @@ -234,7 +234,7 @@ static void UpdateAllServiceInterval(int32_t new_value) } } - SetWindowClassesDirty(WC_VEHICLE_DETAILS); + SetWindowClassesDirty(WindowClass::VehicleDetails); } static bool CanUpdateServiceInterval(VehicleType, int32_t &new_value) @@ -261,7 +261,7 @@ static void UpdateServiceInterval(VehicleType type, int32_t new_value) } } - SetWindowClassesDirty(WC_VEHICLE_DETAILS); + SetWindowClassesDirty(WindowClass::VehicleDetails); } /** @@ -322,9 +322,9 @@ static void TrainAccelerationModelChanged(int32_t) } /* These windows show acceleration values only when realistic acceleration is on. They must be redrawn after a setting change. */ - SetWindowClassesDirty(WC_ENGINE_PREVIEW); - InvalidateWindowClassesData(WC_BUILD_VEHICLE, 0); - SetWindowClassesDirty(WC_VEHICLE_DETAILS); + SetWindowClassesDirty(WindowClass::EnginePreview); + InvalidateWindowClassesData(WindowClass::BuildVehicle, 0); + SetWindowClassesDirty(WindowClass::VehicleDetails); } /** @@ -351,9 +351,9 @@ static void RoadVehAccelerationModelChanged(int32_t) } /* These windows show acceleration values only when realistic acceleration is on. They must be redrawn after a setting change. */ - SetWindowClassesDirty(WC_ENGINE_PREVIEW); - InvalidateWindowClassesData(WC_BUILD_VEHICLE, 0); - SetWindowClassesDirty(WC_VEHICLE_DETAILS); + SetWindowClassesDirty(WindowClass::EnginePreview); + InvalidateWindowClassesData(WindowClass::BuildVehicle, 0); + SetWindowClassesDirty(WindowClass::VehicleDetails); } /** @@ -378,7 +378,7 @@ static void AircraftRangeChanged(int32_t) /* Reset destination is too far state */ if (v->flags.Test(VehicleAirFlag::DestinationTooFar)) { v->flags.Reset(VehicleAirFlag::DestinationTooFar); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); DeleteVehicleNews(v->index, AdviceType::AircraftDestinationTooFar); } } @@ -387,9 +387,9 @@ static void AircraftRangeChanged(int32_t) static void TownFoundingChanged(int32_t) { if (_game_mode != GM_EDITOR && _settings_game.economy.found_town == TF_FORBIDDEN) { - CloseWindowById(WC_FOUND_TOWN, 0); + CloseWindowById(WindowClass::FoundTown, 0); } else { - InvalidateWindowData(WC_FOUND_TOWN, 0); + InvalidateWindowData(WindowClass::FoundTown, 0); } } @@ -397,7 +397,7 @@ static void ZoomMinMaxChanged(int32_t) { ConstrainAllViewportsZoom(); GfxClearSpriteCache(); - InvalidateWindowClassesData(WC_SPRITE_ALIGNER); + InvalidateWindowClassesData(WindowClass::SpriteAligner); if (AdjustGUIZoom(false)) { ReInitAllWindows(true); } @@ -417,14 +417,14 @@ static void SpriteZoomMinChanged(int32_t) */ static void InvalidateNewGRFChangeWindows(int32_t) { - InvalidateWindowClassesData(WC_SAVELOAD); - CloseWindowByClass(WC_GAME_OPTIONS); + InvalidateWindowClassesData(WindowClass::SaveLoad); + CloseWindowByClass(WindowClass::GameOptions); ReInitAllWindows(false); } static void InvalidateCompanyLiveryWindow(int32_t) { - InvalidateWindowClassesData(WC_COMPANY_COLOUR, -1); + InvalidateWindowClassesData(WindowClass::CompanyLivery, -1); ResetVehicleColourMap(); } @@ -433,7 +433,7 @@ static void DifficultyNoiseChange(int32_t) if (_game_mode == GM_NORMAL) { UpdateAirportsNoise(); if (_settings_game.economy.station_noise_level) { - InvalidateWindowClassesData(WC_TOWN_VIEW, 0); + InvalidateWindowClassesData(WindowClass::TownView, 0); } } } @@ -446,7 +446,7 @@ static void MaxNoAIsChange(int32_t) ShowErrorMessage(GetEncodedString(STR_WARNING_NO_SUITABLE_AI), {}, WL_CRITICAL); } - InvalidateWindowClassesData(WC_GAME_OPTIONS, 0); + InvalidateWindowClassesData(WindowClass::GameOptions, 0); } /** @@ -583,7 +583,7 @@ static void StationCatchmentChanged(int32_t) static void MaxVehiclesChanged(int32_t) { - InvalidateWindowClassesData(WC_BUILD_TOOLBAR); + InvalidateWindowClassesData(WindowClass::BuildToolbar); MarkWholeScreenDirty(); } @@ -603,7 +603,7 @@ static void UpdateClientConfigValues() { NetworkServerUpdateGameInfo(); - InvalidateWindowData(WC_CLIENT_LIST, 0); + InvalidateWindowData(WindowClass::NetworkClientList, 0); if (_network_server) { NetworkServerSendConfigUpdate(); @@ -625,7 +625,7 @@ static void ChangeTimekeepingUnits() _settings_newgame.economy.minutes_per_calendar_year = CalendarTime::DEF_MINUTES_PER_YEAR; } - InvalidateWindowClassesData(WC_GAME_OPTIONS, 0); + InvalidateWindowClassesData(WindowClass::GameOptions, 0); /* It is possible to change these units in Scenario Editor. We must set the economy date appropriately. */ if (_game_mode == GM_EDITOR) { diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 1c7cee57ce..61f817536b 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -216,14 +216,14 @@ static void CheckIfShipNeedsService(Vehicle *v) if (depot == nullptr) { if (v->current_order.IsType(OT_GOTO_DEPOT)) { v->current_order.MakeDummy(); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } return; } v->current_order.MakeGoToDepot(depot->index, OrderDepotTypeFlag::Service); v->SetDestTile(depot->xy); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } /** @@ -280,9 +280,9 @@ void Ship::OnNewEconomyDay() SubtractMoneyFromCompanyFract(this->owner, cost); - SetWindowDirty(WC_VEHICLE_DETAILS, this->index); + SetWindowDirty(WindowClass::VehicleDetails, this->index); /* we need this for the profit */ - SetWindowClassesDirty(WC_SHIPS_LIST); + SetWindowClassesDirty(WindowClass::ShipList); } Trackdir Ship::GetVehicleTrackdir() const @@ -396,13 +396,13 @@ static bool CheckShipStayInDepot(Ship *v) v->vehstatus.Reset(VehState::Hidden); v->cur_speed = 0; v->UpdateViewport(true, true); - SetWindowDirty(WC_VEHICLE_DEPOT, v->tile); + SetWindowDirty(WindowClass::VehicleDepot, v->tile); VehicleServiceInDepot(v); v->LeaveUnbunchingDepot(); v->PlayLeaveStationSound(); - InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); - SetWindowClassesDirty(WC_SHIPS_LIST); + InvalidateWindowData(WindowClass::VehicleDepot, v->tile); + SetWindowClassesDirty(WindowClass::ShipList); return false; } @@ -421,7 +421,7 @@ static uint ShipAccelerate(Vehicle *v) /* updates statusbar only if speed have changed to save CPU time */ if (speed != v->cur_speed) { v->cur_speed = speed; - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } const uint advance_speed = v->GetAdvanceSpeed(speed); @@ -597,7 +597,7 @@ static bool ShipMoveUpDownOnLock(Ship *v) if (v->cur_speed != 0) { v->cur_speed = 0; - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } if ((v->tick_counter & 7) == 0) { @@ -721,7 +721,7 @@ static void ShipController(Ship *v) * always skip ahead. */ if (v->current_order.IsType(OT_LEAVESTATION)) { v->current_order.Free(); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); /* Test if continuing forward would lead to a dead-end, moving into the dock. */ const DiagDirection exitdir = VehicleExitDir(v->direction, v->state); const TileIndex tile = TileAddByDiagDir(v->tile, exitdir); diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp index a2f3b35a62..5be9c7a62b 100644 --- a/src/signs_cmd.cpp +++ b/src/signs_cmd.cpp @@ -48,7 +48,7 @@ std::tuple CmdPlaceSign(DoCommandFlags flags, TileIndex til Sign *si = Sign::Create(_game_mode == GM_EDITOR ? OWNER_DEITY : _current_company, x, y, GetSlopePixelZ(x, y), text); si->UpdateVirtCoord(); - InvalidateWindowData(WC_SIGN_LIST, 0, 0); + InvalidateWindowData(WindowClass::SignList, 0, 0); return { CommandCost(), si->index }; } @@ -82,7 +82,7 @@ CommandCost CmdRenameSign(DoCommandFlags flags, SignID sign_id, const std::strin if (_game_mode != GM_EDITOR) si->owner = _current_company; si->UpdateVirtCoord(); - InvalidateWindowData(WC_SIGN_LIST, 0, 1); + InvalidateWindowData(WindowClass::SignList, 0, 1); } } else { // Delete sign if (flags.Test(DoCommandFlag::Execute)) { @@ -90,7 +90,7 @@ CommandCost CmdRenameSign(DoCommandFlags flags, SignID sign_id, const std::strin if (si->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeSign(si->index)); delete si; - InvalidateWindowData(WC_SIGN_LIST, 0, 0); + InvalidateWindowData(WindowClass::SignList, 0, 0); } } diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index 9d86d48464..ff077c4b30 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -363,7 +363,7 @@ static constexpr std::initializer_list _nested_sign_list_widgets = /** Window definition for the sign list window. */ static WindowDesc _sign_list_desc( WindowPosition::Automatic, "list_signs", 358, 138, - WC_SIGN_LIST, WC_NONE, + WindowClass::SignList, WindowClass::None, {}, _nested_sign_list_widgets, &SignListWindow::hotkeys @@ -616,7 +616,7 @@ static constexpr std::initializer_list _nested_query_sign_edit_widg /** Window definition for the sign editor window. */ static WindowDesc _query_sign_edit_desc( WindowPosition::Center, {}, 0, 0, - WC_QUERY_STRING, WC_NONE, + WindowClass::QueryString, WindowClass::None, WindowDefaultFlag::Construction, _nested_query_sign_edit_widgets ); @@ -645,7 +645,7 @@ void HandleClickOnSign(const Sign *si) void ShowRenameSignWindow(const Sign *si) { /* Delete all other edit windows */ - CloseWindowByClass(WC_QUERY_STRING); + CloseWindowByClass(WindowClass::QueryString); new SignWindow(_query_sign_edit_desc, si); } @@ -656,7 +656,7 @@ void ShowRenameSignWindow(const Sign *si) */ void DeleteRenameSignWindow(SignID sign) { - SignWindow *w = dynamic_cast(FindWindowById(WC_QUERY_STRING, QueryStringWindowNumber::Sign)); + SignWindow *w = dynamic_cast(FindWindowById(WindowClass::QueryString, QueryStringWindowNumber::Sign)); if (w != nullptr && w->cur_sign == sign) w->Close(); } diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 562d371e69..c8c4b4cf93 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -657,7 +657,7 @@ protected: /** Notify the industry chain window to stop sending newly selected industries. */ static void BreakIndustryChainLink() { - InvalidateWindowClassesData(WC_INDUSTRY_CARGOES, NUM_INDUSTRYTYPES); + InvalidateWindowClassesData(WindowClass::IndustryCargoes, NUM_INDUSTRYTYPES); } static inline Point SmallmapRemapCoords(int x, int y) @@ -2061,7 +2061,7 @@ static constexpr std::initializer_list _nested_smallmap_widgets = { /** Window definition for the smallmap window. */ static WindowDesc _smallmap_desc( WindowPosition::Automatic, "smallmap", 484, 314, - WC_SMALLMAP, WC_NONE, + WindowClass::SmallMap, WindowClass::None, {}, _nested_smallmap_widgets ); @@ -2092,7 +2092,7 @@ bool ScrollMainWindowTo(int x, int y, int z, bool instant) if (res) return res; - SmallMapWindow *w = dynamic_cast(FindWindowById(WC_SMALLMAP, 0)); + SmallMapWindow *w = dynamic_cast(FindWindowById(WindowClass::SmallMap, 0)); if (w != nullptr) w->SmallMapCenterOnCurrentPos(); return res; diff --git a/src/sound.cpp b/src/sound.cpp index f577180d5e..2a2556b50b 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -187,7 +187,7 @@ void ChangeSoundSet(int index) sound->priority = 0; } - InvalidateWindowData(WC_GAME_OPTIONS, GameOptionsWindowNumber::GameOptions, 0, true); + InvalidateWindowData(WindowClass::GameOptions, GameOptionsWindowNumber::GameOptions, 0, true); } /** diff --git a/src/station.cpp b/src/station.cpp index eeecfeb986..960390cd04 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -53,10 +53,10 @@ BaseStation::~BaseStation() { if (CleaningPool()) return; - CloseWindowById(WC_TRAINS_LIST, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Train, this->owner, this->index).ToWindowNumber()); - CloseWindowById(WC_ROADVEH_LIST, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Road, this->owner, this->index).ToWindowNumber()); - CloseWindowById(WC_SHIPS_LIST, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Ship, this->owner, this->index).ToWindowNumber()); - CloseWindowById(WC_AIRCRAFT_LIST, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Aircraft, this->owner, this->index).ToWindowNumber()); + CloseWindowById(WindowClass::TrainList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Train, this->owner, this->index).ToWindowNumber()); + CloseWindowById(WindowClass::RoadVehicleList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Road, this->owner, this->index).ToWindowNumber()); + CloseWindowById(WindowClass::ShipList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Ship, this->owner, this->index).ToWindowNumber()); + CloseWindowById(WindowClass::AircraftList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Aircraft, this->owner, this->index).ToWindowNumber()); this->sign.MarkDirty(); } @@ -138,12 +138,12 @@ Station::~Station() if (this->owner == OWNER_NONE) { /* Invalidate all in case of oil rigs. */ - InvalidateWindowClassesData(WC_STATION_LIST, 0); + InvalidateWindowClassesData(WindowClass::StationList, 0); } else { - InvalidateWindowData(WC_STATION_LIST, this->owner, 0); + InvalidateWindowData(WindowClass::StationList, this->owner, 0); } - CloseWindowById(WC_STATION_VIEW, index); + CloseWindowById(WindowClass::StationView, index); /* Now delete all orders that go to the station */ RemoveOrderFromAllVehicles(OT_GOTO_STATION, this->index); @@ -170,7 +170,7 @@ Station::~Station() */ void BaseStation::PostDestructor([[maybe_unused]] size_t index) { - InvalidateWindowData(WC_SELECT_STATION, 0, 0); + InvalidateWindowData(WindowClass::JoinStation, 0, 0); } bool BaseStation::SetRoadStopTileData(TileIndex tile, uint8_t data, bool animation) @@ -239,7 +239,7 @@ void Station::AddFacility(StationFacility new_facility_bit, TileIndex facil_xy) this->facilities.Set(new_facility_bit); this->owner = _current_company; this->build_date = TimerGameCalendar::date; - SetWindowClassesDirty(WC_VEHICLE_ORDERS); + SetWindowClassesDirty(WindowClass::VehicleOrders); } /** diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index cc0c2ef34b..65b0409cd2 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -460,7 +460,7 @@ void Station::UpdateVirtCoord() _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeStation(this->index)); - SetWindowDirty(WC_STATION_VIEW, this->index); + SetWindowDirty(WindowClass::StationView, this->index); } /** @@ -671,7 +671,7 @@ void UpdateStationAcceptance(Station *st, bool show_msg) } /* redraw the station view since acceptance changed */ - SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_ACCEPT_RATING_LIST); + SetWindowWidgetDirty(WindowClass::StationView, st->index, WID_SV_ACCEPT_RATING_LIST); } static void UpdateStationSignCoord(BaseStation *st) @@ -743,7 +743,7 @@ static void DeleteStationIfEmpty(BaseStation *st) { if (!st->IsInUse()) { st->delete_ctr = 0; - InvalidateWindowData(WC_STATION_LIST, st->owner, 0); + InvalidateWindowData(WindowClass::StationList, st->owner, 0); } /* station remains but it probably lost some parts - station sign should stay in the station boundaries */ UpdateStationSignCoord(st); @@ -762,30 +762,30 @@ void Station::AfterStationTileSetChange(bool adding, StationType type) if (adding) { this->RecomputeCatchment(); MarkCatchmentTilesDirty(); - InvalidateWindowData(WC_STATION_LIST, this->owner, 0); + InvalidateWindowData(WindowClass::StationList, this->owner, 0); } else { MarkCatchmentTilesDirty(); } switch (type) { case StationType::Rail: - SetWindowWidgetDirty(WC_STATION_VIEW, this->index, WID_SV_TRAINS); + SetWindowWidgetDirty(WindowClass::StationView, this->index, WID_SV_TRAINS); break; case StationType::Airport: break; case StationType::Truck: case StationType::Bus: - SetWindowWidgetDirty(WC_STATION_VIEW, this->index, WID_SV_ROADVEHS); + SetWindowWidgetDirty(WindowClass::StationView, this->index, WID_SV_ROADVEHS); break; case StationType::Dock: - SetWindowWidgetDirty(WC_STATION_VIEW, this->index, WID_SV_SHIPS); + SetWindowWidgetDirty(WindowClass::StationView, this->index, WID_SV_SHIPS); break; default: NOT_REACHED(); } if (adding) { UpdateStationAcceptance(this, false); - InvalidateWindowData(WC_SELECT_STATION, 0, 0); + InvalidateWindowData(WindowClass::JoinStation, 0, 0); } else { DeleteStationIfEmpty(this); this->RecomputeCatchment(); @@ -1844,8 +1844,8 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector &affected_st /* if we deleted the whole station, delete the train facility. */ if (st->train_station.tile == INVALID_TILE) { st->facilities.Reset(StationFacility::Train); - SetWindowClassesDirty(WC_VEHICLE_ORDERS); - SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_TRAINS); + SetWindowClassesDirty(WindowClass::VehicleOrders); + SetWindowWidgetDirty(WindowClass::StationView, st->index, WID_SV_TRAINS); MarkCatchmentTilesDirty(); st->UpdateVirtCoord(); DeleteStationIfEmpty(st); @@ -1879,7 +1879,7 @@ CommandCost CmdRemoveFromRailStation(DoCommandFlags flags, TileIndex start, Tile /* Do all station specific functions here. */ for (Station *st : affected_stations) { - if (st->train_station.tile == INVALID_TILE) SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_TRAINS); + if (st->train_station.tile == INVALID_TILE) SetWindowWidgetDirty(WindowClass::StationView, st->index, WID_SV_TRAINS); st->MarkTilesDirty(false); MarkCatchmentTilesDirty(); st->RecomputeCatchment(); @@ -2293,7 +2293,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlags flags, int repl /* removed the only stop? */ if (*primary_stop == nullptr) { st->facilities.Reset(is_truck ? StationFacility::TruckStop : StationFacility::BusStop); - SetWindowClassesDirty(WC_VEHICLE_ORDERS); + SetWindowClassesDirty(WindowClass::VehicleOrders); } } else { /* tell the predecessor in the list to skip this stop */ @@ -2414,7 +2414,7 @@ CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlags flags, int rep /* if we deleted the whole waypoint, delete the road facility. */ if (wp->road_waypoint_area.tile == INVALID_TILE) { wp->facilities.Reset({StationFacility::BusStop, StationFacility::TruckStop}); - SetWindowWidgetDirty(WC_STATION_VIEW, wp->index, WID_SV_ROADVEHS); + SetWindowWidgetDirty(WindowClass::StationView, wp->index, WID_SV_ROADVEHS); wp->UpdateVirtCoord(); DeleteStationIfEmpty(wp); } @@ -2751,10 +2751,10 @@ CommandCost CmdBuildAirport(DoCommandFlags flags, TileIndex tile, uint8_t airpor Company::Get(st->owner)->infrastructure.airport++; st->AfterStationTileSetChange(true, StationType::Airport); - InvalidateWindowData(WC_STATION_VIEW, st->index, -1); + InvalidateWindowData(WindowClass::StationView, st->index, -1); if (_settings_game.economy.station_noise_level) { - SetWindowDirty(WC_TOWN_VIEW, nearest->index); + SetWindowDirty(WindowClass::TownView, nearest->index); } } @@ -2791,7 +2791,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlags flags) for (uint i = 0; i < st->airport.GetNumHangars(); ++i) { TileIndex tile_cur = st->airport.GetHangarTile(i); OrderBackup::Reset(tile_cur, false); - CloseWindowById(WC_VEHICLE_DEPOT, tile_cur); + CloseWindowById(WindowClass::VehicleDepot, tile_cur); } /* The noise level is the noise from the airport and reduce it to account for the distance to the town center. @@ -2802,7 +2802,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlags flags) nearest->noise_reached -= GetAirportNoiseLevelForDistance(st->airport.GetSpec(), dist); if (_settings_game.economy.station_noise_level) { - SetWindowDirty(WC_TOWN_VIEW, nearest->index); + SetWindowDirty(WindowClass::TownView, nearest->index); } } @@ -2828,9 +2828,9 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlags flags) st->airport.Clear(); st->facilities.Reset(StationFacility::Airport); - SetWindowClassesDirty(WC_VEHICLE_ORDERS); + SetWindowClassesDirty(WindowClass::VehicleOrders); - InvalidateWindowData(WC_STATION_VIEW, st->index, -1); + InvalidateWindowData(WindowClass::StationView, st->index, -1); Company::Get(st->owner)->infrastructure.airport--; @@ -2860,7 +2860,7 @@ CommandCost CmdOpenCloseAirport(DoCommandFlags flags, StationID station_id) if (flags.Test(DoCommandFlag::Execute)) { st->airport.blocks.Flip(AirportBlock::AirportClosed); - SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_CLOSE_AIRPORT); + SetWindowWidgetDirty(WindowClass::StationView, st->index, WID_SV_CLOSE_AIRPORT); } return CommandCost(); } @@ -3087,7 +3087,7 @@ static CommandCost RemoveDock(TileIndex tile, DoCommandFlags flags) st->ship_station.Clear(); st->docking_station.Clear(); st->facilities.Reset(StationFacility::Dock); - SetWindowClassesDirty(WC_VEHICLE_ORDERS); + SetWindowClassesDirty(WindowClass::VehicleOrders); } Company::Get(st->owner)->infrastructure.station -= 2; @@ -4142,9 +4142,9 @@ static void UpdateStationRating(Station *st) StationID index = st->index; if (waiting_changed) { - SetWindowDirty(WC_STATION_VIEW, index); // update whole window + SetWindowDirty(WindowClass::StationView, index); // update whole window } else { - SetWindowWidgetDirty(WC_STATION_VIEW, index, WID_SV_ACCEPT_RATING_LIST); // update only ratings list + SetWindowWidgetDirty(WindowClass::StationView, index, WID_SV_ACCEPT_RATING_LIST); // update only ratings list } } @@ -4447,7 +4447,7 @@ static uint UpdateStationWaiting(Station *st, CargoType cargo, uint amount, Sour if (lg != nullptr) (*lg)[ge.node].UpdateSupply(amount); if (!ge.HasRating()) { - InvalidateWindowData(WC_STATION_LIST, st->owner); + InvalidateWindowData(WindowClass::StationList, st->owner); ge.status.Set(GoodsEntry::State::Rating); } @@ -4458,7 +4458,7 @@ static uint UpdateStationWaiting(Station *st, CargoType cargo, uint amount, Sour TriggerRoadStopAnimation(st, st->xy, StationAnimationTrigger::NewCargo, cargo); - SetWindowDirty(WC_STATION_VIEW, st->index); + SetWindowDirty(WindowClass::StationView, st->index); st->MarkTilesDirty(true); return amount; } @@ -4503,7 +4503,7 @@ CommandCost CmdRenameStation(DoCommandFlags flags, StationID station_id, const s } st->UpdateVirtCoord(); - InvalidateWindowData(WC_STATION_LIST, st->owner, 1); + InvalidateWindowData(WindowClass::StationList, st->owner, 1); } return CommandCost(); @@ -4853,7 +4853,7 @@ static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_o /* for buoys, owner of tile is owner of water, st->owner == OWNER_NONE */ SetTileOwner(tile, new_owner); - InvalidateWindowClassesData(WC_STATION_LIST, 0); + InvalidateWindowClassesData(WindowClass::StationList, 0); } else { if (IsDriveThroughStopTile(tile)) { /* Remove the drive-through road stop */ diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 56ffdecc48..4139940bef 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -721,7 +721,7 @@ public: } /* Always close the list if ctrl is not pressed. */ - if (!_ctrl_pressed) this->CloseChildWindows(WC_DROPDOWN_MENU); + if (!_ctrl_pressed) this->CloseChildWindows(WindowClass::DropdownMenu); } } @@ -800,7 +800,7 @@ static constexpr std::initializer_list _nested_company_stations_wid /** Window definition for the company stations window. */ static WindowDesc _company_stations_desc( WindowPosition::Automatic, "list_stations", 358, 162, - WC_STATION_LIST, WC_NONE, + WindowClass::StationList, WindowClass::None, {}, _nested_company_stations_widgets ); @@ -1362,10 +1362,10 @@ struct StationViewWindow : public Window { void Close([[maybe_unused]] int data = 0) override { - CloseWindowById(WC_TRAINS_LIST, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Train, this->owner, this->window_number).ToWindowNumber(), false); - CloseWindowById(WC_ROADVEH_LIST, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Road, this->owner, this->window_number).ToWindowNumber(), false); - CloseWindowById(WC_SHIPS_LIST, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Ship, this->owner, this->window_number).ToWindowNumber(), false); - CloseWindowById(WC_AIRCRAFT_LIST, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Aircraft, this->owner, this->window_number).ToWindowNumber(), false); + CloseWindowById(WindowClass::TrainList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Train, this->owner, this->window_number).ToWindowNumber(), false); + CloseWindowById(WindowClass::RoadVehicleList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Road, this->owner, this->window_number).ToWindowNumber(), false); + CloseWindowById(WindowClass::ShipList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Ship, this->owner, this->window_number).ToWindowNumber(), false); + CloseWindowById(WindowClass::AircraftList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Aircraft, this->owner, this->window_number).ToWindowNumber(), false); SetViewportCatchmentStation(Station::Get(this->window_number), false); this->Window::Close(); @@ -1969,7 +1969,7 @@ struct StationViewWindow : public Window { void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { - Window *w = FindWindowByClass(WC_QUERY_STRING); + Window *w = FindWindowByClass(WindowClass::QueryString); switch (widget) { case WID_SV_WAITING: @@ -1980,8 +1980,8 @@ struct StationViewWindow : public Window { SetViewportCatchmentStation(Station::Get(this->window_number), !this->IsWidgetLowered(WID_SV_CATCHMENT)); if (w != nullptr && this->IsWidgetLowered(WID_SV_CATCHMENT)) { - if (w->parent->window_class == WC_STATION_VIEW && w->IsWidgetLowered(WID_QS_MOVE)) SetViewportStationRect(Station::Get(w->parent->window_number), true); - if (w->parent->window_class == WC_WAYPOINT_VIEW && w->IsWidgetLowered(WID_QS_MOVE)) SetViewportWaypointRect(Waypoint::Get(w->parent->window_number), true); + if (w->parent->window_class == WindowClass::StationView && w->IsWidgetLowered(WID_QS_MOVE)) SetViewportStationRect(Station::Get(w->parent->window_number), true); + if (w->parent->window_class == WindowClass::WaypointView && w->IsWidgetLowered(WID_QS_MOVE)) SetViewportWaypointRect(Waypoint::Get(w->parent->window_number), true); } break; @@ -2179,7 +2179,7 @@ struct StationViewWindow : public Window { /** Window definition for the station view window. */ static WindowDesc _station_view_desc( WindowPosition::Automatic, "view_station", 249, 117, - WC_STATION_VIEW, WC_NONE, + WindowClass::StationView, WindowClass::None, {}, _nested_station_view_widgets ); @@ -2387,7 +2387,7 @@ struct SelectStationWindow : Window { this->select_station_proc(false, *it); /* Close Window; this might cause double frees! */ - CloseWindowById(WC_SELECT_STATION, 0); + CloseWindowById(WindowClass::JoinStation, 0); } void OnRealtimeTick([[maybe_unused]] uint delta_ms) override @@ -2433,7 +2433,7 @@ struct SelectStationWindow : Window { /** Window definition for the station selection window for (distant) joining. */ static WindowDesc _select_station_desc( WindowPosition::Automatic, "build_station_join", 200, 180, - WC_SELECT_STATION, WC_NONE, + WindowClass::JoinStation, WindowClass::None, WindowDefaultFlag::Construction, _nested_select_station_widgets ); @@ -2451,7 +2451,7 @@ static bool StationJoinerNeeded(const StationPickerCmdProc &proc) /* If a window is already opened and we didn't ctrl-click, * return true (i.e. just flash the old window) */ - Window *selection_window = FindWindowById(WC_SELECT_STATION, 0); + Window *selection_window = FindWindowById(WindowClass::JoinStation, 0); if (selection_window != nullptr) { /* Abort current distant-join and start new one */ selection_window->Close(); diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index f14a7380a3..b3e63aafba 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -140,7 +140,7 @@ struct StatusBarWindow : Window { } else if (this->ticker_scroll < TICKER_STOP && GetStatusbarNews() != nullptr && !GetStatusbarNews()->headline.empty()) { /* Draw the scrolling news text */ if (!DrawScrollingStatusText(*GetStatusbarNews(), ScaleGUITrad(this->ticker_scroll), tr.left, tr.right, tr.top, tr.bottom)) { - InvalidateWindowData(WC_STATUS_BAR, 0, SBI_NEWS_DELETED); + InvalidateWindowData(WindowClass::Statusbar, 0, SBI_NEWS_DELETED); if (Company::IsValidID(_local_company)) { /* This is the default text */ DrawString(tr, GetString(STR_STATUSBAR_COMPANY_NAME, _local_company), TextColour::FromString, SA_HOR_CENTER); @@ -221,7 +221,7 @@ static constexpr std::initializer_list _nested_main_status_widgets /** Window definition for the main status bar. */ static WindowDesc _main_status_desc( WindowPosition::Manual, {}, 0, 0, - WC_STATUS_BAR, WC_NONE, + WindowClass::Statusbar, WindowClass::None, {WindowDefaultFlag::NoFocus, WindowDefaultFlag::NoClose}, _nested_main_status_widgets ); @@ -232,7 +232,7 @@ static WindowDesc _main_status_desc( */ bool IsNewsTickerShown() { - const StatusBarWindow *w = dynamic_cast(FindWindowById(WC_STATUS_BAR, 0)); + const StatusBarWindow *w = dynamic_cast(FindWindowById(WindowClass::Statusbar, 0)); return w != nullptr && w->ticker_scroll < StatusBarWindow::TICKER_STOP; } diff --git a/src/story.cpp b/src/story.cpp index 65c71fa992..f5389e52f9 100644 --- a/src/story.cpp +++ b/src/story.cpp @@ -271,8 +271,8 @@ std::tuple CmdCreateStoryPage(DoCommandFlags flags, Co StoryPage *s = StoryPage::Create(_story_page_next_sort_value, TimerGameCalendar::date, company, text); - InvalidateWindowClassesData(WC_STORY_BOOK, -1); - if (StoryPage::GetNumItems() == 1) InvalidateWindowData(WC_MAIN_TOOLBAR, 0); + InvalidateWindowClassesData(WindowClass::StoryBook, -1); + if (StoryPage::GetNumItems() == 1) InvalidateWindowData(WindowClass::MainToolbar, 0); _story_page_next_sort_value++; return { CommandCost(), s->index }; @@ -316,7 +316,7 @@ std::tuple CmdCreateStoryPageElement(DoCommandF StoryPageElement *pe = StoryPageElement::Create(_story_page_element_next_sort_value, type, page_id); UpdateElement(*pe, tile, reference, text); - InvalidateWindowClassesData(WC_STORY_BOOK, page_id); + InvalidateWindowClassesData(WindowClass::StoryBook, page_id); _story_page_element_next_sort_value++; return { CommandCost(), pe->index }; @@ -347,7 +347,7 @@ CommandCost CmdUpdateStoryPageElement(DoCommandFlags flags, TileIndex tile, Stor if (flags.Test(DoCommandFlag::Execute)) { UpdateElement(*pe, tile, reference, text); - InvalidateWindowClassesData(WC_STORY_BOOK, pe->page); + InvalidateWindowClassesData(WindowClass::StoryBook, pe->page); } return CommandCost(); @@ -369,7 +369,7 @@ CommandCost CmdSetStoryPageTitle(DoCommandFlags flags, StoryPageID page_id, cons StoryPage *p = StoryPage::Get(page_id); p->title = text; - InvalidateWindowClassesData(WC_STORY_BOOK, page_id); + InvalidateWindowClassesData(WindowClass::StoryBook, page_id); } return CommandCost(); @@ -391,7 +391,7 @@ CommandCost CmdSetStoryPageDate(DoCommandFlags flags, StoryPageID page_id, Timer StoryPage *p = StoryPage::Get(page_id); p->date = date; - InvalidateWindowClassesData(WC_STORY_BOOK, page_id); + InvalidateWindowClassesData(WindowClass::StoryBook, page_id); } return CommandCost(); @@ -438,8 +438,8 @@ CommandCost CmdRemoveStoryPage(DoCommandFlags flags, StoryPageID page_id) delete p; - InvalidateWindowClassesData(WC_STORY_BOOK, -1); - if (StoryPage::GetNumItems() == 0) InvalidateWindowData(WC_MAIN_TOOLBAR, 0); + InvalidateWindowClassesData(WindowClass::StoryBook, -1); + if (StoryPage::GetNumItems() == 0) InvalidateWindowData(WindowClass::MainToolbar, 0); } return CommandCost(); @@ -462,7 +462,7 @@ CommandCost CmdRemoveStoryPageElement(DoCommandFlags flags, StoryPageElementID p delete pe; - InvalidateWindowClassesData(WC_STORY_BOOK, page_id); + InvalidateWindowClassesData(WindowClass::StoryBook, page_id); } return CommandCost(); diff --git a/src/story_gui.cpp b/src/story_gui.cpp index f035d9ac48..f35d1e3c92 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -964,7 +964,7 @@ static constexpr std::initializer_list _nested_story_book_widgets = /** Window definition for the story book window. */ static WindowDesc _story_book_desc( WindowPosition::Automatic, "view_story", 400, 300, - WC_STORY_BOOK, WC_NONE, + WindowClass::StoryBook, WindowClass::None, {}, _nested_story_book_widgets ); @@ -972,7 +972,7 @@ static WindowDesc _story_book_desc( /** Window definition for the game script window. */ static WindowDesc _story_book_gs_desc( WindowPosition::Center, "view_story_gs", 400, 300, - WC_STORY_BOOK, WC_NONE, + WindowClass::StoryBook, WindowClass::None, {}, _nested_story_book_widgets ); diff --git a/src/strings.cpp b/src/strings.cpp index b9bb6060b9..be5f11e52c 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -2139,13 +2139,13 @@ bool ReadLanguagePack(const LanguageMetadata *lang) SortIndustryTypes(); BuildIndustriesLegend(); BuildContentTypeStringList(); - InvalidateWindowClassesData(WC_BUILD_VEHICLE); // Build vehicle window. - InvalidateWindowClassesData(WC_TRAINS_LIST); // Train group window. - InvalidateWindowClassesData(WC_ROADVEH_LIST); // Road vehicle group window. - InvalidateWindowClassesData(WC_SHIPS_LIST); // Ship group window. - InvalidateWindowClassesData(WC_AIRCRAFT_LIST); // Aircraft group window. - InvalidateWindowClassesData(WC_INDUSTRY_DIRECTORY); // Industry directory window. - InvalidateWindowClassesData(WC_STATION_LIST); // Station list window. + InvalidateWindowClassesData(WindowClass::BuildVehicle); // Build vehicle window. + InvalidateWindowClassesData(WindowClass::TrainList); // Train group window. + InvalidateWindowClassesData(WindowClass::RoadVehicleList); // Road vehicle group window. + InvalidateWindowClassesData(WindowClass::ShipList); // Ship group window. + InvalidateWindowClassesData(WindowClass::AircraftList); // Aircraft group window. + InvalidateWindowClassesData(WindowClass::IndustryDirectory); // Industry directory window. + InvalidateWindowClassesData(WindowClass::StationList); // Station list window. return true; } diff --git a/src/subsidy.cpp b/src/subsidy.cpp index 559e952509..a113084b44 100644 --- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -82,7 +82,7 @@ void Subsidy::AwardTo(CompanyID company) AI::BroadcastNewEvent(new ScriptEventSubsidyAwarded(this->index)); Game::NewEvent(new ScriptEventSubsidyAwarded(this->index)); - InvalidateWindowData(WC_SUBSIDIES_LIST, 0); + InvalidateWindowData(WindowClass::SubsidyList, 0); } /** @@ -128,7 +128,7 @@ void DeleteSubsidyWith(Source source) } if (dirty) { - InvalidateWindowData(WC_SUBSIDIES_LIST, 0); + InvalidateWindowData(WindowClass::SubsidyList, 0); RebuildSubsidisedSourceAndDestinationCache(); } } @@ -182,7 +182,7 @@ void CreateSubsidy(CargoType cargo_type, Source src, Source dst) AI::BroadcastNewEvent(new ScriptEventSubsidyOffer(s->index)); Game::NewEvent(new ScriptEventSubsidyOffer(s->index)); - InvalidateWindowData(WC_SUBSIDIES_LIST, 0); + InvalidateWindowData(WindowClass::SubsidyList, 0); } /** @@ -479,7 +479,7 @@ static const IntervalTimer _economy_subsidies_monthly({TimerGa modified |= passenger_subsidy || town_subsidy || industry_subsidy; - if (modified) InvalidateWindowData(WC_SUBSIDIES_LIST, 0); + if (modified) InvalidateWindowData(WindowClass::SubsidyList, 0); }); /** diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 2b7ec5e446..d32e4bbac2 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -282,7 +282,7 @@ static constexpr std::initializer_list _nested_subsidies_list_widge /** Window definition for the subsidies window. */ static WindowDesc _subsidies_list_desc( WindowPosition::Automatic, "list_subsidies", 500, 127, - WC_SUBSIDIES_LIST, WC_NONE, + WindowClass::SubsidyList, WindowClass::None, {}, _nested_subsidies_list_widgets ); diff --git a/src/table/settings/difficulty_settings.ini b/src/table/settings/difficulty_settings.ini index 1b91b765ea..ce31746b5c 100644 --- a/src/table/settings/difficulty_settings.ini +++ b/src/table/settings/difficulty_settings.ini @@ -319,5 +319,5 @@ def = false str = STR_CONFIG_SETTING_INFINITE_MONEY strhelp = STR_CONFIG_SETTING_INFINITE_MONEY_HELPTEXT cat = SC_BASIC -post_cb = [](auto) { SetWindowDirty(WC_STATUS_BAR, 0); } +post_cb = [](auto) { SetWindowDirty(WindowClass::Statusbar, 0); } diff --git a/src/table/settings/economy_settings.ini b/src/table/settings/economy_settings.ini index 74d6240798..6719d8fa9e 100644 --- a/src/table/settings/economy_settings.ini +++ b/src/table/settings/economy_settings.ini @@ -125,7 +125,7 @@ flags = SettingFlag::NoNetwork def = false str = STR_CONFIG_SETTING_NOISE_LEVEL strhelp = STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT -post_cb = [](auto new_value) { InvalidateWindowClassesData(WC_TOWN_VIEW, new_value); } +post_cb = [](auto new_value) { InvalidateWindowClassesData(WindowClass::TownView, new_value); } [SDT_BOOL] var = economy.inflation @@ -147,7 +147,7 @@ def = true str = STR_CONFIG_SETTING_BRIBE strhelp = STR_CONFIG_SETTING_BRIBE_HELPTEXT help_cb = SettingHelpWallclock -post_cb = [](auto) { InvalidateWindowClassesData(WC_TOWN_AUTHORITY); } +post_cb = [](auto) { InvalidateWindowClassesData(WindowClass::TownAuthority); } cat = SC_BASIC [SDT_BOOL] @@ -157,7 +157,7 @@ def = true str = STR_CONFIG_SETTING_ALLOW_EXCLUSIVE strhelp = STR_CONFIG_SETTING_ALLOW_EXCLUSIVE_HELPTEXT help_cb = SettingHelpWallclock -post_cb = [](auto) { InvalidateWindowClassesData(WC_TOWN_AUTHORITY); } +post_cb = [](auto) { InvalidateWindowClassesData(WindowClass::TownAuthority); } cat = SC_BASIC [SDT_BOOL] @@ -166,7 +166,7 @@ from = SLV_165 def = true str = STR_CONFIG_SETTING_ALLOW_FUND_BUILDINGS strhelp = STR_CONFIG_SETTING_ALLOW_FUND_BUILDINGS_HELPTEXT -post_cb = [](auto) { InvalidateWindowClassesData(WC_TOWN_AUTHORITY); } +post_cb = [](auto) { InvalidateWindowClassesData(WindowClass::TownAuthority); } cat = SC_BASIC [SDT_BOOL] @@ -175,7 +175,7 @@ from = SLV_160 def = true str = STR_CONFIG_SETTING_ALLOW_FUND_ROAD strhelp = STR_CONFIG_SETTING_ALLOW_FUND_ROAD_HELPTEXT -post_cb = [](auto) { InvalidateWindowClassesData(WC_TOWN_AUTHORITY); } +post_cb = [](auto) { InvalidateWindowClassesData(WindowClass::TownAuthority); } cat = SC_BASIC [SDT_BOOL] @@ -197,7 +197,7 @@ str = STR_CONFIG_SETTING_ECONOMY_TYPE strhelp = STR_CONFIG_SETTING_ECONOMY_TYPE_HELPTEXT help_cb = SettingHelpWallclock strval = STR_CONFIG_SETTING_ECONOMY_TYPE_ORIGINAL -post_cb = [](auto) { InvalidateWindowClassesData(WC_INDUSTRY_VIEW); } +post_cb = [](auto) { InvalidateWindowClassesData(WindowClass::IndustryView); } cat = SC_BASIC [SDT_VAR] @@ -315,7 +315,7 @@ from = SLV_166 def = false str = STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE strhelp = STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE_HELPTEXT -post_cb = [](auto) { InvalidateWindowClassesData(WC_COMPANY_INFRASTRUCTURE); } +post_cb = [](auto) { InvalidateWindowClassesData(WindowClass::CompanyInfrastructure); } cat = SC_BASIC [SDT_VAR] @@ -385,4 +385,4 @@ str = STR_CONFIG_SETTING_CARGO_AGING_RATE strhelp = STR_CONFIG_SETTING_CARGO_AGING_RATE_HELPTEXT strval = STR_CONFIG_SETTING_CARGO_AGING_RATE_VALUE cat = SC_EXPERT -post_cb = [](auto) { InvalidateWindowData(WC_PAYMENT_RATES, 0); } +post_cb = [](auto) { InvalidateWindowData(WindowClass::CargoPaymentRatesGraph, 0); } diff --git a/src/table/settings/game_settings.ini b/src/table/settings/game_settings.ini index d273dd04bf..5596adfd5f 100644 --- a/src/table/settings/game_settings.ini +++ b/src/table/settings/game_settings.ini @@ -139,7 +139,7 @@ from = SLV_106 def = true str = STR_CONFIG_SETTING_DISTANT_JOIN_STATIONS strhelp = STR_CONFIG_SETTING_DISTANT_JOIN_STATIONS_HELPTEXT -post_cb = [](auto) { CloseWindowById(WC_SELECT_STATION, 0); } +post_cb = [](auto) { CloseWindowById(WindowClass::JoinStation, 0); } [SDT_OMANY] var = vehicle.road_side diff --git a/src/table/settings/gui_settings.ini b/src/table/settings/gui_settings.ini index cc362c33fd..d068a134a6 100644 --- a/src/table/settings/gui_settings.ini +++ b/src/table/settings/gui_settings.ini @@ -447,7 +447,7 @@ str = STR_CONFIG_SETTING_TIMETABLE_MODE strhelp = STR_CONFIG_SETTING_TIMETABLE_MODE_HELPTEXT strval = STR_CONFIG_SETTING_TIMETABLE_MODE_DAYS pre_cb = CanChangeTimetableMode -post_cb = [](auto) { InvalidateWindowClassesData(WC_VEHICLE_TIMETABLE, VIWD_MODIFY_ORDERS); } +post_cb = [](auto) { InvalidateWindowClassesData(WindowClass::VehicleTimetable, VIWD_MODIFY_ORDERS); } cat = SC_ADVANCED [SDTC_BOOL] @@ -456,7 +456,7 @@ flags = SettingFlag::NotInSave, SettingFlag::NoNetworkSync def = true str = STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE strhelp = STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT -post_cb = [](auto) { InvalidateWindowClassesData(WC_VEHICLE_TIMETABLE, VIWD_MODIFY_ORDERS); } +post_cb = [](auto) { InvalidateWindowClassesData(WindowClass::VehicleTimetable, VIWD_MODIFY_ORDERS); } [SDTC_BOOL] var = gui.quick_goto @@ -501,7 +501,7 @@ max = 1 str = STR_CONFIG_SETTING_SIGNAL_GUI_MODE strhelp = STR_CONFIG_SETTING_SIGNAL_GUI_MODE_HELPTEXT strval = STR_CONFIG_SETTING_SIGNAL_GUI_MODE_PATH -post_cb = [](auto) { CloseWindowByClass(WC_BUILD_SIGNAL); } +post_cb = [](auto) { CloseWindowByClass(WindowClass::BuildSignal); } cat = SC_ADVANCED [SDTC_VAR] @@ -548,7 +548,7 @@ max = 20 str = STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY strhelp = STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY_HELPTEXT strval = STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY_VALUE -post_cb = [](auto) { InvalidateWindowData(WC_BUILD_SIGNAL, 0); } +post_cb = [](auto) { InvalidateWindowData(WindowClass::BuildSignal, 0); } cat = SC_BASIC [SDTC_BOOL] @@ -626,7 +626,7 @@ interval = 1 str = STR_CONFIG_SETTING_STOP_LOCATION strhelp = STR_CONFIG_SETTING_STOP_LOCATION_HELPTEXT strval = STR_CONFIG_SETTING_STOP_LOCATION_NEAR_END -post_cb = [](auto) { SetWindowClassesDirty(WC_VEHICLE_ORDERS); } +post_cb = [](auto) { SetWindowClassesDirty(WindowClass::VehicleOrders); } cat = SC_BASIC [SDTC_BOOL] @@ -821,7 +821,7 @@ cat = SC_EXPERT var = gui.ai_developer_tools flags = SettingFlag::NotInSave, SettingFlag::NoNetworkSync def = false -post_cb = [](auto) { InvalidateWindowClassesData(WC_GAME_OPTIONS); InvalidateWindowClassesData(WC_SCRIPT_DEBUG); InvalidateWindowClassesData(WC_SCRIPT_SETTINGS); } +post_cb = [](auto) { InvalidateWindowClassesData(WindowClass::GameOptions); InvalidateWindowClassesData(WindowClass::ScriptDebug); InvalidateWindowClassesData(WindowClass::ScriptSettings); } cat = SC_EXPERT [SDTC_BOOL] diff --git a/src/table/settings/world_settings.ini b/src/table/settings/world_settings.ini index 0bcda9e8bb..3b7f97574a 100644 --- a/src/table/settings/world_settings.ini +++ b/src/table/settings/world_settings.ini @@ -365,7 +365,7 @@ str = STR_CONFIG_SETTING_MAP_HEIGHT_LIMIT strhelp = STR_CONFIG_SETTING_MAP_HEIGHT_LIMIT_HELPTEXT strval = STR_CONFIG_SETTING_MAP_HEIGHT_LIMIT_VALUE pre_cb = CheckMaxHeightLevel -post_cb = [](auto) { InvalidateWindowClassesData(WC_SMALLMAP, 2); } +post_cb = [](auto) { InvalidateWindowClassesData(WindowClass::SmallMap, 2); } cat = SC_ADVANCED [SDT_BOOL] @@ -565,7 +565,7 @@ max = 2 str = STR_CONFIG_SETTING_RAW_INDUSTRY_CONSTRUCTION_METHOD strhelp = STR_CONFIG_SETTING_RAW_INDUSTRY_CONSTRUCTION_METHOD_HELPTEXT strval = STR_CONFIG_SETTING_RAW_INDUSTRY_CONSTRUCTION_METHOD_NONE -post_cb = [](auto) { InvalidateWindowData(WC_BUILD_INDUSTRY, 0); } +post_cb = [](auto) { InvalidateWindowData(WindowClass::BuildIndustry, 0); } cat = SC_BASIC [SDT_VAR] diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index cbb46f1a6c..e55ee4c2e2 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -73,7 +73,7 @@ static void GenerateDesertArea(TileIndex end, TileIndex start) MarkTileDirtyByTile(tile); } old_generating_world.Restore(); - InvalidateWindowClassesData(WC_TOWN_VIEW, 0); + InvalidateWindowClassesData(WindowClass::TownView, 0); } /** @@ -265,7 +265,7 @@ struct TerraformToolbarWindow : Window { Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override { Point pt = GetToolbarAlignedWindowPosition(sm_width); - if (FindWindowByClass(WC_BUILD_TOOLBAR) != nullptr && !_settings_client.gui.link_terraform_toolbar) pt.y += sm_height; + if (FindWindowByClass(WindowClass::BuildToolbar) != nullptr && !_settings_client.gui.link_terraform_toolbar) pt.y += sm_height; return pt; } @@ -359,7 +359,7 @@ static constexpr std::initializer_list _nested_terraform_widgets = /** Window definition for the landscaping toolbar. */ static WindowDesc _terraform_desc( WindowPosition::Manual, "toolbar_landscape", 0, 0, - WC_SCEN_LAND_GEN, WC_NONE, + WindowClass::ScenarioGenerateLandscape, WindowClass::None, WindowDefaultFlag::Construction, _nested_terraform_widgets, &TerraformToolbarWindow::hotkeys @@ -375,7 +375,7 @@ Window *ShowTerraformToolbar(Window *link) if (!Company::IsValidID(_local_company)) return nullptr; /* Delete the terraform toolbar to place it again. */ - CloseWindowById(WC_SCEN_LAND_GEN, 0, true); + CloseWindowById(WindowClass::ScenarioGenerateLandscape, 0, true); if (link == nullptr) return AllocateWindowDescFront(_terraform_desc, 0); @@ -747,7 +747,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { /** Window definition for the landscaping toolbar for he scenario editor. */ static WindowDesc _scen_edit_land_gen_desc( WindowPosition::Automatic, "toolbar_landscape_scen", 0, 0, - WC_SCEN_LAND_GEN, WC_NONE, + WindowClass::ScenarioGenerateLandscape, WindowClass::None, WindowDefaultFlag::Construction, _nested_scen_edit_land_gen_widgets, &ScenarioEditorLandscapeGenerationWindow::hotkeys diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index e6c508ec54..0ccf3f2325 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -78,7 +78,7 @@ static constexpr std::initializer_list _nested_textfile_widgets = { /** Window definition for the textfile window */ static WindowDesc _textfile_desc( WindowPosition::Center, "textfile", 630, 460, - WC_TEXTFILE, WC_NONE, + WindowClass::Textfile, WindowClass::None, {}, _nested_textfile_widgets ); diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index a7a01e8a05..e26157acb0 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -117,7 +117,7 @@ static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16_t va NOT_REACHED(); } } - SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index); + SetWindowDirty(WindowClass::VehicleTimetable, v->index); } } @@ -289,14 +289,14 @@ CommandCost CmdSetVehicleOnTime(DoCommandFlags flags, VehicleID veh, bool apply_ if (!v->vehicle_flags.Test(VehicleFlag::TimetableStarted)) continue; u->lateness_counter -= most_late; - SetWindowDirty(WC_VEHICLE_TIMETABLE, u->index); + SetWindowDirty(WindowClass::VehicleTimetable, u->index); } } } else { v->lateness_counter = 0; /* Unbunching data is no longer valid. */ v->ResetDepotUnbunching(); - SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index); + SetWindowDirty(WindowClass::VehicleTimetable, v->index); } } @@ -400,7 +400,7 @@ CommandCost CmdSetTimetableStart(DoCommandFlags flags, VehicleID veh_id, bool ti /* Unbunching data is no longer valid. */ v->ResetDepotUnbunching(); - SetWindowDirty(WC_VEHICLE_TIMETABLE, w->index); + SetWindowDirty(WindowClass::VehicleTimetable, w->index); ++idx; } @@ -452,7 +452,7 @@ CommandCost CmdAutofillTimetable(DoCommandFlags flags, VehicleID veh, bool autof v2->vehicle_flags.Reset(VehicleFlag::AutofillTimetable); v2->vehicle_flags.Reset(VehicleFlag::AutofillPreserveWaitTime); } - SetWindowDirty(WC_VEHICLE_TIMETABLE, v2->index); + SetWindowDirty(WindowClass::VehicleTimetable, v2->index); } } @@ -498,7 +498,7 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling) } v->vehicle_flags.Set(VehicleFlag::TimetableStarted); - SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index); + SetWindowDirty(WindowClass::VehicleTimetable, v->index); } if (!v->vehicle_flags.Test(VehicleFlag::TimetableStarted)) return; @@ -568,6 +568,6 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling) } for (v = v->FirstShared(); v != nullptr; v = v->NextShared()) { - SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index); + SetWindowDirty(WindowClass::VehicleTimetable, v->index); } } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 588efd9f00..b07cf39b36 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -852,7 +852,7 @@ static constexpr std::initializer_list _nested_timetable_widgets = /** Window definition for the timetable window. */ static WindowDesc _timetable_desc( WindowPosition::Automatic, "view_vehicle_timetable", 400, 130, - WC_VEHICLE_TIMETABLE, WC_VEHICLE_VIEW, + WindowClass::VehicleTimetable, WindowClass::VehicleView, WindowDefaultFlag::Construction, _nested_timetable_widgets ); @@ -863,7 +863,7 @@ static WindowDesc _timetable_desc( */ void ShowTimetableWindow(const Vehicle *v) { - CloseWindowById(WC_VEHICLE_DETAILS, v->index, false); - CloseWindowById(WC_VEHICLE_ORDERS, v->index, false); + CloseWindowById(WindowClass::VehicleDetails, v->index, false); + CloseWindowById(WindowClass::VehicleOrders, v->index, false); AllocateWindowDescFront(_timetable_desc, v->index); } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 409802324e..083e735f78 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -207,7 +207,7 @@ static CallBackFunction SelectSignTool() ResetObjectToPlace(); return CallBackFunction::None; } else { - SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0); + SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, HT_RECT, WindowClass::MainToolbar, 0); return CallBackFunction::PlaceSign; } } @@ -337,7 +337,7 @@ static CallBackFunction MenuClickSettings(int index) case OptionMenuEntries::ShowSigns: _display_opt.Flip(DisplayOption::ShowSigns); break; case OptionMenuEntries::ShowCompetitorSigns: _display_opt.Flip(DisplayOption::ShowCompetitorSigns); - InvalidateWindowClassesData(WC_SIGN_LIST, -1); + InvalidateWindowClassesData(WindowClass::SignList, -1); break; case OptionMenuEntries::FullAnimation: _display_opt.Flip(DisplayOption::FullAnimation); CheckBlitter(); break; case OptionMenuEntries::FullDetails: _display_opt.Flip(DisplayOption::FullDetail); break; @@ -1075,7 +1075,7 @@ static CallBackFunction PlaceLandBlockInfo() ResetObjectToPlace(); return CallBackFunction::None; } else { - SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0); + SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, HT_RECT, WindowClass::MainToolbar, 0); return CallBackFunction::PlaceLandInfo; } } @@ -2265,7 +2265,7 @@ static constexpr std::initializer_list _nested_toolbar_normal_widge /** Window definition for the normal (top) toolbar. */ static WindowDesc _toolb_normal_desc( WindowPosition::Manual, {}, 0, 0, - WC_MAIN_TOOLBAR, WC_NONE, + WindowClass::MainToolbar, WindowClass::None, {WindowDefaultFlag::NoFocus, WindowDefaultFlag::NoClose}, _nested_toolbar_normal_widgets, &MainToolbarWindow::hotkeys @@ -2609,7 +2609,7 @@ static constexpr std::initializer_list _nested_toolb_scen_widgets = /** Window definition for the scenario editor (top) toolbar window. */ static WindowDesc _toolb_scen_desc( WindowPosition::Manual, {}, 0, 0, - WC_MAIN_TOOLBAR, WC_NONE, + WindowClass::MainToolbar, WindowClass::None, {WindowDefaultFlag::NoFocus, WindowDefaultFlag::NoClose}, _nested_toolb_scen_widgets, &ScenarioEditorToolbarWindow::hotkeys diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index f1cff82fda..a3feb5ea06 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -118,8 +118,8 @@ Town::~Town() /* Delete town authority window * and remove from list of sorted towns */ - CloseWindowById(WC_TOWN_VIEW, this->index); - CloseWindowById(WC_TOWN_CARGO_GRAPH, this->index); + CloseWindowById(WindowClass::TownView, this->index); + CloseWindowById(WindowClass::TownCargoGraph, this->index); #ifdef WITH_ASSERT /* Check no industry is related to us. */ @@ -174,7 +174,7 @@ Town::~Town() */ void Town::PostDestructor([[maybe_unused]] size_t index) { - InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_FORCE_REBUILD); + InvalidateWindowData(WindowClass::TownDirectory, 0, TDIWD_FORCE_REBUILD); UpdateNearestTownForRoadTiles(false); /* Give objects a new home! */ @@ -404,7 +404,7 @@ void Town::UpdateVirtCoord() _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeTown(this->index)); - SetWindowDirty(WC_TOWN_VIEW, this->index); + SetWindowDirty(WindowClass::TownView, this->index); } /** Update the virtual coords needed to draw the town sign for all towns. */ @@ -433,10 +433,10 @@ static void ChangePopulation(Town *t, int mod) t->cache.population += mod; if (_generating_town) [[unlikely]] return; - InvalidateWindowData(WC_TOWN_VIEW, t->index); // Cargo requirements may appear/vanish for small populations + InvalidateWindowData(WindowClass::TownView, t->index); // Cargo requirements may appear/vanish for small populations if (_settings_client.gui.population_in_label) t->UpdateVirtCoord(); - InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_POPULATION_CHANGE); + InvalidateWindowData(WindowClass::TownDirectory, 0, TDIWD_POPULATION_CHANGE); } /** @@ -2074,7 +2074,7 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32_t townnameparts, TownSi } while (--i); t->UpdateVirtCoord(); - InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_FORCE_REBUILD); + InvalidateWindowData(WindowClass::TownDirectory, 0, TDIWD_FORCE_REBUILD); t->cache.num_houses -= x; UpdateTownRadius(t); @@ -3143,7 +3143,7 @@ CommandCost CmdRenameTown(DoCommandFlags flags, TownID town_id, const std::strin } t->UpdateVirtCoord(); - InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_FORCE_RESORT); + InvalidateWindowData(WindowClass::TownDirectory, 0, TDIWD_FORCE_RESORT); ClearAllStationCachedNames(); ClearAllIndustryCachedNames(); UpdateAllStationVirtCoords(); @@ -3188,7 +3188,7 @@ CommandCost CmdTownCargoGoal(DoCommandFlags flags, TownID town_id, TownAcceptanc if (flags.Test(DoCommandFlag::Execute)) { t->goal[tae] = goal; UpdateTownGrowth(t); - InvalidateWindowData(WC_TOWN_VIEW, town_id); + InvalidateWindowData(WindowClass::TownView, town_id); } return CommandCost(); @@ -3210,7 +3210,7 @@ CommandCost CmdTownSetText(DoCommandFlags flags, TownID town_id, const EncodedSt if (flags.Test(DoCommandFlag::Execute)) { t->text.clear(); if (!text.empty()) t->text = text; - InvalidateWindowData(WC_TOWN_VIEW, town_id); + InvalidateWindowData(WindowClass::TownView, town_id); } return CommandCost(); @@ -3247,7 +3247,7 @@ CommandCost CmdTownGrowthRate(DoCommandFlags flags, TownID town_id, uint16_t gro t->flags.Set(TownFlag::CustomGrowth); } UpdateTownGrowth(t); - InvalidateWindowData(WC_TOWN_VIEW, town_id); + InvalidateWindowData(WindowClass::TownView, town_id); } return CommandCost(); @@ -3273,7 +3273,7 @@ CommandCost CmdTownRating(DoCommandFlags flags, TownID town_id, CompanyID compan int16_t new_rating = Clamp(rating, RATING_MINIMUM, RATING_MAXIMUM); if (flags.Test(DoCommandFlag::Execute)) { t->ratings[company_id] = new_rating; - InvalidateWindowData(WC_TOWN_AUTHORITY, town_id); + InvalidateWindowData(WindowClass::TownAuthority, town_id); } return CommandCost(); @@ -3602,7 +3602,7 @@ static CommandCost TownActionFundBuildings(Town *t, DoCommandFlags flags) */ t->grow_counter = std::min(t->grow_counter, 2 * Ticks::TOWN_GROWTH_TICKS - (t->growth_rate - t->grow_counter) % Ticks::TOWN_GROWTH_TICKS); - SetWindowDirty(WC_TOWN_VIEW, t->index); + SetWindowDirty(WindowClass::TownView, t->index); } return CommandCost(); } @@ -3625,7 +3625,7 @@ static CommandCost TownActionBuyRights(Town *t, DoCommandFlags flags) ModifyStationRatingAround(t->xy, _current_company, 130, 17); - SetWindowClassesDirty(WC_STATION_VIEW); + SetWindowClassesDirty(WindowClass::StationView); /* Spawn news message */ auto cni = std::make_unique(STR_NEWS_EXCLUSIVE_RIGHTS_TITLE, Company::Get(_current_company)); @@ -3668,7 +3668,7 @@ static CommandCost TownActionBribe(Town *t, DoCommandFlags flags) */ if (t->ratings[_current_company] > RATING_BRIBE_DOWN_TO) { t->ratings[_current_company] = RATING_BRIBE_DOWN_TO; - SetWindowDirty(WC_TOWN_AUTHORITY, t->index); + SetWindowDirty(WindowClass::TownAuthority, t->index); } } else { ChangeTownRating(t, RATING_BRIBE_UP_STEP, RATING_BRIBE_MAXIMUM, DoCommandFlag::Execute); @@ -3769,7 +3769,7 @@ CommandCost CmdDoTownAction(DoCommandFlags flags, TownID town_id, TownAction act if (ret.Failed()) return ret; if (flags.Test(DoCommandFlag::Execute)) { - SetWindowDirty(WC_TOWN_AUTHORITY, town_id); + SetWindowDirty(WindowClass::TownAuthority, town_id); } return cost; @@ -3822,7 +3822,7 @@ static void UpdateTownRating(Town *t) *it = Clamp(*it, RATING_MINIMUM, RATING_MAXIMUM); } - SetWindowDirty(WC_TOWN_AUTHORITY, t->index); + SetWindowDirty(WindowClass::TownAuthority, t->index); } @@ -3897,7 +3897,7 @@ static void UpdateTownGrowthRate(Town *t) uint old_rate = t->growth_rate; t->growth_rate = GetNormalGrowthRate(t); UpdateTownGrowCounter(t, old_rate); - SetWindowDirty(WC_TOWN_VIEW, t->index); + SetWindowDirty(WindowClass::TownView, t->index); } /** @@ -3909,7 +3909,7 @@ static void UpdateTownGrowth(Town *t) UpdateTownGrowthRate(t); t->flags.Reset(TownFlag::IsGrowing); - SetWindowDirty(WC_TOWN_VIEW, t->index); + SetWindowDirty(WindowClass::TownView, t->index); if (_settings_game.economy.town_growth_rate == 0 && t->fund_buildings_months == 0) return; @@ -3932,14 +3932,14 @@ static void UpdateTownGrowth(Town *t) if (t->flags.Test(TownFlag::CustomGrowth)) { if (t->growth_rate != TOWN_GROWTH_RATE_NONE) t->flags.Set(TownFlag::IsGrowing); - SetWindowDirty(WC_TOWN_VIEW, t->index); + SetWindowDirty(WindowClass::TownView, t->index); return; } if (t->fund_buildings_months == 0 && CountActiveStations(t) == 0 && !Chance16(1, 12)) return; t->flags.Set(TownFlag::IsGrowing); - SetWindowDirty(WC_TOWN_VIEW, t->index); + SetWindowDirty(WindowClass::TownView, t->index); } /** @@ -4094,7 +4094,7 @@ void ChangeTownRating(Town *t, int add, int max, DoCommandFlags flags) } else { t->have_ratings.Set(_current_company); t->ratings[_current_company] = rating; - SetWindowDirty(WC_TOWN_AUTHORITY, t->index); + SetWindowDirty(WindowClass::TownAuthority, t->index); } } @@ -4189,7 +4189,7 @@ static const IntervalTimer _economy_towns_monthly({TimerGameEc UpdateTownGrowth(t); UpdateTownRating(t); - SetWindowDirty(WC_TOWN_VIEW, t->index); + SetWindowDirty(WindowClass::TownView, t->index); } }); diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 028163f19c..72ecd5699b 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -333,7 +333,7 @@ public: /** Window definition for the town authority window. */ static WindowDesc _town_authority_desc( WindowPosition::Automatic, "view_town_authority", 317, 222, - WC_TOWN_AUTHORITY, WC_NONE, + WindowClass::TownAuthority, WindowClass::None, {}, _nested_town_authority_widgets ); @@ -640,7 +640,7 @@ static constexpr std::initializer_list _nested_town_game_view_widge /** Window definition for the town view window. */ static WindowDesc _town_game_view_desc( WindowPosition::Automatic, "view_town", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL, - WC_TOWN_VIEW, WC_NONE, + WindowClass::TownView, WindowClass::None, {}, _nested_town_game_view_widgets ); @@ -676,7 +676,7 @@ static constexpr std::initializer_list _nested_town_editor_view_wid /** Window definition for the town view window of the scenario edtior. */ static WindowDesc _town_editor_view_desc( WindowPosition::Automatic, "view_town_scen", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL, - WC_TOWN_VIEW, WC_NONE, + WindowClass::TownView, WindowClass::None, {}, _nested_town_editor_view_widgets ); @@ -1049,7 +1049,7 @@ const std::initializer_list TownDirectoryWind /** Window definition for the town directory window. */ static WindowDesc _town_directory_desc( WindowPosition::Automatic, "list_towns", 208, 202, - WC_TOWN_DIRECTORY, WC_NONE, + WindowClass::TownDirectory, WindowClass::None, {}, _nested_town_directory_widgets, &TownDirectoryWindow::hotkeys @@ -1057,7 +1057,7 @@ static WindowDesc _town_directory_desc( void ShowTownDirectory() { - if (BringWindowToFrontById(WC_TOWN_DIRECTORY, 0)) return; + if (BringWindowToFrontById(WindowClass::TownDirectory, 0)) return; new TownDirectoryWindow(_town_directory_desc); } @@ -1350,7 +1350,7 @@ public: /** Window definition for the town funding window. */ static WindowDesc _found_town_desc( WindowPosition::Automatic, "build_town", 160, 162, - WC_FOUND_TOWN, WC_NONE, + WindowClass::FoundTown, WindowClass::None, WindowDefaultFlag::Construction, _nested_found_town_widgets ); @@ -1874,7 +1874,7 @@ static constexpr std::initializer_list _nested_build_house_widgets /** Window definition for the house building window. */ static WindowDesc _build_house_desc( WindowPosition::Automatic, "build_house", 0, 0, - WC_BUILD_HOUSE, WC_BUILD_TOOLBAR, + WindowClass::BuildHouse, WindowClass::BuildToolbar, WindowDefaultFlag::Construction, _nested_build_house_widgets, &BuildHouseWindow::hotkeys @@ -1882,6 +1882,6 @@ static WindowDesc _build_house_desc( void ShowBuildHousePicker(Window *parent) { - if (BringWindowToFrontById(WC_BUILD_HOUSE, 0)) return; + if (BringWindowToFrontById(WindowClass::BuildHouse, 0)) return; new BuildHouseWindow(_build_house_desc, parent); } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 2fe262aa5a..926b2c1030 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -241,13 +241,13 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes) if (this->IsFrontEngine()) { this->UpdateAcceleration(); - SetWindowDirty(WC_VEHICLE_DETAILS, this->index); - InvalidateWindowData(WC_VEHICLE_REFIT, this->index, VIWD_CONSIST_CHANGED); - InvalidateWindowData(WC_VEHICLE_ORDERS, this->index, VIWD_CONSIST_CHANGED); + SetWindowDirty(WindowClass::VehicleDetails, this->index); + InvalidateWindowData(WindowClass::VehicleRefit, this->index, VIWD_CONSIST_CHANGED); + InvalidateWindowData(WindowClass::VehicleOrders, this->index, VIWD_CONSIST_CHANGED); InvalidateNewGRFInspectWindow(GrfSpecFeature::Trains, this->index); /* If the consist is changed while in a depot, the vehicle view window must be invalidated to update the availability of refitting. */ - InvalidateWindowData(WC_VEHICLE_VIEW, this->index, VIWD_CONSIST_CHANGED); + InvalidateWindowData(WindowClass::VehicleView, this->index, VIWD_CONSIST_CHANGED); } } @@ -691,7 +691,7 @@ static CommandCost CmdBuildRailWagon(DoCommandFlags flags, TileIndex tile, const v->SetWagon(); v->SetFreeWagon(); - InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); + InvalidateWindowData(WindowClass::VehicleDepot, v->tile); v->cargo_type = e->GetDefaultCargoType(); assert(IsValidCargoType(v->cargo_type)); @@ -1235,8 +1235,8 @@ static void NormaliseTrainHead(Train *head) if (!head->IsFrontEngine()) return; /* Update the refit button and window */ - InvalidateWindowData(WC_VEHICLE_REFIT, head->index, VIWD_CONSIST_CHANGED); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, head->index, WID_VV_REFIT); + InvalidateWindowData(WindowClass::VehicleRefit, head->index, VIWD_CONSIST_CHANGED); + SetWindowWidgetDirty(WindowClass::VehicleView, head->index, WID_VV_REFIT); /* If we don't have a unit number yet, set one. */ if (head->unitnumber != 0) return; @@ -1381,13 +1381,13 @@ CommandCost CmdMoveRailVehicle(DoCommandFlags flags, VehicleID src_veh, VehicleI */ if (src == original_src_head && src->IsEngine() && !src->IsFrontEngine()) { /* Cases #2 and #3: the front engine gets trashed. */ - CloseWindowById(WC_VEHICLE_VIEW, src->index); - CloseWindowById(WC_VEHICLE_ORDERS, src->index); - CloseWindowById(WC_VEHICLE_REFIT, src->index); - CloseWindowById(WC_VEHICLE_DETAILS, src->index); - CloseWindowById(WC_VEHICLE_TIMETABLE, src->index); + CloseWindowById(WindowClass::VehicleView, src->index); + CloseWindowById(WindowClass::VehicleOrders, src->index); + CloseWindowById(WindowClass::VehicleRefit, src->index); + CloseWindowById(WindowClass::VehicleDetails, src->index); + CloseWindowById(WindowClass::VehicleTimetable, src->index); DeleteNewGRFInspectWindow(GrfSpecFeature::Trains, src->index); - SetWindowDirty(WC_COMPANY, _current_company); + SetWindowDirty(WindowClass::Company, _current_company); if (src_head != nullptr && src_head->IsFrontEngine()) { /* Cases #?b: Transfer order, unit number and other stuff @@ -1406,7 +1406,7 @@ CommandCost CmdMoveRailVehicle(DoCommandFlags flags, VehicleID src_veh, VehicleI * we should be put in the default group. */ if (original_src_head != src && dst_head == src) { SetTrainGroupID(src, DEFAULT_GROUP); - SetWindowDirty(WC_COMPANY, _current_company); + SetWindowDirty(WindowClass::Company, _current_company); } /* Handle 'new engine' part of cases #1b, #2b, #3b, #4b and #5 in NormaliseTrainHead. */ @@ -1427,8 +1427,8 @@ CommandCost CmdMoveRailVehicle(DoCommandFlags flags, VehicleID src_veh, VehicleI if (dst_head != nullptr) dst_head->First()->MarkDirty(); /* We are undoubtedly changing something in the depot and train list. */ - InvalidateWindowData(WC_VEHICLE_DEPOT, src->tile); - InvalidateWindowClassesData(WC_TRAINS_LIST, 0); + InvalidateWindowData(WindowClass::VehicleDepot, src->tile); + InvalidateWindowClassesData(WindowClass::TrainList, 0); } else { /* We don't want to execute what we're just tried. */ RestoreTrainBackup(original_src); @@ -1511,8 +1511,8 @@ CommandCost CmdSellRailWagon(DoCommandFlags flags, Vehicle *t, bool sell_chain, NormaliseTrainHead(new_head); /* We are undoubtedly changing something in the depot and train list. */ - InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); - InvalidateWindowClassesData(WC_TRAINS_LIST, 0); + InvalidateWindowData(WindowClass::VehicleDepot, v->tile); + InvalidateWindowClassesData(WindowClass::TrainList, 0); /* Actually delete the sold 'goods' */ delete sell_head; @@ -1604,7 +1604,7 @@ static void MarkTrainAsStuck(Train *consist) consist->subspeed = 0; consist->SetLastSpeed(); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, consist->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, consist->index, WID_VV_START_STOP); } } @@ -2022,7 +2022,7 @@ static void ReverseTrainDirection(Train *consist) Train *moving_front = consist->GetMovingFront(); if (IsRailDepotTile(moving_front->tile)) { if (IsWholeTrainInsideDepot(consist)) return; - InvalidateWindowData(WC_VEHICLE_DEPOT, moving_front->tile); + InvalidateWindowData(WindowClass::VehicleDepot, moving_front->tile); } /* Clear path reservation in front if train is not stuck. */ @@ -2062,7 +2062,7 @@ static void ReverseTrainDirection(Train *consist) } if (IsRailDepotTile(moving_front->tile)) { - InvalidateWindowData(WC_VEHICLE_DEPOT, moving_front->tile); + InvalidateWindowData(WindowClass::VehicleDepot, moving_front->tile); } consist->flags.Flip(VehicleRailFlag::Reversed); @@ -2084,7 +2084,7 @@ static void ReverseTrainDirection(Train *consist) /* If we are inside a depot after reversing, don't bother with path reserving. */ if (moving_front->track == TRACK_BIT_DEPOT) { /* Can't be stuck here as inside a depot is always a safe tile. */ - if (consist->flags.Test(VehicleRailFlag::Stuck)) SetWindowWidgetDirty(WC_VEHICLE_VIEW, consist->index, WID_VV_START_STOP); + if (consist->flags.Test(VehicleRailFlag::Stuck)) SetWindowWidgetDirty(WindowClass::VehicleView, consist->index, WID_VV_START_STOP); consist->flags.Reset(VehicleRailFlag::Stuck); return; } @@ -2149,10 +2149,10 @@ CommandCost CmdReverseTrainDirection(DoCommandFlags flags, VehicleID veh_id, boo v->flags.Flip(VehicleRailFlag::Flipped); front->ConsistChanged(CCF_ARRANGE); - SetWindowDirty(WC_VEHICLE_DEPOT, front->tile); - SetWindowDirty(WC_VEHICLE_DETAILS, front->index); - InvalidateWindowData(WC_VEHICLE_VIEW, front->index); - SetWindowClassesDirty(WC_TRAINS_LIST); + SetWindowDirty(WindowClass::VehicleDepot, front->tile); + SetWindowDirty(WindowClass::VehicleDetails, front->index); + InvalidateWindowData(WindowClass::VehicleView, front->index); + SetWindowClassesDirty(WindowClass::TrainList); } } else { /* turn the whole train around */ @@ -2172,7 +2172,7 @@ CommandCost CmdReverseTrainDirection(DoCommandFlags flags, VehicleID veh_id, boo /* We cancel any 'skip signal at dangers' here */ v->force_proceed = TFP_NONE; - InvalidateWindowData(WC_VEHICLE_VIEW, v->index); + InvalidateWindowData(WindowClass::VehicleView, v->index); if (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL && v->cur_speed != 0) { v->flags.Flip(VehicleRailFlag::Reversing); @@ -2231,7 +2231,7 @@ CommandCost CmdForceTrainProceed(DoCommandFlags flags, VehicleID veh_id) if (flags.Test(DoCommandFlag::Execute)) { t->force_proceed = DetermineNextTrainForceProceeding(t); - InvalidateWindowData(WC_VEHICLE_VIEW, t->index); + InvalidateWindowData(WindowClass::VehicleView, t->index); /* Unbunching data is no longer valid. */ t->ResetDepotUnbunching(); @@ -2353,7 +2353,7 @@ static bool CheckTrainStayInDepot(Train *v) /* if the train got no power, then keep it in the depot */ if (v->gcache.cached_power == 0) { v->vehstatus.Set(VehState::Stopped); - SetWindowDirty(WC_VEHICLE_DEPOT, v->tile); + SetWindowDirty(WindowClass::VehicleDepot, v->tile); return true; } @@ -2365,7 +2365,7 @@ static bool CheckTrainStayInDepot(Train *v) if (v->force_proceed == TFP_NONE) { /* force proceed was not pressed */ if (++v->wait_counter < 37) { - SetWindowClassesDirty(WC_TRAINS_LIST); + SetWindowClassesDirty(WindowClass::TrainList); return true; } @@ -2374,7 +2374,7 @@ static bool CheckTrainStayInDepot(Train *v) seg_state = _settings_game.pf.reserve_paths ? SIGSEG_PBS : UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner); if (seg_state == SIGSEG_FULL || HasDepotReservation(v->tile)) { /* Full and no PBS signal in block or depot reserved, can't exit. */ - SetWindowClassesDirty(WC_TRAINS_LIST); + SetWindowClassesDirty(WindowClass::TrainList); return true; } } else { @@ -2391,7 +2391,7 @@ static bool CheckTrainStayInDepot(Train *v) /* Only leave when we can reserve a path to our destination. */ if (seg_state == SIGSEG_PBS && !TryPathReserve(v) && v->force_proceed == TFP_NONE) { /* No path and no force proceed. */ - SetWindowClassesDirty(WC_TRAINS_LIST); + SetWindowClassesDirty(WindowClass::TrainList); MarkTrainAsStuck(v); return true; } @@ -2402,7 +2402,7 @@ static bool CheckTrainStayInDepot(Train *v) VehicleServiceInDepot(v); v->LeaveUnbunchingDepot(); v->PlayLeaveStationSound(); - SetWindowClassesDirty(WC_TRAINS_LIST); + SetWindowClassesDirty(WindowClass::TrainList); v->track = TRACK_BIT_X; if (v->direction & 2) v->track = TRACK_BIT_Y; @@ -2414,7 +2414,7 @@ static bool CheckTrainStayInDepot(Train *v) v->UpdatePosition(); UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner); v->UpdateAcceleration(); - InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); + InvalidateWindowData(WindowClass::VehicleDepot, v->tile); return false; } @@ -2938,7 +2938,7 @@ static Track ChooseTrainTrack(Train *consist, TileIndex tile, DiagDirection ente final_dest != INVALID_TILE && IsRailDepotTile(final_dest)) { consist->current_order.SetDestination(GetDepotIndex(final_dest)); consist->dest_tile = final_dest; - SetWindowWidgetDirty(WC_VEHICLE_VIEW, consist->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, consist->index, WID_VV_START_STOP); } return best_track; @@ -2986,7 +2986,7 @@ bool TryPathReserve(Train *consist, bool mark_as_stuck, bool first_tile_okay) /* If we have a reserved path and the path ends at a safe tile, we are finished already. */ if (origin.okay && (moving_front->tile != origin.tile || first_tile_okay)) { /* Can't be stuck then. */ - if (consist->flags.Test(VehicleRailFlag::Stuck)) SetWindowWidgetDirty(WC_VEHICLE_VIEW, consist->index, WID_VV_START_STOP); + if (consist->flags.Test(VehicleRailFlag::Stuck)) SetWindowWidgetDirty(WindowClass::VehicleView, consist->index, WID_VV_START_STOP); consist->flags.Reset(VehicleRailFlag::Stuck); return true; } @@ -3014,7 +3014,7 @@ bool TryPathReserve(Train *consist, bool mark_as_stuck, bool first_tile_okay) if (consist->flags.Test(VehicleRailFlag::Stuck)) { consist->wait_counter = 0; - SetWindowWidgetDirty(WC_VEHICLE_VIEW, consist->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, consist->index, WID_VV_START_STOP); } consist->flags.Reset(VehicleRailFlag::Stuck); return true; @@ -3115,7 +3115,7 @@ static void TrainEnterStation(Train *consist, StationID station) } consist->force_proceed = TFP_NONE; - InvalidateWindowData(WC_VEHICLE_VIEW, consist->index); + InvalidateWindowData(WindowClass::VehicleView, consist->index); consist->BeginLoading(); @@ -3440,7 +3440,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse) /* However, we do not want to be stopped by PBS signals * entered via the back. */ first->force_proceed = (first->force_proceed == TFP_SIGNAL) ? TFP_STUCK : TFP_NONE; - InvalidateWindowData(WC_VEHICLE_VIEW, first->index); + InvalidateWindowData(WindowClass::VehicleView, first->index); } } @@ -3719,8 +3719,8 @@ static void DeleteLastWagon(Train *v) /* Recalculate cached train properties */ first->ConsistChanged(CCF_ARRANGE); /* Update the depot window in case a part of the consist is in a depot. */ - SetWindowDirty(WC_VEHICLE_DEPOT, first->tile); - SetWindowDirty(WC_VEHICLE_DEPOT, v->tile); + SetWindowDirty(WindowClass::VehicleDepot, first->tile); + SetWindowDirty(WindowClass::VehicleDepot, v->tile); } /* 'v' shouldn't be accessed after it has been deleted */ @@ -4033,7 +4033,7 @@ static bool TrainLocoHandler(Train *consist, bool mode) if (consist->force_proceed != TFP_NONE) { consist->flags.Reset(VehicleRailFlag::Stuck); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, consist->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, consist->index, WID_VV_START_STOP); } /* train is broken down? */ @@ -4104,13 +4104,13 @@ static bool TrainLocoHandler(Train *consist, bool mode) if (consist->force_proceed == TFP_NONE) return true; consist->flags.Reset(VehicleRailFlag::Stuck); consist->wait_counter = 0; - SetWindowWidgetDirty(WC_VEHICLE_VIEW, consist->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, consist->index, WID_VV_START_STOP); } } if (consist->current_order.IsType(OT_LEAVESTATION)) { consist->current_order.Free(); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, consist->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, consist->index, WID_VV_START_STOP); return true; } @@ -4120,7 +4120,7 @@ static bool TrainLocoHandler(Train *consist, bool mode) if (consist->cur_speed == 0 && consist->vehstatus.Test(VehState::Stopped)) { /* If we manually stopped, we're not force-proceeding anymore. */ consist->force_proceed = TFP_NONE; - InvalidateWindowData(WC_VEHICLE_VIEW, consist->index); + InvalidateWindowData(WindowClass::VehicleView, consist->index); } Train* moving_front = consist->GetMovingFront(); @@ -4243,7 +4243,7 @@ static void CheckIfTrainNeedsService(Train *v) * suddenly moved farther away, we continue our normal * schedule? */ v->current_order.MakeDummy(); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } return; } @@ -4259,7 +4259,7 @@ static void CheckIfTrainNeedsService(Train *v) SetBit(v->gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS); v->current_order.MakeGoToDepot(depot, OrderDepotTypeFlag::Service, OrderNonStopFlag::NonStop, OrderDepotActionFlag::NearestDepot); v->dest_tile = tfdd.tile; - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); } /** Calendar day handler. */ @@ -4297,8 +4297,8 @@ void Train::OnNewEconomyDay() SubtractMoneyFromCompanyFract(this->owner, cost); - SetWindowDirty(WC_VEHICLE_DETAILS, this->index); - SetWindowClassesDirty(WC_TRAINS_LIST); + SetWindowDirty(WindowClass::VehicleDetails, this->index); + SetWindowClassesDirty(WindowClass::TrainList); } } } diff --git a/src/train_gui.cpp b/src/train_gui.cpp index d6382fd9a1..d01a24ca89 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -49,7 +49,7 @@ void CcBuildWagon(Commands, const CommandCost &result, VehicleID new_veh_id, uin found = found->Last(); /* put the new wagon at the end of the loco. */ Command::Post(found->tile, new_veh_id, found->index, false); - InvalidateWindowClassesData(WC_TRAINS_LIST, 0); + InvalidateWindowClassesData(WindowClass::TrainList, 0); } } diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 5b5e074391..7bd5392506 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -152,7 +152,7 @@ static constexpr std::initializer_list _nested_transparency_widgets /** Window definition for the transparency toolbar window. */ static WindowDesc _transparency_desc( WindowPosition::Manual, "toolbar_transparency", 0, 0, - WC_TRANSPARENCY_TOOLBAR, WC_NONE, + WindowClass::TransparencyToolbar, WindowClass::None, {}, _nested_transparency_widgets ); diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index d1b63546a7..b94f05395c 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -313,7 +313,7 @@ static constexpr std::initializer_list _nested_build_trees_widgets /** Window definition for the tree building window. */ static WindowDesc _build_trees_desc( WindowPosition::Automatic, "build_tree", 0, 0, - WC_BUILD_TREES, WC_NONE, + WindowClass::BuildTrees, WindowClass::None, WindowDefaultFlag::Construction, _nested_build_trees_widgets ); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 63bcca3ddc..4442dd1319 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -187,7 +187,7 @@ bool Vehicle::NeedsAutorenewing(const Company *c, bool use_renew_setting) const void VehicleServiceInDepot(Vehicle *v) { assert(v != nullptr); - SetWindowDirty(WC_VEHICLE_DETAILS, v->index); // ensure that last service date and reliability are updated + SetWindowDirty(WindowClass::VehicleDetails, v->index); // ensure that last service date and reliability are updated do { v->date_of_last_service = TimerGameEconomy::date; @@ -315,9 +315,9 @@ uint Vehicle::Crash(bool) /* Dirty some windows */ InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type), 0); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); - SetWindowDirty(WC_VEHICLE_DETAILS, this->index); - SetWindowDirty(WC_VEHICLE_DEPOT, this->GetMovingFront()->tile); + SetWindowWidgetDirty(WindowClass::VehicleView, this->index, WID_VV_START_STOP); + SetWindowDirty(WindowClass::VehicleDetails, this->index); + SetWindowDirty(WindowClass::VehicleDepot, this->GetMovingFront()->tile); delete this->cargo_payment; assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment @@ -797,7 +797,7 @@ void Vehicle::HandlePathfindingResult(bool path_found) /* Clear the flag as the PF's problem was solved. */ this->vehicle_flags.Reset(VehicleFlag::PathfinderLost); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, this->index, WID_VV_START_STOP); InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type)); /* Delete the news item. */ DeleteVehicleNews(this->index, AdviceType::VehicleLost); @@ -809,7 +809,7 @@ void Vehicle::HandlePathfindingResult(bool path_found) /* It is first time the problem occurred, set the "lost" flag. */ this->vehicle_flags.Set(VehicleFlag::PathfinderLost); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); + SetWindowWidgetDirty(WindowClass::VehicleView, this->index, WID_VV_START_STOP); InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type)); /* Unbunching data is no longer valid. */ @@ -869,16 +869,16 @@ void Vehicle::PreDestructor() } if (this->Previous() == nullptr) { - InvalidateWindowData(WC_VEHICLE_DEPOT, this->tile); + InvalidateWindowData(WindowClass::VehicleDepot, this->tile); } if (this->IsPrimaryVehicle()) { - CloseWindowById(WC_VEHICLE_VIEW, this->index); - CloseWindowById(WC_VEHICLE_ORDERS, this->index); - CloseWindowById(WC_VEHICLE_REFIT, this->index); - CloseWindowById(WC_VEHICLE_DETAILS, this->index); - CloseWindowById(WC_VEHICLE_TIMETABLE, this->index); - SetWindowDirty(WC_COMPANY, this->owner); + CloseWindowById(WindowClass::VehicleView, this->index); + CloseWindowById(WindowClass::VehicleOrders, this->index); + CloseWindowById(WindowClass::VehicleRefit, this->index); + CloseWindowById(WindowClass::VehicleDetails, this->index); + CloseWindowById(WindowClass::VehicleTimetable, this->index); + SetWindowDirty(WindowClass::Company, this->owner); OrderBackup::ClearVehicle(this); } InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type), 0); @@ -1297,7 +1297,7 @@ Vehicle *CheckClickOnVehicle(const Viewport &vp, int x, int y) void DecreaseVehicleValue(Vehicle *v) { v->value -= v->value >> 8; - SetWindowDirty(WC_VEHICLE_DETAILS, v->index); + SetWindowDirty(WindowClass::VehicleDetails, v->index); } static const uint8_t _breakdown_chance[64] = { @@ -1329,7 +1329,7 @@ void CheckVehicleBreakdown(Vehicle *v) /* Decrease reliability. */ int rel, rel_old; v->reliability = rel = std::max((rel_old = v->reliability) - v->reliability_spd_dec, 0); - if ((rel_old >> 8) != (rel >> 8)) SetWindowDirty(WC_VEHICLE_DETAILS, v->index); + if ((rel_old >> 8) != (rel >> 8)) SetWindowDirty(WindowClass::VehicleDetails, v->index); /* Some vehicles lose reliability but won't break down. */ /* Breakdowns are disabled. */ @@ -1409,8 +1409,8 @@ bool Vehicle::HandleBreakdown() } this->MarkDirty(); // Update graphics after speed is zeroed - SetWindowDirty(WC_VEHICLE_VIEW, this->index); - SetWindowDirty(WC_VEHICLE_DETAILS, this->index); + SetWindowDirty(WindowClass::VehicleView, this->index); + SetWindowDirty(WindowClass::VehicleDetails, this->index); [[fallthrough]]; case 1: @@ -1422,7 +1422,7 @@ bool Vehicle::HandleBreakdown() if (--this->breakdown_delay == 0) { this->breakdown_ctr = 0; this->MarkDirty(); - SetWindowDirty(WC_VEHICLE_VIEW, this->index); + SetWindowDirty(WindowClass::VehicleView, this->index); } } return true; @@ -1463,7 +1463,7 @@ void AgeVehicle(Vehicle *v) } } - SetWindowDirty(WC_VEHICLE_DETAILS, v->index); + SetWindowDirty(WindowClass::VehicleDetails, v->index); /* Don't warn if warnings are disabled */ if (!_settings_client.gui.old_vehicle_warn) return; @@ -1567,7 +1567,7 @@ void VehicleEnterDepot(Vehicle *v) switch (v->type) { case VehicleType::Train: { Train *t = Train::From(v); - SetWindowClassesDirty(WC_TRAINS_LIST); + SetWindowClassesDirty(WindowClass::TrainList); /* Clear path reservation */ SetDepotReservation(t->tile, false); if (_settings_client.gui.show_track_reservation) MarkTileDirtyByTile(t->tile); @@ -1581,21 +1581,21 @@ void VehicleEnterDepot(Vehicle *v) } case VehicleType::Road: - SetWindowClassesDirty(WC_ROADVEH_LIST); + SetWindowClassesDirty(WindowClass::RoadVehicleList); break; case VehicleType::Ship: { - SetWindowClassesDirty(WC_SHIPS_LIST); + SetWindowClassesDirty(WindowClass::ShipList); Ship *ship = Ship::From(v); ship->state = TRACK_BIT_DEPOT; ship->UpdateCache(); ship->UpdateViewport(true, true); - SetWindowDirty(WC_VEHICLE_DEPOT, v->tile); + SetWindowDirty(WindowClass::VehicleDepot, v->tile); break; } case VehicleType::Aircraft: - SetWindowClassesDirty(WC_AIRCRAFT_LIST); + SetWindowClassesDirty(WindowClass::AircraftList); HandleAircraftEnterHangar(Aircraft::From(v)); break; default: NOT_REACHED(); @@ -1603,9 +1603,9 @@ void VehicleEnterDepot(Vehicle *v) if (v->type != VehicleType::Train) { /* Trains update the vehicle list when the first unit enters the depot and calls VehicleEnterDepot() when the last unit enters. * We only increase the number of vehicles when the first one enters, so we will not need to search for more vehicles in the depot */ - InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); + InvalidateWindowData(WindowClass::VehicleDepot, v->tile); } - SetWindowDirty(WC_VEHICLE_DEPOT, v->tile); + SetWindowDirty(WindowClass::VehicleDepot, v->tile); v->vehstatus.Set(VehState::Hidden); v->cur_speed = 0; @@ -1619,7 +1619,7 @@ void VehicleEnterDepot(Vehicle *v) TriggerVehicleRandomisation(v, VehicleRandomTrigger::Depot); v->MarkDirty(); - InvalidateWindowData(WC_VEHICLE_VIEW, v->index); + InvalidateWindowData(WindowClass::VehicleView, v->index); if (v->current_order.IsType(OT_GOTO_DEPOT)) { const Order *real_order = v->GetOrder(v->cur_real_order_index); @@ -2331,9 +2331,9 @@ void Vehicle::BeginLoading() PrepareUnload(this); SetWindowDirty(GetWindowClassForVehicleType(this->type), this->owner); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); - SetWindowDirty(WC_VEHICLE_DETAILS, this->index); - SetWindowDirty(WC_STATION_VIEW, this->last_station_visited); + SetWindowWidgetDirty(WindowClass::VehicleView, this->index, WID_VV_START_STOP); + SetWindowDirty(WindowClass::VehicleDetails, this->index); + SetWindowDirty(WindowClass::StationView, this->last_station_visited); Station::Get(this->last_station_visited)->MarkTilesDirty(true); this->cur_speed = 0; @@ -2533,7 +2533,7 @@ void Vehicle::LeaveUnbunchingDepot() /* Tell the timetable we are now "on time." */ this->lateness_counter = 0; - SetWindowDirty(WC_VEHICLE_TIMETABLE, this->index); + SetWindowDirty(WindowClass::VehicleTimetable, this->index); /* Find the average travel time of vehicles that we share orders with. */ int num_vehicles = 0; @@ -2562,7 +2562,7 @@ void Vehicle::LeaveUnbunchingDepot() if (u->vehstatus.Any({VehState::Stopped, VehState::Crashed})) continue; u->depot_unbunching_next_departure = next_departure; - InvalidateWindowData(WC_VEHICLE_VIEW, u->index); + InvalidateWindowData(WindowClass::VehicleView, u->index); } } @@ -2612,7 +2612,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlags flags, DepotCommandFlags command if (flags.Test(DoCommandFlag::Execute)) { this->current_order.SetDepotOrderType({}); this->current_order.SetDepotActionType(halt_in_depot ? OrderDepotActionFlags{} : OrderDepotActionFlag::Halt); - InvalidateWindowData(WC_VEHICLE_VIEW, this->index); + InvalidateWindowData(WindowClass::VehicleView, this->index); } return CommandCost(); } @@ -2629,7 +2629,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlags flags, DepotCommandFlags command } this->current_order.MakeDummy(); - InvalidateWindowData(WC_VEHICLE_VIEW, this->index); + InvalidateWindowData(WindowClass::VehicleView, this->index); } return CommandCost(); } @@ -2649,7 +2649,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlags flags, DepotCommandFlags command this->SetDestTile(closest_depot.location); this->current_order.MakeGoToDepot(closest_depot.destination.ToDepotID(), {}); if (!command.Test(DepotCommandFlag::Service)) this->current_order.SetDepotActionType(OrderDepotActionFlag::Halt); - InvalidateWindowData(WC_VEHICLE_VIEW, this->index); + InvalidateWindowData(WindowClass::VehicleView, this->index); /* If there is no depot in front and the train is not already reversing, reverse automatically (trains only) */ if (this->type == VehicleType::Train && (closest_depot.reverse ^ Train::From(this)->flags.Test(VehicleRailFlag::Reversing))) { @@ -3055,6 +3055,7 @@ void Vehicle::RemoveFromShared() this->previous_shared = nullptr; } +/** Yearly callback for vehicles. Updates statistics and shows advices about unprofitable vehicles. */ static const IntervalTimer _economy_vehicles_yearly({TimerGameEconomy::Trigger::Year, TimerGameEconomy::Priority::Vehicle}, [](auto) { for (Vehicle *v : Vehicle::Iterate()) { @@ -3072,14 +3073,14 @@ static const IntervalTimer _economy_vehicles_yearly({TimerGame v->profit_last_year = v->profit_this_year; v->profit_this_year = 0; - SetWindowDirty(WC_VEHICLE_DETAILS, v->index); + SetWindowDirty(WindowClass::VehicleDetails, v->index); } } GroupStatistics::UpdateProfits(); - SetWindowClassesDirty(WC_TRAINS_LIST); - SetWindowClassesDirty(WC_SHIPS_LIST); - SetWindowClassesDirty(WC_ROADVEH_LIST); - SetWindowClassesDirty(WC_AIRCRAFT_LIST); + SetWindowClassesDirty(WindowClass::TrainList); + SetWindowClassesDirty(WindowClass::ShipList); + SetWindowClassesDirty(WindowClass::RoadVehicleList); + SetWindowClassesDirty(WindowClass::AircraftList); }); /** diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index f01ad910f6..8e81b03f6e 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -202,9 +202,9 @@ std::tuple CmdBuildVehicle(D NormalizeTrainVehInDepot(Train::From(v)); } - InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); + InvalidateWindowData(WindowClass::VehicleDepot, v->tile); InvalidateWindowClassesData(GetWindowClassForVehicleType(type), 0); - SetWindowDirty(WC_COMPANY, _current_company); + SetWindowDirty(WindowClass::Company, _current_company); if (IsLocalCompany()) { InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the auto replace window (must be called before incrementing num_engines) } @@ -560,10 +560,10 @@ std::tuple CmdRefitVehicle(DoCommandFla front->MarkDirty(); if (!free_wagon) { - InvalidateWindowData(WC_VEHICLE_DETAILS, front->index); + InvalidateWindowData(WindowClass::VehicleDetails, front->index); InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0); } - SetWindowDirty(WC_VEHICLE_DEPOT, front->tile); + SetWindowDirty(WindowClass::VehicleDepot, front->tile); } else { /* Always invalidate the cache; querycost might have filled it. */ v->InvalidateNewGRFCacheOfChain(); @@ -653,10 +653,10 @@ CommandCost CmdStartStopVehicle(DoCommandFlags flags, VehicleID veh_id, bool eva v->ResetDepotUnbunching(); v->MarkDirty(); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP); - SetWindowDirty(WC_VEHICLE_DEPOT, v->GetMovingFront()->tile); + SetWindowWidgetDirty(WindowClass::VehicleView, v->index, WID_VV_START_STOP); + SetWindowDirty(WindowClass::VehicleDepot, v->GetMovingFront()->tile); SetWindowClassesDirty(GetWindowClassForVehicleType(v->type)); - InvalidateWindowData(WC_VEHICLE_VIEW, v->index); + InvalidateWindowData(WindowClass::VehicleView, v->index); } return CommandCost(); } @@ -1141,7 +1141,7 @@ CommandCost CmdChangeServiceInt(DoCommandFlags flags, VehicleID veh_id, uint16_t v->SetServiceInterval(serv_int); v->SetServiceIntervalIsCustom(is_custom); v->SetServiceIntervalIsPercent(is_percent); - SetWindowDirty(WC_VEHICLE_DETAILS, v->index); + SetWindowDirty(WindowClass::VehicleDetails, v->index); } return CommandCost(); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 8cebda9c60..441e3812e1 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1344,7 +1344,7 @@ static constexpr std::initializer_list _nested_vehicle_refit_widget /** Window definition for the vehicle refit window. */ static WindowDesc _vehicle_refit_desc( WindowPosition::Automatic, "view_vehicle_refit", 240, 174, - WC_VEHICLE_REFIT, WC_VEHICLE_VIEW, + WindowClass::VehicleRefit, WindowClass::VehicleView, WindowDefaultFlag::Construction, _nested_vehicle_refit_widgets ); @@ -1358,7 +1358,7 @@ static WindowDesc _vehicle_refit_desc( */ void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit) { - CloseWindowById(WC_VEHICLE_REFIT, v->index); + CloseWindowById(WindowClass::VehicleRefit, v->index); RefitWindow *w = new RefitWindow(_vehicle_refit_desc, v, order, auto_refit); w->parent = parent; } @@ -1607,11 +1607,11 @@ static inline void ChangeVehicleWindow(WindowClass window_class, VehicleID from_ */ void ChangeVehicleViewWindow(VehicleID from_index, VehicleID to_index) { - ChangeVehicleWindow(WC_VEHICLE_VIEW, from_index, to_index); - ChangeVehicleWindow(WC_VEHICLE_ORDERS, from_index, to_index); - ChangeVehicleWindow(WC_VEHICLE_REFIT, from_index, to_index); - ChangeVehicleWindow(WC_VEHICLE_DETAILS, from_index, to_index); - ChangeVehicleWindow(WC_VEHICLE_TIMETABLE, from_index, to_index); + ChangeVehicleWindow(WindowClass::VehicleView, from_index, to_index); + ChangeVehicleWindow(WindowClass::VehicleOrders, from_index, to_index); + ChangeVehicleWindow(WindowClass::VehicleRefit, from_index, to_index); + ChangeVehicleWindow(WindowClass::VehicleDetails, from_index, to_index); + ChangeVehicleWindow(WindowClass::VehicleTimetable, from_index, to_index); } static constexpr std::initializer_list _nested_vehicle_list = { @@ -2084,7 +2084,7 @@ public: this->SortVehicleList(); if (this->vehicles.empty() && this->IsWidgetLowered(WID_VL_MANAGE_VEHICLES_DROPDOWN)) { - this->CloseChildWindows(WC_DROPDOWN_MENU); + this->CloseChildWindows(WindowClass::DropdownMenu); } /* Hide the widgets that we will not use in this window @@ -2284,25 +2284,25 @@ public: static VehicleTypeIndexArray _vehicle_list_desc = {{ WindowDesc{ WindowPosition::Automatic, "list_vehicles_train", 325, 246, - WC_TRAINS_LIST, WC_NONE, + WindowClass::TrainList, WindowClass::None, {}, _nested_vehicle_list }, WindowDesc{ WindowPosition::Automatic, "list_vehicles_roadveh", 260, 246, - WC_ROADVEH_LIST, WC_NONE, + WindowClass::RoadVehicleList, WindowClass::None, {}, _nested_vehicle_list }, WindowDesc{ WindowPosition::Automatic, "list_vehicles_ship", 260, 246, - WC_SHIPS_LIST, WC_NONE, + WindowClass::ShipList, WindowClass::None, {}, _nested_vehicle_list }, WindowDesc{ WindowPosition::Automatic, "list_vehicles_aircraft", 260, 246, - WC_AIRCRAFT_LIST, WC_NONE, + WindowClass::AircraftList, WindowClass::None, {}, _nested_vehicle_list } @@ -2835,7 +2835,7 @@ struct VehicleDetailsWindow : Window { /** Vehicle details window descriptor. */ static WindowDesc _train_vehicle_details_desc( WindowPosition::Automatic, "view_vehicle_details_train", 405, 178, - WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, + WindowClass::VehicleDetails, WindowClass::VehicleView, {}, _nested_train_vehicle_details_widgets ); @@ -2843,7 +2843,7 @@ static WindowDesc _train_vehicle_details_desc( /** Vehicle details window descriptor for other vehicles than a train. */ static WindowDesc _nontrain_vehicle_details_desc( WindowPosition::Automatic, "view_vehicle_details", 405, 113, - WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, + WindowClass::VehicleDetails, WindowClass::VehicleView, {}, _nested_nontrain_vehicle_details_widgets ); @@ -2854,8 +2854,8 @@ static WindowDesc _nontrain_vehicle_details_desc( */ static void ShowVehicleDetailsWindow(const Vehicle *v) { - CloseWindowById(WC_VEHICLE_ORDERS, v->index, false); - CloseWindowById(WC_VEHICLE_TIMETABLE, v->index, false); + CloseWindowById(WindowClass::VehicleOrders, v->index, false); + CloseWindowById(WindowClass::VehicleTimetable, v->index, false); AllocateWindowDescFront((v->type == VehicleType::Train) ? _train_vehicle_details_desc : _nontrain_vehicle_details_desc, v->index); } @@ -3103,10 +3103,10 @@ public: void Close([[maybe_unused]] int data = 0) override { - CloseWindowById(WC_VEHICLE_ORDERS, this->window_number, false); - CloseWindowById(WC_VEHICLE_REFIT, this->window_number, false); - CloseWindowById(WC_VEHICLE_DETAILS, this->window_number, false); - CloseWindowById(WC_VEHICLE_TIMETABLE, this->window_number, false); + CloseWindowById(WindowClass::VehicleOrders, this->window_number, false); + CloseWindowById(WindowClass::VehicleRefit, this->window_number, false); + CloseWindowById(WindowClass::VehicleDetails, this->window_number, false); + CloseWindowById(WindowClass::VehicleTimetable, this->window_number, false); this->Window::Close(); } @@ -3479,7 +3479,7 @@ public: /** Vehicle view window descriptor for all vehicles but trains. */ static WindowDesc _vehicle_view_desc( WindowPosition::Automatic, "view_vehicle", 250, 116, - WC_VEHICLE_VIEW, WC_NONE, + WindowClass::VehicleView, WindowClass::None, {}, _nested_vehicle_view_widgets, &VehicleViewWindow::hotkeys @@ -3491,7 +3491,7 @@ static WindowDesc _vehicle_view_desc( */ static WindowDesc _train_view_desc( WindowPosition::Automatic, "view_vehicle_train", 250, 134, - WC_VEHICLE_VIEW, WC_NONE, + WindowClass::VehicleView, WindowClass::None, {}, _nested_vehicle_view_widgets, &VehicleViewWindow::hotkeys diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index bfe81e28c3..2a5463330b 100644 --- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -98,10 +98,10 @@ inline WindowClass GetWindowClassForVehicleType(VehicleType vt) { switch (vt) { default: NOT_REACHED(); - case VehicleType::Train: return WC_TRAINS_LIST; - case VehicleType::Road: return WC_ROADVEH_LIST; - case VehicleType::Ship: return WC_SHIPS_LIST; - case VehicleType::Aircraft: return WC_AIRCRAFT_LIST; + case VehicleType::Train: return WindowClass::TrainList; + case VehicleType::Road: return WindowClass::RoadVehicleList; + case VehicleType::Ship: return WindowClass::ShipList; + case VehicleType::Aircraft: return WindowClass::AircraftList; } } diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index 572126632c..e36059fd17 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -187,7 +187,7 @@ bool VideoDriver_Cocoa::ToggleFullscreen(bool full_screen) [ NSMenu setMenuBarVisible:!full_screen ]; this->UpdateVideoModes(); - InvalidateWindowClassesData(WC_GAME_OPTIONS, 3); + InvalidateWindowClassesData(WindowClass::GameOptions, 3); return true; } diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 86689c1115..0cb5a341f2 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -718,7 +718,7 @@ bool VideoDriver_SDL_Base::ToggleFullscreen(bool fullscreen) Debug(driver, 0, "SDL_SetWindowFullscreen() failed: {}", SDL_GetError()); } - InvalidateWindowClassesData(WC_GAME_OPTIONS, 3); + InvalidateWindowClassesData(WindowClass::GameOptions, 3); return ret == 0; } diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index f58af580ae..440a610a52 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -331,7 +331,7 @@ static void SetCandidatePos(HWND hwnd) Point pt = _focused_window->GetCaretPosition(); cf.ptCurrentPos.x = _focused_window->left + pt.x; cf.ptCurrentPos.y = _focused_window->top + pt.y; - if (_focused_window->window_class == WC_CONSOLE) { + if (_focused_window->window_class == WindowClass::Console) { cf.rcArea.left = _focused_window->left; cf.rcArea.top = _focused_window->top; cf.rcArea.right = _focused_window->left + _focused_window->width; @@ -1076,7 +1076,7 @@ bool VideoDriver_Win32Base::ToggleFullscreen(bool full_screen) { bool res = this->MakeWindow(full_screen); - InvalidateWindowClassesData(WC_GAME_OPTIONS, 3); + InvalidateWindowClassesData(WindowClass::GameOptions, 3); return res; } diff --git a/src/viewport.cpp b/src/viewport.cpp index 5c45b2d8f2..79c4540f21 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -2795,7 +2795,7 @@ static inline void ShowMeasurementTooltips(EncodedString &&text) static void HideMeasurementTooltips() { - CloseWindowById(WC_TOOLTIPS, 0); + CloseWindowById(WindowClass::ToolTips, 0); } /** @@ -3544,7 +3544,7 @@ void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Wind */ void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num) { - if (_thd.window_class != WC_INVALID) { + if (_thd.window_class != WindowClass::Invalid) { /* Undo clicking on button and drag & drop */ Window *w = _thd.GetCallbackWnd(); /* Call the abort function, but set the window class to something @@ -3552,7 +3552,7 @@ void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowC * the 'next' window class must not be done because recursion into * this function might in some cases reset the newly set object to * place or not properly reset the original selection. */ - _thd.window_class = WC_INVALID; + _thd.window_class = WindowClass::Invalid; if (w != nullptr) { w->OnPlaceObjectAbort(); HideMeasurementTooltips(); @@ -3587,7 +3587,7 @@ void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowC /** Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows). */ void ResetObjectToPlace() { - SetObjectToPlace(SPR_CURSOR_MOUSE, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0); + SetObjectToPlace(SPR_CURSOR_MOUSE, PAL_NONE, HT_NONE, WindowClass::MainWindow, 0); } Point GetViewportStationMiddle(const Viewport &vp, const Station *st) @@ -3702,11 +3702,11 @@ void MarkCatchmentTilesDirty() static void SetWindowDirtyForViewportCatchment() { - if (_viewport_highlight_station != nullptr) SetWindowDirty(WC_STATION_VIEW, _viewport_highlight_station->index); - if (_viewport_highlight_station_rect != nullptr) SetWindowDirty(WC_STATION_VIEW, _viewport_highlight_station_rect->index); - if (_viewport_highlight_waypoint != nullptr) SetWindowDirty(WC_WAYPOINT_VIEW, _viewport_highlight_waypoint->index); - if (_viewport_highlight_waypoint_rect != nullptr) SetWindowDirty(WC_WAYPOINT_VIEW, _viewport_highlight_waypoint_rect->index); - if (_viewport_highlight_town != nullptr) SetWindowDirty(WC_TOWN_VIEW, _viewport_highlight_town->index); + if (_viewport_highlight_station != nullptr) SetWindowDirty(WindowClass::StationView, _viewport_highlight_station->index); + if (_viewport_highlight_station_rect != nullptr) SetWindowDirty(WindowClass::StationView, _viewport_highlight_station_rect->index); + if (_viewport_highlight_waypoint != nullptr) SetWindowDirty(WindowClass::WaypointView, _viewport_highlight_waypoint->index); + if (_viewport_highlight_waypoint_rect != nullptr) SetWindowDirty(WindowClass::WaypointView, _viewport_highlight_waypoint_rect->index); + if (_viewport_highlight_town != nullptr) SetWindowDirty(WindowClass::TownView, _viewport_highlight_town->index); } static void ClearViewportCatchment() @@ -3739,7 +3739,7 @@ void SetViewportCatchmentStation(const Station *st, bool sel) _viewport_highlight_station = nullptr; } /* Redraw the currently selected station window */ - if (_viewport_highlight_station != nullptr) SetWindowDirty(WC_STATION_VIEW, _viewport_highlight_station->index); + if (_viewport_highlight_station != nullptr) SetWindowDirty(WindowClass::StationView, _viewport_highlight_station->index); } /** @@ -3762,7 +3762,7 @@ void SetViewportStationRect(const Station *st, bool sel) _viewport_highlight_station_rect = nullptr; } /* Redraw the currently selected station window */ - if (_viewport_highlight_station_rect != nullptr) SetWindowDirty(WC_STATION_VIEW, _viewport_highlight_station_rect->index); + if (_viewport_highlight_station_rect != nullptr) SetWindowDirty(WindowClass::StationView, _viewport_highlight_station_rect->index); } /** @@ -3785,7 +3785,7 @@ void SetViewportCatchmentWaypoint(const Waypoint *wp, bool sel) _viewport_highlight_waypoint = nullptr; } /* Redraw the currently selected waypoint window */ - if (_viewport_highlight_waypoint != nullptr) SetWindowDirty(WC_WAYPOINT_VIEW, _viewport_highlight_waypoint->index); + if (_viewport_highlight_waypoint != nullptr) SetWindowDirty(WindowClass::WaypointView, _viewport_highlight_waypoint->index); } /** @@ -3808,7 +3808,7 @@ void SetViewportWaypointRect(const Waypoint *wp, bool sel) _viewport_highlight_waypoint_rect = nullptr; } /* Redraw the currently selected waypoint window */ - if (_viewport_highlight_waypoint_rect != nullptr) SetWindowDirty(WC_WAYPOINT_VIEW, _viewport_highlight_waypoint_rect->index); + if (_viewport_highlight_waypoint_rect != nullptr) SetWindowDirty(WindowClass::WaypointView, _viewport_highlight_waypoint_rect->index); } /** @@ -3831,7 +3831,7 @@ void SetViewportCatchmentTown(const Town *t, bool sel) MarkWholeScreenDirty(); } /* Redraw the currently selected town window */ - if (_viewport_highlight_town != nullptr) SetWindowDirty(WC_TOWN_VIEW, _viewport_highlight_town->index); + if (_viewport_highlight_town != nullptr) SetWindowDirty(WindowClass::TownView, _viewport_highlight_town->index); } /** @@ -3842,10 +3842,10 @@ void ViewportData::CancelFollow(const Window &viewport_window) { if (this->follow_vehicle == VehicleID::Invalid()) return; - if (viewport_window.window_class == WC_MAIN_WINDOW) { + if (viewport_window.window_class == WindowClass::MainWindow) { /* We're cancelling follow in the main viewport, so we need to check for a vehicle view window * to raise the location follow widget. */ - Window *vehicle_window = FindWindowById(WC_VEHICLE_VIEW, this->follow_vehicle); + Window *vehicle_window = FindWindowById(WindowClass::VehicleView, this->follow_vehicle); if (vehicle_window != nullptr) vehicle_window->RaiseWidgetWhenLowered(WID_VV_LOCATION); } diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 04995300d7..096dc1ef94 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -149,7 +149,7 @@ public: /** Window definition for the extra viewport window. */ static WindowDesc _extra_viewport_desc( WindowPosition::Automatic, "extra_viewport", 300, 268, - WC_EXTRA_VIEWPORT, WC_NONE, + WindowClass::ExtraViewport, WindowClass::None, {}, _nested_extra_viewport_widgets ); @@ -163,7 +163,7 @@ void ShowExtraViewportWindow(TileIndex tile) int i = 0; /* find next free window number for extra viewport */ - while (FindWindowById(WC_EXTRA_VIEWPORT, i) != nullptr) i++; + while (FindWindowById(WindowClass::ExtraViewport, i) != nullptr) i++; new ExtraViewportWindow(_extra_viewport_desc, i, tile); } diff --git a/src/waypoint.cpp b/src/waypoint.cpp index 84e1d0e934..986292ddec 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -46,7 +46,7 @@ TileArea Waypoint::GetTileArea(StationType type) const Waypoint::~Waypoint() { if (CleaningPool()) return; - CloseWindowById(WC_WAYPOINT_VIEW, this->index); + CloseWindowById(WindowClass::WaypointView, this->index); RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, this->index); if (this->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeWaypoint(this->index)); } diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp index 0c4369ce6a..83c19afd58 100644 --- a/src/waypoint_cmd.cpp +++ b/src/waypoint_cmd.cpp @@ -55,7 +55,7 @@ void Waypoint::UpdateVirtCoord() _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeWaypoint(this->index)); /* Recenter viewport */ - InvalidateWindowData(WC_WAYPOINT_VIEW, this->index); + InvalidateWindowData(WindowClass::WaypointView, this->index); } /** @@ -507,7 +507,7 @@ CommandCost CmdBuildBuoy(DoCommandFlags flags, TileIndex tile) } else { /* Move existing (recently deleted) buoy to the new location */ wp->xy = tile; - InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index); + InvalidateWindowData(WindowClass::WaypointView, wp->index); } wp->rect.BeforeAddTile(tile, StationRect::ADD_TRY); @@ -526,7 +526,7 @@ CommandCost CmdBuildBuoy(DoCommandFlags flags, TileIndex tile) ClearNeighbourNonFloodingStates(tile); wp->UpdateVirtCoord(); - InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index); + InvalidateWindowData(WindowClass::WaypointView, wp->index); } return cost; @@ -556,7 +556,7 @@ CommandCost RemoveBuoy(TileIndex tile, DoCommandFlags flags) if (flags.Test(DoCommandFlag::Execute)) { wp->facilities.Reset(StationFacility::Dock); - InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index); + InvalidateWindowData(WindowClass::WaypointView, wp->index); /* We have to set the water tile's state to the same state as before the * buoy was placed. Otherwise one could plant a buoy on a canal edge, diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index c08f8296b4..d459bb33e1 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -127,7 +127,7 @@ public: void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { - Window *w = FindWindowByClass(WC_QUERY_STRING); + Window *w = FindWindowByClass(WindowClass::QueryString); switch (widget) { case WID_W_CENTER_VIEW: // scroll to location @@ -151,8 +151,8 @@ public: SetViewportCatchmentWaypoint(Waypoint::Get(this->window_number), !this->IsWidgetLowered(WID_W_CATCHMENT)); if (w != nullptr && this->IsWidgetLowered(WID_W_CATCHMENT)) { - if (w->parent->window_class == WC_STATION_VIEW && w->IsWidgetLowered(WID_QS_MOVE)) SetViewportStationRect(Station::Get(w->parent->window_number), true); - if (w->parent->window_class == WC_WAYPOINT_VIEW && w->IsWidgetLowered(WID_QS_MOVE)) SetViewportWaypointRect(Waypoint::Get(w->parent->window_number), true); + if (w->parent->window_class == WindowClass::StationView && w->IsWidgetLowered(WID_QS_MOVE)) SetViewportStationRect(Station::Get(w->parent->window_number), true); + if (w->parent->window_class == WindowClass::WaypointView && w->IsWidgetLowered(WID_QS_MOVE)) SetViewportWaypointRect(Waypoint::Get(w->parent->window_number), true); } break; } @@ -220,7 +220,7 @@ static constexpr std::initializer_list _nested_waypoint_view_widget /** The description of the waypoint view. */ static WindowDesc _waypoint_view_desc( WindowPosition::Automatic, "view_waypoint", 260, 118, - WC_WAYPOINT_VIEW, WC_NONE, + WindowClass::WaypointView, WindowClass::None, {}, _nested_waypoint_view_widgets ); diff --git a/src/widgets/link_graph_legend_widget.h b/src/widgets/link_graph_legend_widget.h index f54b3e89fa..e41efe8e3b 100644 --- a/src/widgets/link_graph_legend_widget.h +++ b/src/widgets/link_graph_legend_widget.h @@ -12,7 +12,7 @@ #include "../cargo_type.h" -/** Widgets of the WC_LINKGRAPH_LEGEND. */ +/** Widgets of the WindowClass::LinkGraphLegend. */ enum LinkGraphLegendWidgets : WidgetID { WID_LGL_CAPTION, ///< Caption widget. diff --git a/src/window.cpp b/src/window.cpp index 64fa504314..1bea60d841 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -301,7 +301,7 @@ void Window::OnDropdownClose(Point pt, WidgetID widget, int index, int click_res /* Many dropdown selections depend on the position of the main toolbar, * so if it doesn't exist (e.g. the end screen has appeared), just skip the instant close behaviour. */ - if (instant_close && FindWindowById(WC_MAIN_TOOLBAR, 0) != nullptr) { + if (instant_close && FindWindowById(WindowClass::MainToolbar, 0) != nullptr) { /* Send event for selected option if we're still * on the parent button of the dropdown (behaviour of the dropdowns in the main toolbar). */ if (GetWidgetFromPos(this, pt.x, pt.y) == widget) { @@ -437,7 +437,7 @@ void SetFocusedWindow(Window *w) if (_focused_window == w) return; /* Don't focus a tooltip */ - if (w != nullptr && w->window_class == WC_TOOLTIPS) return; + if (w != nullptr && w->window_class == WindowClass::ToolTips) return; /* Invalidate focused widget */ if (_focused_window != nullptr) { @@ -463,7 +463,7 @@ bool EditBoxInGlobalFocus() if (_focused_window == nullptr) return false; /* The console does not have an edit box so a special case is needed. */ - if (_focused_window->window_class == WC_CONSOLE) return true; + if (_focused_window->window_class == WindowClass::Console) return true; return _focused_window->nested_focus != nullptr && _focused_window->nested_focus->type == WWT_EDITBOX; } @@ -474,7 +474,7 @@ bool EditBoxInGlobalFocus() */ bool FocusedWindowIsConsole() { - return _focused_window && _focused_window->window_class == WC_CONSOLE; + return _focused_window && _focused_window->window_class == WindowClass::Console; } /** @@ -643,7 +643,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count) if (!w->window_desc.flags.Test(WindowDefaultFlag::NoFocus) && widget_type != WWT_CLOSEBOX) { focused_widget_changed = true; SetFocusedWindow(w); - } else if (_focused_window != nullptr && _focused_window->window_class == WC_DROPDOWN_MENU) { + } else if (_focused_window != nullptr && _focused_window->window_class == WindowClass::DropdownMenu) { /* The previously focused window was a dropdown menu, but the user clicked on another window that * isn't focusable. Close the dropdown menu anyway. */ SetFocusedWindow(nullptr); @@ -660,7 +660,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count) /* Clicked on a widget that is not disabled. * So unless the clicked widget is the caption bar, change focus to this widget. * Exception: In the OSK we always want the editbox to stay focused. */ - if (widget_index >= 0 && widget_type != WWT_CAPTION && w->window_class != WC_OSK) { + if (widget_index >= 0 && widget_type != WWT_CAPTION && w->window_class != WindowClass::OnScreenKeyboard) { /* focused_widget_changed is 'now' only true if the window this widget * is in gained focus. In that case it must remain true, also if the * local widget focus did not change. As such it's the logical-or of @@ -872,9 +872,9 @@ static bool MayBeShown(const Window *w) if (!HasModalProgress()) return true; switch (w->window_class) { - case WC_MAIN_WINDOW: ///< The background, i.e. the game. - case WC_MODAL_PROGRESS: ///< The actual progress window. - case WC_CONFIRM_POPUP_QUERY: ///< The abort window. + case WindowClass::MainWindow: ///< The background, i.e. the game. + case WindowClass::ModalProgress: ///< The actual progress window. + case WindowClass::ConfirmPopupQuery: ///< The abort window. return true; default: @@ -1055,13 +1055,13 @@ void Window::SetShaded(bool make_shaded) /** * Find the Window whose parent pointer points to this window - * @param wc Window class of the window to find; #WC_INVALID if class does not matter + * @param wc Window class of the window to find; ::WindowClass::Invalid if class does not matter * @return a Window pointer that is the child of this window, or \c nullptr otherwise */ Window *Window::FindChildWindow(WindowClass wc) const { for (Window *v : Window::Iterate()) { - if ((wc == WC_INVALID || wc == v->window_class) && v->parent == this) return v; + if ((wc == WindowClass::Invalid || wc == v->window_class) && v->parent == this) return v; } return nullptr; @@ -1084,7 +1084,7 @@ Window *Window::FindChildWindowById(WindowClass wc, WindowNumber number) const /** * Close all children a window might have in a head-recursive manner - * @param wc Window class of the window to remove; #WC_INVALID if class does not matter + * @param wc Window class of the window to remove; ::WindowClass::Invalid if class does not matter */ void Window::CloseChildWindows(WindowClass wc) const { @@ -1174,7 +1174,7 @@ Window *FindWindowById(WindowClass cls, WindowNumber number) /** * Find any window by its class. Useful when searching for a window that uses - * the window number as a #WindowClass, like #WC_SEND_NETWORK_MSG. + * the window number as a #WindowClass, like ::WindowClass::NetworkChat. * @param cls Window class * @return Pointer to the found window, or \c nullptr if not available */ @@ -1188,13 +1188,13 @@ Window *FindWindowByClass(WindowClass cls) } /** - * Get the main window, i.e. FindWindowById(WC_MAIN_WINDOW, 0). + * Get the main window, i.e. FindWindowById(WindowClass::MainWindow, 0). * If the main window is not available, this function will trigger an assert. * @return Pointer to the main window. */ Window *GetMainWindow() { - Window *w = FindWindowById(WC_MAIN_WINDOW, 0); + Window *w = FindWindowById(WindowClass::MainWindow, 0); assert(w != nullptr); return w; } @@ -1245,7 +1245,7 @@ void CloseCompanyWindows(CompanyID id) } /* Also delete the company specific windows that don't have a company-colour. */ - CloseWindowById(WC_BUY_COMPANY, id); + CloseWindowById(WindowClass::BuyCompany, id); } /** @@ -1261,17 +1261,17 @@ void ChangeWindowOwner(Owner old_owner, Owner new_owner) if (w->owner != old_owner) continue; switch (w->window_class) { - case WC_COMPANY_COLOUR: - case WC_FINANCES: - case WC_STATION_LIST: - case WC_TRAINS_LIST: - case WC_ROADVEH_LIST: - case WC_SHIPS_LIST: - case WC_AIRCRAFT_LIST: - case WC_BUY_COMPANY: - case WC_COMPANY: - case WC_COMPANY_INFRASTRUCTURE: - case WC_VEHICLE_ORDERS: // Changing owner would also require changing WindowDesc, which is not possible; however keeping the old one crashes because of missing widgets etc.. See ShowOrdersWindow(). + case WindowClass::CompanyLivery: + case WindowClass::Finances: + case WindowClass::StationList: + case WindowClass::TrainList: + case WindowClass::RoadVehicleList: + case WindowClass::ShipList: + case WindowClass::AircraftList: + case WindowClass::BuyCompany: + case WindowClass::Company: + case WindowClass::CompanyInfrastructure: + case WindowClass::VehicleOrders: // Changing owner would also require changing WindowDesc, which is not possible; however keeping the old one crashes because of missing widgets etc.. See ShowOrdersWindow(). continue; default: @@ -1308,10 +1308,10 @@ Window *BringWindowToFrontById(WindowClass cls, WindowNumber number) static inline bool IsVitalWindow(const Window *w) { switch (w->window_class) { - case WC_MAIN_TOOLBAR: - case WC_STATUS_BAR: - case WC_NEWS_WINDOW: - case WC_SEND_NETWORK_MSG: + case WindowClass::MainToolbar: + case WindowClass::Statusbar: + case WindowClass::News: + case WindowClass::NetworkChat: return true; default: @@ -1324,75 +1324,75 @@ static inline bool IsVitalWindow(const Window *w) * a window with a given z-priority will appear above other windows with a lower value, and below * those with a higher one (the ordering within z-priorities is arbitrary). * @param wc The window class of window to get the z-priority for - * @pre wc != WC_INVALID + * @pre wc != WindowClass::Invalid * @return The window's z-priority */ static uint GetWindowZPriority(WindowClass wc) { - assert(wc != WC_INVALID); + assert(wc != WindowClass::Invalid); uint z_priority = 0; switch (wc) { - case WC_TOOLTIPS: + case WindowClass::ToolTips: ++z_priority; [[fallthrough]]; - case WC_ERRMSG: - case WC_CONFIRM_POPUP_QUERY: + case WindowClass::ErrorMessage: + case WindowClass::ConfirmPopupQuery: ++z_priority; [[fallthrough]]; - case WC_ENDSCREEN: + case WindowClass::Endscreen: ++z_priority; [[fallthrough]]; - case WC_HIGHSCORE: + case WindowClass::Highscore: ++z_priority; [[fallthrough]]; - case WC_DROPDOWN_MENU: + case WindowClass::DropdownMenu: ++z_priority; [[fallthrough]]; - case WC_MAIN_TOOLBAR: - case WC_STATUS_BAR: + case WindowClass::MainToolbar: + case WindowClass::Statusbar: ++z_priority; [[fallthrough]]; - case WC_OSK: + case WindowClass::OnScreenKeyboard: ++z_priority; [[fallthrough]]; - case WC_QUERY_STRING: - case WC_SEND_NETWORK_MSG: + case WindowClass::QueryString: + case WindowClass::NetworkChat: ++z_priority; [[fallthrough]]; - case WC_NETWORK_ASK_RELAY: - case WC_MODAL_PROGRESS: - case WC_NETWORK_STATUS_WINDOW: - case WC_SAVE_PRESET: + case WindowClass::NetworkAskRelay: + case WindowClass::ModalProgress: + case WindowClass::NetworkStatus: + case WindowClass::SavePreset: ++z_priority; [[fallthrough]]; - case WC_GENERATE_LANDSCAPE: - case WC_SAVELOAD: - case WC_GAME_OPTIONS: - case WC_CUSTOM_CURRENCY: - case WC_NETWORK_WINDOW: - case WC_GRF_PARAMETERS: - case WC_SCRIPT_LIST: - case WC_SCRIPT_SETTINGS: - case WC_TEXTFILE: + case WindowClass::GenerateLandscape: + case WindowClass::SaveLoad: + case WindowClass::GameOptions: + case WindowClass::CustomCurrenty: + case WindowClass::Network: + case WindowClass::NewGRFParameters: + case WindowClass::ScriptList: + case WindowClass::ScriptSettings: + case WindowClass::Textfile: ++z_priority; [[fallthrough]]; - case WC_CONSOLE: + case WindowClass::Console: ++z_priority; [[fallthrough]]; - case WC_NEWS_WINDOW: + case WindowClass::News: ++z_priority; [[fallthrough]]; @@ -1400,7 +1400,7 @@ static uint GetWindowZPriority(WindowClass wc) ++z_priority; [[fallthrough]]; - case WC_MAIN_WINDOW: + case WindowClass::MainWindow: return z_priority; } } @@ -1453,7 +1453,7 @@ void Window::InitializeData(WindowNumber window_number) /* Give focus to the opened window unless a dropdown menu has focus or a text box of the focused window has focus * (so we don't interrupt typing) unless the new window has a text box. */ - bool dropdown_active = _focused_window != nullptr && _focused_window->window_class == WC_DROPDOWN_MENU; + bool dropdown_active = _focused_window != nullptr && _focused_window->window_class == WindowClass::DropdownMenu; bool editbox_active = EditBoxInGlobalFocus() && this->nested_root->GetWidgetOfType(WWT_EDITBOX) == nullptr; if (!dropdown_active && !editbox_active) SetFocusedWindow(this); @@ -1500,9 +1500,9 @@ void Window::FindWindowPlacementAndResize(int def_width, int def_height, bool al if (this->width != def_width || this->height != def_height) { /* Think about the overlapping toolbars when determining the minimum window size */ int free_height = _screen.height; - const Window *wt = FindWindowById(WC_STATUS_BAR, 0); + const Window *wt = FindWindowById(WindowClass::Statusbar, 0); if (wt != nullptr) free_height -= wt->height; - wt = FindWindowById(WC_MAIN_TOOLBAR, 0); + wt = FindWindowById(WindowClass::MainToolbar, 0); if (wt != nullptr) free_height -= wt->height; int enlarge_x = std::max(std::min(def_width - this->width, _screen.width - this->width), 0); @@ -1527,7 +1527,7 @@ void Window::FindWindowPlacementAndResize(int def_width, int def_height, bool al if (nx + this->width > _screen.width) nx -= (nx + this->width - _screen.width); - const Window *wt = FindWindowById(WC_MAIN_TOOLBAR, 0); + const Window *wt = FindWindowById(WindowClass::MainToolbar, 0); ny = std::max(ny, (wt == nullptr || this == wt || this->top == 0) ? 0 : wt->height); nx = std::max(nx, 0); @@ -1562,7 +1562,7 @@ static bool IsGoodAutoPlace1(int left, int top, int width, int height, int toolb /* Make sure it is not obscured by any window. */ for (const Window *w : Window::Iterate()) { - if (w->window_class == WC_MAIN_WINDOW) continue; + if (w->window_class == WindowClass::MainWindow) continue; if (right > w->left && w->left + w->width > left && @@ -1607,7 +1607,7 @@ static bool IsGoodAutoPlace2(int left, int top, int width, int height, int toolb /* Make sure it is not obscured by any window. */ for (const Window *w : Window::Iterate()) { - if (w->window_class == WC_MAIN_WINDOW) continue; + if (w->window_class == WindowClass::MainWindow) continue; if (left + width > w->left && w->left + w->width > left && @@ -1635,7 +1635,7 @@ static Point GetAutoPlacePosition(int width, int height) bool rtl = _current_text_dir == TD_RTL; /* First attempt, try top-left of the screen */ - const Window *main_toolbar = FindWindowByClass(WC_MAIN_TOOLBAR); + const Window *main_toolbar = FindWindowByClass(WindowClass::MainToolbar); const int toolbar_y = main_toolbar != nullptr ? main_toolbar->height : 0; if (IsGoodAutoPlace1(rtl ? _screen.width - width : 0, toolbar_y, width, height, toolbar_y, pt)) return pt; @@ -1644,7 +1644,7 @@ static Point GetAutoPlacePosition(int width, int height) * Eight starting points are tried, two at each corner. */ for (const Window *w : Window::Iterate()) { - if (w->window_class == WC_MAIN_WINDOW) continue; + if (w->window_class == WindowClass::MainWindow) continue; if (IsGoodAutoPlace1(w->left + w->width, w->top, width, height, toolbar_y, pt)) return pt; if (IsGoodAutoPlace1(w->left - width, w->top, width, height, toolbar_y, pt)) return pt; @@ -1661,7 +1661,7 @@ static Point GetAutoPlacePosition(int width, int height) * Only four starting points are tried. */ for (const Window *w : Window::Iterate()) { - if (w->window_class == WC_MAIN_WINDOW) continue; + if (w->window_class == WindowClass::MainWindow) continue; if (IsGoodAutoPlace2(w->left + w->width, w->top, width, height, toolbar_y, pt)) return pt; if (IsGoodAutoPlace2(w->left - width, w->top, width, height, toolbar_y, pt)) return pt; @@ -1698,7 +1698,7 @@ restart: */ Point GetToolbarAlignedWindowPosition(int window_width) { - const Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0); + const Window *w = FindWindowById(WindowClass::MainToolbar, 0); assert(w != nullptr); Point pt = { _current_text_dir == TD_RTL ? w->left : (w->left + w->width) - window_width, w->top + w->height }; return pt; @@ -1715,7 +1715,7 @@ Point GetToolbarAlignedWindowPosition(int window_width) Point AlignInitialConstructionToolbar(int window_width) { Point pt = GetToolbarAlignedWindowPosition(window_width); - const Window *w = FindWindowByClass(WC_SCEN_LAND_GEN); + const Window *w = FindWindowByClass(WindowClass::ScenarioGenerateLandscape); if (w != nullptr && w->top == pt.y && !_settings_client.gui.link_terraform_toolbar) { pt.x = w->left + (_current_text_dir == TD_RTL ? w->width : - window_width); } @@ -1726,8 +1726,8 @@ Point AlignInitialConstructionToolbar(int window_width) * Compute the position of the top-left corner of a new window that is opened. * * By default position a child window at an offset of 10/10 of its parent. - * With the exception of WC_BUILD_TOOLBAR (build railway/roads/ship docks/airports) - * and WC_SCEN_LAND_GEN (landscaping). Whose child window has an offset of 0/toolbar-height of + * With the exception of WindowClass::BuildToolbar (build railway/roads/ship docks/airports) + * and WindowClass::ScenarioGenerateLandscape (landscaping). Whose child window has an offset of 0/toolbar-height of * its parent. So it's exactly under the parent toolbar and no buttons will be covered. * However if it falls too extremely outside window positions, reposition * it to an automatic place. @@ -1747,9 +1747,9 @@ static Point LocalGetWindowPlacement(const WindowDesc &desc, int16_t sm_width, i int16_t default_width = std::max(desc.GetDefaultWidth(), sm_width); int16_t default_height = std::max(desc.GetDefaultHeight(), sm_height); - if (desc.parent_cls != WC_NONE && (w = FindWindowById(desc.parent_cls, window_number)) != nullptr) { + if (desc.parent_cls != WindowClass::None && (w = FindWindowById(desc.parent_cls, window_number)) != nullptr) { bool rtl = _current_text_dir == TD_RTL; - if (desc.parent_cls == WC_BUILD_TOOLBAR || desc.parent_cls == WC_SCEN_LAND_GEN) { + if (desc.parent_cls == WindowClass::BuildToolbar || desc.parent_cls == WindowClass::ScenarioGenerateLandscape) { pt.x = w->left + (rtl ? w->width - default_width : 0); pt.y = w->top + w->height; return pt; @@ -2086,8 +2086,8 @@ static void EnsureVisibleCaption(Window *w, int nx, int ny) ny = Clamp(ny, 0, _screen.height - min_visible); /* Make sure the title bar isn't hidden behind the main tool bar or the status bar. */ - PreventHiding(&nx, &ny, caption_rect, FindWindowById(WC_MAIN_TOOLBAR, 0), w->left, PHD_DOWN); - PreventHiding(&nx, &ny, caption_rect, FindWindowById(WC_STATUS_BAR, 0), w->left, PHD_UP); + PreventHiding(&nx, &ny, caption_rect, FindWindowById(WindowClass::MainToolbar, 0), w->left, PHD_DOWN); + PreventHiding(&nx, &ny, caption_rect, FindWindowById(WindowClass::Statusbar, 0), w->left, PHD_UP); } if (w->viewport != nullptr) { @@ -2152,7 +2152,7 @@ void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen, boo */ int GetMainViewTop() { - Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0); + Window *w = FindWindowById(WindowClass::MainToolbar, 0); return (w == nullptr) ? 0 : w->top + w->height; } @@ -2163,7 +2163,7 @@ int GetMainViewTop() */ int GetMainViewBottom() { - Window *w = FindWindowById(WC_STATUS_BAR, 0); + Window *w = FindWindowById(WindowClass::Statusbar, 0); return (w == nullptr) ? _screen.height : w->top; } @@ -2519,10 +2519,10 @@ static bool MaybeBringWindowToFront(Window *w) { bool bring_to_front = false; - if (w->window_class == WC_MAIN_WINDOW || + if (w->window_class == WindowClass::MainWindow || IsVitalWindow(w) || - w->window_class == WC_TOOLTIPS || - w->window_class == WC_DROPDOWN_MENU) { + w->window_class == WindowClass::ToolTips || + w->window_class == WindowClass::DropdownMenu) { return true; } @@ -2545,10 +2545,10 @@ static bool MaybeBringWindowToFront(Window *w) return false; } - if (u->window_class == WC_MAIN_WINDOW || + if (u->window_class == WindowClass::MainWindow || IsVitalWindow(u) || - u->window_class == WC_TOOLTIPS || - u->window_class == WC_DROPDOWN_MENU) { + u->window_class == WindowClass::ToolTips || + u->window_class == WindowClass::DropdownMenu) { continue; } @@ -2591,11 +2591,11 @@ EventState Window::HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode case HKPR_CURSOR: this->SetWidgetDirty(wid); /* For the OSK also invalidate the parent window */ - if (this->window_class == WC_OSK) this->InvalidateData(); + if (this->window_class == WindowClass::OnScreenKeyboard) this->InvalidateData(); break; case HKPR_CONFIRM: - if (this->window_class == WC_OSK) { + if (this->window_class == WindowClass::OnScreenKeyboard) { this->OnClick(Point(), WID_OSK_OK, 1); } else if (query->ok_button >= 0) { this->OnClick(Point(), query->ok_button, 1); @@ -2605,7 +2605,7 @@ EventState Window::HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode break; case HKPR_CANCEL: - if (this->window_class == WC_OSK) { + if (this->window_class == WindowClass::OnScreenKeyboard) { this->OnClick(Point(), WID_OSK_CANCEL, 1); } else if (query->cancel_button >= 0) { this->OnClick(Point(), query->cancel_button, 1); @@ -2651,7 +2651,7 @@ void HandleToolbarHotkey(int hotkey) { assert(HasModalProgress() || IsLocalCompany()); - Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0); + Window *w = FindWindowById(WindowClass::MainToolbar, 0); if (w != nullptr) { if (w->window_desc.hotkeys != nullptr) { if (hotkey >= 0 && w->OnHotkey(hotkey) == ES_HANDLED) return; @@ -2687,7 +2687,7 @@ void HandleKeypress(uint keycode, char32_t key) /* Check if the focused window has a focused editbox */ if (EditBoxInGlobalFocus()) { /* All input will in this case go to the focused editbox */ - if (_focused_window->window_class == WC_CONSOLE) { + if (_focused_window->window_class == WindowClass::Console) { if (_focused_window->OnKeyPress(key, keycode) == ES_HANDLED) return; } else { if (_focused_window->HandleEditBoxKey(_focused_window->nested_focus->GetIndex(), key, keycode) == ES_HANDLED) return; @@ -2696,7 +2696,7 @@ void HandleKeypress(uint keycode, char32_t key) /* Call the event, start with the uppermost window, but ignore the toolbar. */ for (Window *w : Window::IterateFromFront()) { - if (w->window_class == WC_MAIN_TOOLBAR) continue; + if (w->window_class == WindowClass::MainToolbar) continue; if (w->window_desc.hotkeys != nullptr) { int hotkey = w->window_desc.hotkeys->CheckMatch(keycode); if (hotkey >= 0 && w->OnHotkey(hotkey) == ES_HANDLED) return; @@ -2704,7 +2704,7 @@ void HandleKeypress(uint keycode, char32_t key) if (w->OnKeyPress(key, keycode) == ES_HANDLED) return; } - Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0); + Window *w = FindWindowById(WindowClass::MainToolbar, 0); /* When there is no toolbar w is null, check for that */ if (w != nullptr) { if (w->window_desc.hotkeys != nullptr) { @@ -2760,7 +2760,7 @@ void HandleTextInput(std::string_view str, bool marked, std::optional ca { if (!EditBoxInGlobalFocus()) return; - _focused_window->InsertTextString(_focused_window->window_class == WC_CONSOLE ? 0 : _focused_window->nested_focus->GetIndex(), str, marked, caret, insert_location, replacement_end); + _focused_window->InsertTextString(_focused_window->window_class == WindowClass::Console ? 0 : _focused_window->nested_focus->GetIndex(), str, marked, caret, insert_location, replacement_end); } /** @@ -2777,7 +2777,7 @@ static void HandleAutoscroll() int y = _cursor.pos.y; Window *w = FindWindowFromPt(x, y); if (w == nullptr || w->flags.Test(WindowFlag::DisableVpScroll)) return; - if (_settings_client.gui.auto_scrolling != VA_EVERY_VIEWPORT && w->window_class != WC_MAIN_WINDOW) return; + if (_settings_client.gui.auto_scrolling != VA_EVERY_VIEWPORT && w->window_class != WindowClass::MainWindow) return; Viewport *vp = IsPtInWindowViewport(w, x, y); if (vp == nullptr) return; @@ -2908,7 +2908,7 @@ static void MouseLoop(MouseClick click, int mousewheel) if (mousewheel != 0) { /* Send mousewheel event to window, unless we're scrolling a viewport or the map */ - if (!scrollwheel_scrolling || (vp == nullptr && w->window_class != WC_SMALLMAP)) { + if (!scrollwheel_scrolling || (vp == nullptr && w->window_class != WindowClass::SmallMap)) { if (NWidgetCore *nwid = w->nested_root->GetWidgetFromPos(x - w->left, y - w->top); nwid != nullptr) { w->OnMouseWheel(mousewheel, nwid->GetIndex()); } @@ -2960,7 +2960,7 @@ static void MouseLoop(MouseClick click, int mousewheel) return; default: - if (!scrollwheel_scrolling || w == nullptr || w->window_class != WC_SMALLMAP) break; + if (!scrollwheel_scrolling || w == nullptr || w->window_class != WindowClass::SmallMap) break; /* We try to use the scrollwheel to scroll since we didn't touch any of the buttons. * Simulate a right button click so we can get started. */ [[fallthrough]]; @@ -3062,7 +3062,7 @@ static void CheckSoftLimit() uint deletable_count = 0; Window *last_deletable = nullptr; for (Window *w : Window::IterateFromFront()) { - if (w->window_class == WC_MAIN_WINDOW || IsVitalWindow(w) || w->flags.Test(WindowFlag::Sticky)) continue; + if (w->window_class == WindowClass::MainWindow || IsVitalWindow(w) || w->flags.Test(WindowFlag::Sticky)) continue; last_deletable = w; deletable_count++; @@ -3188,7 +3188,7 @@ void UpdateWindows() /* We are done with the last draw-frame, so we know what sprites we * clicked on. Reset the picker mode and invalidate the window. */ _newgrf_debug_sprite_picker.mode = SPM_NONE; - InvalidateWindowData(WC_SPRITE_ALIGNER, 0, 1); + InvalidateWindowData(WindowClass::SpriteAligner, 0, 1); } } @@ -3275,7 +3275,7 @@ void Window::InvalidateData(int data, bool gui_scope) void Window::ProcessScheduledInvalidations() { for (int data : this->scheduled_invalidation_data) { - if (this->window_class == WC_INVALID) break; + if (this->window_class == WindowClass::Invalid) break; this->OnInvalidateData(data, true); } this->scheduled_invalidation_data.clear(); @@ -3397,9 +3397,9 @@ void CloseAllNonVitalWindows() void DeleteAllMessages() { InitNewsItemStructs(); - InvalidateWindowData(WC_STATUS_BAR, 0, SBI_NEWS_DELETED); // invalidate the statusbar - InvalidateWindowData(WC_MESSAGE_HISTORY, 0); // invalidate the message history - CloseWindowById(WC_NEWS_WINDOW, 0); // close newspaper or general message window if shown + InvalidateWindowData(WindowClass::Statusbar, 0, SBI_NEWS_DELETED); // invalidate the statusbar + InvalidateWindowData(WindowClass::MessageHistory, 0); // invalidate the message history + CloseWindowById(WindowClass::News, 0); // close newspaper or general message window if shown } /** @@ -3421,8 +3421,8 @@ void CloseConstructionWindows() /** Close all always on-top windows to get an empty screen */ void HideVitalWindows() { - CloseWindowById(WC_MAIN_TOOLBAR, 0); - CloseWindowById(WC_STATUS_BAR, 0); + CloseWindowById(WindowClass::MainToolbar, 0); + CloseWindowById(WindowClass::Statusbar, 0); } void ReInitWindow(Window *w, bool zoom_changed) @@ -3446,10 +3446,10 @@ void ReInitAllWindows(bool zoom_changed) /* When _gui_zoom has changed, we need to resize toolbar and statusbar first, * so EnsureVisibleCaption uses the updated size information. */ - ReInitWindow(FindWindowById(WC_MAIN_TOOLBAR, 0), zoom_changed); - ReInitWindow(FindWindowById(WC_STATUS_BAR, 0), zoom_changed); + ReInitWindow(FindWindowById(WindowClass::MainToolbar, 0), zoom_changed); + ReInitWindow(FindWindowById(WindowClass::Statusbar, 0), zoom_changed); for (Window *w : Window::Iterate()) { - if (w->window_class == WC_MAIN_TOOLBAR || w->window_class == WC_STATUS_BAR) continue; + if (w->window_class == WindowClass::MainToolbar || w->window_class == WindowClass::Statusbar) continue; ReInitWindow(w, zoom_changed); } @@ -3494,7 +3494,7 @@ static int PositionWindow(Window *w, WindowClass clss, int setting) int PositionMainToolbar(Window *w) { Debug(misc, 5, "Repositioning Main Toolbar..."); - return PositionWindow(w, WC_MAIN_TOOLBAR, _settings_client.gui.toolbar_pos); + return PositionWindow(w, WindowClass::MainToolbar, _settings_client.gui.toolbar_pos); } /** @@ -3505,7 +3505,7 @@ int PositionMainToolbar(Window *w) int PositionStatusbar(Window *w) { Debug(misc, 5, "Repositioning statusbar..."); - return PositionWindow(w, WC_STATUS_BAR, _settings_client.gui.statusbar_pos); + return PositionWindow(w, WindowClass::Statusbar, _settings_client.gui.statusbar_pos); } /** @@ -3516,7 +3516,7 @@ int PositionStatusbar(Window *w) int PositionNewsMessage(Window *w) { Debug(misc, 5, "Repositioning news message..."); - return PositionWindow(w, WC_NEWS_WINDOW, _settings_client.gui.statusbar_pos); + return PositionWindow(w, WindowClass::News, _settings_client.gui.statusbar_pos); } /** @@ -3527,7 +3527,7 @@ int PositionNewsMessage(Window *w) int PositionNetworkChatWindow(Window *w) { Debug(misc, 5, "Repositioning network chat window..."); - return PositionWindow(w, WC_SEND_NETWORK_MSG, _settings_client.gui.statusbar_pos); + return PositionWindow(w, WindowClass::NetworkChat, _settings_client.gui.statusbar_pos); } @@ -3554,15 +3554,15 @@ void ChangeVehicleViewports(VehicleID from_index, VehicleID to_index) */ void RelocateAllWindows(int neww, int newh) { - CloseWindowByClass(WC_DROPDOWN_MENU); + CloseWindowByClass(WindowClass::DropdownMenu); /* Reposition toolbar then status bar before other all windows. */ - if (Window *wt = FindWindowById(WC_MAIN_TOOLBAR, 0); wt != nullptr) { + if (Window *wt = FindWindowById(WindowClass::MainToolbar, 0); wt != nullptr) { ResizeWindow(wt, std::min(neww, _toolbar_width) - wt->width, 0, false); wt->left = PositionMainToolbar(wt); } - if (Window *ws = FindWindowById(WC_STATUS_BAR, 0); ws != nullptr) { + if (Window *ws = FindWindowById(WindowClass::Statusbar, 0); ws != nullptr) { ResizeWindow(ws, std::min(neww, _toolbar_width) - ws->width, 0, false); ws->top = newh - ws->height; ws->left = PositionStatusbar(ws); @@ -3573,30 +3573,30 @@ void RelocateAllWindows(int neww, int newh) /* XXX - this probably needs something more sane. For example specifying * in a 'backup'-desc that the window should always be centered. */ switch (w->window_class) { - case WC_MAIN_WINDOW: - case WC_BOOTSTRAP: - case WC_HIGHSCORE: - case WC_ENDSCREEN: + case WindowClass::MainWindow: + case WindowClass::Bootstrap: + case WindowClass::Highscore: + case WindowClass::Endscreen: ResizeWindow(w, neww, newh); continue; - case WC_MAIN_TOOLBAR: - case WC_STATUS_BAR: + case WindowClass::MainToolbar: + case WindowClass::Statusbar: continue; - case WC_NEWS_WINDOW: + case WindowClass::News: top = newh - w->height; left = PositionNewsMessage(w); break; - case WC_SEND_NETWORK_MSG: + case WindowClass::NetworkChat: ResizeWindow(w, std::min(neww, _toolbar_width) - w->width, 0, false); - top = newh - w->height - FindWindowById(WC_STATUS_BAR, 0)->height; + top = newh - w->height - FindWindowById(WindowClass::Statusbar, 0)->height; left = PositionNetworkChatWindow(w); break; - case WC_CONSOLE: + case WindowClass::Console: IConsoleResize(w); continue; diff --git a/src/window_gui.h b/src/window_gui.h index bb10555cec..2a6bfc889a 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -546,9 +546,9 @@ public: void DrawSortButtonState(WidgetID widget, SortButtonState state) const; static int SortButtonWidth(); - Window *FindChildWindow(WindowClass wc = WC_INVALID) const; + Window *FindChildWindow(WindowClass wc = WindowClass::Invalid) const; Window *FindChildWindowById(WindowClass wc, WindowNumber number) const; - void CloseChildWindows(WindowClass wc = WC_INVALID) const; + void CloseChildWindows(WindowClass wc = WindowClass::Invalid) const; void CloseChildWindowById(WindowClass wc, WindowNumber number) const; virtual void Close(int data = 0); static void DeleteClosedWindows(); diff --git a/src/window_type.h b/src/window_type.h index 8075bae7cf..5da69c2e02 100644 --- a/src/window_type.h +++ b/src/window_type.h @@ -59,27 +59,27 @@ enum class NetworkStatusWindowNumber : uint8_t { }; /** %Window classes. */ -enum WindowClass : uint16_t { - WC_NONE, ///< No window, redirects to WC_MAIN_WINDOW. +enum class WindowClass : uint16_t { + None, ///< No window, redirects to WindowClass::MainWindow. /** * Main window; %Window numbers: * - 0 = #MainWidgets */ - WC_MAIN_WINDOW = WC_NONE, + MainWindow = WindowClass::None, /** * Main toolbar (the long bar at the top); %Window numbers: * - 0 = #ToolbarNormalWidgets * - 0 = #ToolbarEditorWidgets */ - WC_MAIN_TOOLBAR, + MainToolbar, /** * Statusbar (at the bottom of your screen); %Window numbers: * - 0 = #StatusbarWidgets */ - WC_STATUS_BAR, + Statusbar, /** * Build toolbar; %Window numbers: @@ -88,329 +88,329 @@ enum WindowClass : uint16_t { * - #TRANSPORT_WATER = #DockToolbarWidgets * - #TRANSPORT_ROAD = #RoadToolbarWidgets */ - WC_BUILD_TOOLBAR, + BuildToolbar, /** * Scenario build toolbar; %Window numbers: * - #TRANSPORT_WATER = #DockToolbarWidgets * - #TRANSPORT_ROAD = #RoadToolbarWidgets */ - WC_SCEN_BUILD_TOOLBAR, + ScenarioBuildToolbar, /** * Build trees toolbar; %Window numbers: * - 0 = #BuildTreesWidgets */ - WC_BUILD_TREES, + BuildTrees, /** * Transparency toolbar; %Window numbers: * - 0 = #TransparencyToolbarWidgets */ - WC_TRANSPARENCY_TOOLBAR, + TransparencyToolbar, /** * Build signal toolbar; %Window numbers: * - #TRANSPORT_RAIL = #BuildSignalWidgets */ - WC_BUILD_SIGNAL, + BuildSignal, /** * Small map; %Window numbers: * - 0 = #SmallMapWidgets */ - WC_SMALLMAP, + SmallMap, /** * Error message; %Window numbers: * - 0 = #ErrorMessageWidgets */ - WC_ERRMSG, + ErrorMessage, /** * Tooltip window; %Window numbers: * - 0 = #ToolTipsWidgets */ - WC_TOOLTIPS, + ToolTips, /** * Query string window; %Window numbers: * - #QueryStringWindowNumber::Default = #QueryStringWidgets * - #QueryStringWindowNumber::Sign = #QueryEditSignWidgets */ - WC_QUERY_STRING, + QueryString, /** * Popup with confirm question; %Window numbers: * - #ConfirmPopupQueryWindowNumber::Default = #QueryWidgets * - #ConfirmPopupQueryWindowNumber::Bootstrap = #BootstrapAskForDownloadWidgets */ - WC_CONFIRM_POPUP_QUERY, + ConfirmPopupQuery, /** * Popup with a set of buttons, designed to ask the user a question * from a GameScript. %Window numbers: * - uniqueid = #GoalQuestionWidgets */ - WC_GOAL_QUESTION, + GoalQuestion, /** * Saveload window; %Window numbers: * - 0 = #SaveLoadWidgets */ - WC_SAVELOAD, + SaveLoad, /** * Land info window; %Window numbers: * - 0 = #LandInfoWidgets */ - WC_LAND_INFO, + LandInfo, /** * Drop down menu; %Window numbers: * - 0 = #DropdownMenuWidgets */ - WC_DROPDOWN_MENU, + DropdownMenu, /** * On Screen Keyboard; %Window numbers: * - 0 = #OnScreenKeyboardWidgets */ - WC_OSK, + OnScreenKeyboard, /** * Set date; %Window numbers: * - #VehicleID = #SetDateWidgets */ - WC_SET_DATE, + SetDate, /** * Script settings; %Window numbers: * - 0 = #ScriptSettingsWidgets */ - WC_SCRIPT_SETTINGS, + ScriptSettings, /** * NewGRF parameters; %Window numbers: * - 0 = #NewGRFParametersWidgets */ - WC_GRF_PARAMETERS, + NewGRFParameters, /** * textfile; %Window numbers: * - 0 = #TextfileWidgets */ - WC_TEXTFILE, + Textfile, /** * Town authority; %Window numbers: * - #TownID = #TownAuthorityWidgets */ - WC_TOWN_AUTHORITY, + TownAuthority, /** * Vehicle details; %Window numbers: * - #VehicleID = #VehicleDetailsWidgets */ - WC_VEHICLE_DETAILS, + VehicleDetails, /** * Vehicle refit; %Window numbers: * - #VehicleID = #VehicleRefitWidgets */ - WC_VEHICLE_REFIT, + VehicleRefit, /** * Vehicle orders; %Window numbers: * - #VehicleID = #OrderWidgets */ - WC_VEHICLE_ORDERS, + VehicleOrders, /** * Replace vehicle window; %Window numbers: * - #VehicleType = #ReplaceVehicleWidgets */ - WC_REPLACE_VEHICLE, + ReplaceVehicle, /** * Vehicle timetable; %Window numbers: * - #VehicleID = #VehicleTimetableWidgets */ - WC_VEHICLE_TIMETABLE, + VehicleTimetable, /** * Company colour selection; %Window numbers: * - #CompanyID = #SelectCompanyLiveryWidgets */ - WC_COMPANY_COLOUR, + CompanyLivery, /** * Alter company face window; %Window numbers: * - #CompanyID = #SelectCompanyManagerFaceWidgets */ - WC_COMPANY_MANAGER_FACE, + CompanyManagerFace, /** * Select station (when joining stations); %Window numbers: * - 0 = #JoinStationWidgets */ - WC_SELECT_STATION, + JoinStation, /** * News window; %Window numbers: * - 0 = #NewsWidgets */ - WC_NEWS_WINDOW, + News, /** * Town directory; %Window numbers: * - 0 = #TownDirectoryWidgets */ - WC_TOWN_DIRECTORY, + TownDirectory, /** * Subsidies list; %Window numbers: * - 0 = #SubsidyListWidgets */ - WC_SUBSIDIES_LIST, + SubsidyList, /** * Industry directory; %Window numbers: * - 0 = #IndustryDirectoryWidgets */ - WC_INDUSTRY_DIRECTORY, + IndustryDirectory, /** * News history list; %Window numbers: * - 0 = #MessageHistoryWidgets */ - WC_MESSAGE_HISTORY, + MessageHistory, /** * Sign list; %Window numbers: * - 0 = #SignListWidgets */ - WC_SIGN_LIST, + SignList, /** * Scripts list; %Window numbers: * - 0 = #ScriptListWidgets */ - WC_SCRIPT_LIST, + ScriptList, /** * Goals list; %Window numbers: * - 0 ; #GoalListWidgets */ - WC_GOALS_LIST, + GoalList, /** * Story book; %Window numbers: * - CompanyID = #StoryBookWidgets */ - WC_STORY_BOOK, + StoryBook, /** * Station list; %Window numbers: * - #CompanyID = #StationListWidgets */ - WC_STATION_LIST, + StationList, /** * Trains list; %Window numbers: * - Packed value = #GroupListWidgets / #VehicleListWidgets */ - WC_TRAINS_LIST, + TrainList, /** * Road vehicle list; %Window numbers: * - Packed value = #GroupListWidgets / #VehicleListWidgets */ - WC_ROADVEH_LIST, + RoadVehicleList, /** * Ships list; %Window numbers: * - Packed value = #GroupListWidgets / #VehicleListWidgets */ - WC_SHIPS_LIST, + ShipList, /** * Aircraft list; %Window numbers: * - Packed value = #GroupListWidgets / #VehicleListWidgets */ - WC_AIRCRAFT_LIST, + AircraftList, /** * Town view; %Window numbers: * - #TownID = #TownViewWidgets */ - WC_TOWN_VIEW, + TownView, /** * Vehicle view; %Window numbers: * - #VehicleID = #VehicleViewWidgets */ - WC_VEHICLE_VIEW, + VehicleView, /** * Station view; %Window numbers: * - #StationID = #StationViewWidgets */ - WC_STATION_VIEW, + StationView, /** * Depot view; %Window numbers: * - #TileIndex = #DepotWidgets */ - WC_VEHICLE_DEPOT, + VehicleDepot, /** * Waypoint view; %Window numbers: * - #WaypointID = #WaypointWidgets */ - WC_WAYPOINT_VIEW, + WaypointView, /** * Industry view; %Window numbers: * - #IndustryID = #IndustryViewWidgets */ - WC_INDUSTRY_VIEW, + IndustryView, /** * Company view; %Window numbers: * - #CompanyID = #CompanyWidgets */ - WC_COMPANY, + Company, /** * Build object; %Window numbers: * - 0 = #BuildObjectWidgets */ - WC_BUILD_OBJECT, + BuildObject, /** * Build house; %Window numbers: * - 0 = #BuildHouseWidgets */ - WC_BUILD_HOUSE, + BuildHouse, /** * Build vehicle; %Window numbers: * - #VehicleType = #BuildVehicleWidgets * - #TileIndex = #BuildVehicleWidgets */ - WC_BUILD_VEHICLE, + BuildVehicle, /** * Build bridge; %Window numbers: * - #TransportType = #BuildBridgeSelectionWidgets */ - WC_BUILD_BRIDGE, + BuildBridge, /** * Build station; %Window numbers: @@ -418,19 +418,19 @@ enum WindowClass : uint16_t { * - #TRANSPORT_WATER = #DockToolbarWidgets * - #TRANSPORT_RAIL = #BuildRailStationWidgets */ - WC_BUILD_STATION, + BuildStation, /** * Build bus station; %Window numbers: * - #TRANSPORT_ROAD = #BuildRoadStationWidgets */ - WC_BUS_STATION, + BuildBusStation, /** * Build truck station; %Window numbers: * - #TRANSPORT_ROAD = #BuildRoadStationWidgets */ - WC_TRUCK_STATION, + BuildTruckStation, /** * Build depot; %Window numbers: @@ -438,53 +438,53 @@ enum WindowClass : uint16_t { * - #TRANSPORT_RAIL = #BuildRailDepotWidgets * - #TRANSPORT_ROAD = #BuildRoadDepotWidgets */ - WC_BUILD_DEPOT, + BuildDepot, /** * Build waypoint; %Window numbers: * - #TRANSPORT_RAIL = #BuildRailWaypointWidgets */ - WC_BUILD_WAYPOINT, + BuildWaypoint, /** * Found a town; %Window numbers: * - 0 = #TownFoundingWidgets */ - WC_FOUND_TOWN, + FoundTown, /** * Build industry; %Window numbers: * - 0 = #DynamicPlaceIndustriesWidgets */ - WC_BUILD_INDUSTRY, + BuildIndustry, /** * Select game window; %Window numbers: * - 0 = #SelectGameIntroWidgets */ - WC_SELECT_GAME, + SelectGame, /** * Landscape generation (in Scenario Editor); %Window numbers: * - 0 = #TerraformToolbarWidgets * - 0 = #EditorTerraformToolbarWidgets */ - WC_SCEN_LAND_GEN, + ScenarioGenerateLandscape, /** * Generate landscape (newgame); %Window numbers: * - GLWM_SCENARIO = #CreateScenarioWidgets * - #GenerateLandscapeWindowMode = #GenerateLandscapeWidgets */ - WC_GENERATE_LANDSCAPE, + GenerateLandscape, /** * Progress report of landscape generation; %Window numbers: * - 0 = #GenerationProgressWidgets * - 1 = #ScanProgressWidgets */ - WC_MODAL_PROGRESS, + ModalProgress, /** @@ -493,148 +493,148 @@ enum WindowClass : uint16_t { * - #NetworkWindowNumber::ContentList = #NetworkContentListWidgets * - #NetworkWindowNumber::StartServer = #NetworkStartServerWidgets */ - WC_NETWORK_WINDOW, + Network, /** * Client list; %Window numbers: * - 0 = #ClientListWidgets */ - WC_CLIENT_LIST, + NetworkClientList, /** * Network status window; %Window numbers: * - #NetworkStatusWindowNumber::Join = #NetworkJoinStatusWidgets * - #NetworkStatusWindowNumber::ContentDownload = #NetworkContentDownloadStatusWidgets */ - WC_NETWORK_STATUS_WINDOW, + NetworkStatus, /** * Network ask relay window; %Window numbers: * - 0 - #NetworkAskRelayWidgets */ - WC_NETWORK_ASK_RELAY, + NetworkAskRelay, /** * Network ask survey window; %Window numbers: * - 0 - #NetworkAskSurveyWidgets */ - WC_NETWORK_ASK_SURVEY, + NetworkAskSurvey, /** * Chatbox; %Window numbers: * - #NetworkChatDestinationType = #NetWorkChatWidgets */ - WC_SEND_NETWORK_MSG, + NetworkChat, /** * Industry cargoes chain; %Window numbers: * - 0 = #IndustryCargoesWidgets */ - WC_INDUSTRY_CARGOES, + IndustryCargoes, /** * Legend for graphs; %Window numbers: * - 0 = #GraphLegendWidgets */ - WC_GRAPH_LEGEND, + GraphLegend, /** * Finances of a company; %Window numbers: * - #CompanyID = #CompanyWidgets */ - WC_FINANCES, + Finances, /** * Income graph; %Window numbers: * - 0 = #CompanyValueWidgets */ - WC_INCOME_GRAPH, + IncomeGraph, /** * Operating profit graph; %Window numbers: * - 0 = #CompanyValueWidgets */ - WC_OPERATING_PROFIT, + OperatingProfitGraph, /** * Delivered cargo graph; %Window numbers: * - 0 = #CompanyValueWidgets */ - WC_DELIVERED_CARGO, + DeliveredCargoGraph, /** * Performance history graph; %Window numbers: * - 0 = #PerformanceHistoryGraphWidgets */ - WC_PERFORMANCE_HISTORY, + PerformanceGraph, /** * Company value graph; %Window numbers: * - 0 = #CompanyValueWidgets */ - WC_COMPANY_VALUE, + CompanyValueGraph, /** * Company league window; %Window numbers: * - 0 = #CompanyLeagueWidgets */ - WC_COMPANY_LEAGUE, + CompanyLeague, /** * Payment rates graph; %Window numbers: * - 0 = #CargoPaymentRatesWidgets */ - WC_PAYMENT_RATES, + CargoPaymentRatesGraph, /** * Performance detail window; %Window numbers: * - 0 = #PerformanceRatingDetailsWidgets */ - WC_PERFORMANCE_DETAIL, + PerformanceDetail, /** * Industry production history graph; %Window numbers: * - #IndustryID = #IndustryProductionGraphWidgets */ - WC_INDUSTRY_PRODUCTION, + IndustryProductionGraph, /** * Town cargo history graph; %Window numbers: * - #TownID = #GraphWidgets */ - WC_TOWN_CARGO_GRAPH, + TownCargoGraph, /** * Company infrastructure overview; %Window numbers: * - #CompanyID = #CompanyInfrastructureWidgets */ - WC_COMPANY_INFRASTRUCTURE, + CompanyInfrastructure, /** * Buyout company (merger); %Window numbers: * - #CompanyID = #BuyCompanyWidgets */ - WC_BUY_COMPANY, + BuyCompany, /** * Engine preview window; %Window numbers: * - 0 = #EnginePreviewWidgets */ - WC_ENGINE_PREVIEW, + EnginePreview, /** * Music window; %Window numbers: * - 0 = #MusicWidgets */ - WC_MUSIC_WINDOW, + Music, /** * Music track selection; %Window numbers: * - 0 = MusicTrackSelectionWidgets */ - WC_MUSIC_TRACK_SELECTION, + MusicTrackSelection, /** * Game options window; %Window numbers: @@ -645,110 +645,110 @@ enum WindowClass : uint16_t { * - #GameOptionsWindowNumber::GameOptions = #GameOptionsWidgets * - #GameOptionsWindowNumber::GameSettings = #GameSettingsWidgets */ - WC_GAME_OPTIONS, + GameOptions, /** * Custom currency; %Window numbers: * - 0 = #CustomCurrencyWidgets */ - WC_CUSTOM_CURRENCY, + CustomCurrenty, /** * Cheat window; %Window numbers: * - 0 = #CheatWidgets */ - WC_CHEATS, + Cheat, /** * Extra viewport; %Window numbers: * - Ascending value = #ExtraViewportWidgets */ - WC_EXTRA_VIEWPORT, + ExtraViewport, /** * Console; %Window numbers: * - 0 = #ConsoleWidgets */ - WC_CONSOLE, + Console, /** * Bootstrap; %Window numbers: * - 0 = #BootstrapBackgroundWidgets */ - WC_BOOTSTRAP, + Bootstrap, /** * Highscore; %Window numbers: * - 0 = #HighscoreWidgets */ - WC_HIGHSCORE, + Highscore, /** * Endscreen; %Window numbers: * - 0 = #HighscoreWidgets */ - WC_ENDSCREEN, + Endscreen, /** * Script debug window; %Window numbers: * - Ascending value = #ScriptDebugWidgets */ - WC_SCRIPT_DEBUG, + ScriptDebug, /** * NewGRF inspect (debug); %Window numbers: * - Packed value = #NewGRFInspectWidgets */ - WC_NEWGRF_INSPECT, + NewGRFInspect, /** * Sprite aligner (debug); %Window numbers: * - 0 = #SpriteAlignerWidgets */ - WC_SPRITE_ALIGNER, + SpriteAligner, /** * Linkgraph legend; %Window numbers: * - 0 = #LinkGraphWidgets */ - WC_LINKGRAPH_LEGEND, + LinkGraphLegend, /** * Save preset; %Window numbers: * - 0 = #SavePresetWidgets */ - WC_SAVE_PRESET, + SavePreset, /** * Framerate display; %Window numbers: * - 0 = #FramerateDisplayWidgets */ - WC_FRAMERATE_DISPLAY, + FramerateDisplay, /** * Frame time graph; %Window numbers: * - 0 = #FrametimeGraphWindowWidgets */ - WC_FRAMETIME_GRAPH, + FrametimeGraph, /** * Screenshot window; %Window numbers: * - 0 = #ScreenshotWidgets */ - WC_SCREENSHOT, + Screenshot, /** * Help and manuals window; %Window numbers: * - 0 = #HelpWindowWidgets */ - WC_HELPWIN, + Help, - WC_INVALID = 0xFFFF, ///< Invalid window. + Invalid = 0xFFFF, ///< Invalid window. }; -/** Data value for #Window::OnInvalidateData() of windows with class #WC_GAME_OPTIONS. */ +/** Data value for #Window::OnInvalidateData() of windows with class ::WindowClass::GameOptions. */ enum GameOptionsInvalidationData : uint8_t { GOID_DEFAULT = 0, GOID_NEWGRF_RESCANNED, ///< NewGRFs were just rescanned.