summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-08 11:50:34 +0000
committerrubidium <rubidium@openttd.org>2008-05-08 11:50:34 +0000
commit92aac531c2fdc3e58c108a35e66f723360f46a9a (patch)
tree23ad171b2093a5c5980b9d912bf60056102af9fa
parent51cda2252ceb088d75f25074f1e83e8eec5f18b6 (diff)
downloadopenttd-92aac531c2fdc3e58c108a35e66f723360f46a9a.tar.xz
(svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
-rw-r--r--src/airport_gui.cpp2
-rw-r--r--src/autoreplace_gui.cpp4
-rw-r--r--src/build_vehicle_gui.cpp2
-rw-r--r--src/depot_gui.cpp8
-rw-r--r--src/dock_gui.cpp2
-rw-r--r--src/engine_gui.cpp2
-rw-r--r--src/genworld_gui.cpp6
-rw-r--r--src/graph_gui.cpp18
-rw-r--r--src/group_gui.cpp2
-rw-r--r--src/industry_gui.cpp6
-rw-r--r--src/misc_gui.cpp4
-rw-r--r--src/music_gui.cpp4
-rw-r--r--src/network/network_gui.cpp2
-rw-r--r--src/order_gui.cpp4
-rw-r--r--src/player_gui.cpp10
-rw-r--r--src/rail_gui.cpp2
-rw-r--r--src/road_gui.cpp4
-rw-r--r--src/signs_gui.cpp2
-rw-r--r--src/smallmap_gui.cpp4
-rw-r--r--src/station_gui.cpp4
-rw-r--r--src/subsidy_gui.cpp2
-rw-r--r--src/terraform_gui.cpp4
-rw-r--r--src/timetable_gui.cpp2
-rw-r--r--src/town_gui.cpp8
-rw-r--r--src/transparency_gui.cpp2
-rw-r--r--src/vehicle_gui.cpp14
-rw-r--r--src/window.cpp13
-rw-r--r--src/window_gui.h14
28 files changed, 75 insertions, 76 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index c504a2458..557dc0b63 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -136,7 +136,7 @@ void ShowBuildAirToolbar()
if (!IsValidPlayer(_current_player)) return;
DeleteWindowByClass(WC_BUILD_TOOLBAR);
- Window *w = AllocateWindowDescFront(&_air_toolbar_desc, TRANSPORT_AIR);
+ Window *w = AllocateWindowDescFront<Window>(&_air_toolbar_desc, TRANSPORT_AIR);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
}
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 0d1400c1c..b7b060024 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -527,8 +527,8 @@ static const WindowDesc _replace_vehicle_desc = {
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
{
DeleteWindowById(WC_REPLACE_VEHICLE, vehicletype);
- Window *w = vehicletype == VEH_TRAIN ? AllocateWindowDescFront(&_replace_rail_vehicle_desc, VEH_TRAIN)
- : AllocateWindowDescFront(&_replace_vehicle_desc, vehicletype);
+ Window *w = vehicletype == VEH_TRAIN ? AllocateWindowDescFront<Window>(&_replace_rail_vehicle_desc, VEH_TRAIN)
+ : AllocateWindowDescFront<Window>(&_replace_vehicle_desc, vehicletype);
w->resize.step_height = GetVehicleListHeight(vehicletype);
w->vscroll.cap = w->resize.step_height == 14 ? 8 : 4;
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index d96415ac3..fa397a7ec 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -1192,7 +1192,7 @@ void ShowBuildVehicleWindow(TileIndex tile, VehicleType type)
DeleteWindowById(WC_BUILD_VEHICLE, num);
- w = AllocateWindowDescFront(&_build_vehicle_desc, num, &type);
+ w = AllocateWindowDescFront<Window>(&_build_vehicle_desc, num, &type);
if (w == NULL) return;
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 571bcb210..26cd8ef1c 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -997,13 +997,13 @@ void ShowDepotWindow(TileIndex tile, VehicleType type)
switch (type) {
default: NOT_REACHED();
case VEH_TRAIN:
- w = AllocateWindowDescFront(&_train_depot_desc, tile); break;
+ w = AllocateWindowDescFront<Window>(&_train_depot_desc, tile); break;
case VEH_ROAD:
- w = AllocateWindowDescFront(&_road_depot_desc, tile); break;
+ w = AllocateWindowDescFront<Window>(&_road_depot_desc, tile); break;
case VEH_SHIP:
- w = AllocateWindowDescFront(&_ship_depot_desc, tile); break;
+ w = AllocateWindowDescFront<Window>(&_ship_depot_desc, tile); break;
case VEH_AIRCRAFT:
- w = AllocateWindowDescFront(&_aircraft_depot_desc, tile); break;
+ w = AllocateWindowDescFront<Window>(&_aircraft_depot_desc, tile); break;
}
if (w != NULL) {
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index b5fa85d5d..532ea9633 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -229,7 +229,7 @@ void ShowBuildDocksToolbar()
if (!IsValidPlayer(_current_player)) return;
DeleteWindowByClass(WC_BUILD_TOOLBAR);
- Window *w = AllocateWindowDescFront(&_build_docks_toolbar_desc, TRANSPORT_WATER);
+ Window *w = AllocateWindowDescFront<Window>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
}
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index a91c0fb7d..819921587 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -114,7 +114,7 @@ static const WindowDesc _engine_preview_desc = {
void ShowEnginePreviewWindow(EngineID engine)
{
- AllocateWindowDescFront(&_engine_preview_desc, engine);
+ AllocateWindowDescFront<Window>(&_engine_preview_desc, engine);
}
static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw)
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 01fc43d31..da8b450f8 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -577,7 +577,7 @@ static void _ShowGenerateLandscape(glwp_modes mode)
if (!GetHeightmapDimensions(_file_to_saveload.name, &x, &y)) return;
}
- Window *w = AllocateWindowDescFront((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode);
+ Window *w = AllocateWindowDescFront<Window>((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode);
if (w == NULL) return;
@@ -802,7 +802,7 @@ static const WindowDesc _create_scenario_desc = {
void ShowCreateScenario()
{
DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
- AllocateWindowDescFront(&_create_scenario_desc, GLWP_SCENARIO);
+ AllocateWindowDescFront<Window>(&_create_scenario_desc, GLWP_SCENARIO);
}
@@ -896,7 +896,7 @@ void PrepareGenerateWorldProgress()
*/
void ShowGenerateWorldProgress()
{
- AllocateWindowDescFront(&_show_terrain_progress_desc, 0);
+ AllocateWindowDescFront<Window>(&_show_terrain_progress_desc, 0);
}
static void _SetGeneratingWorldProgress(gwp_class cls, uint progress, uint total)
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index bce14576b..e44545ce1 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -339,7 +339,7 @@ static const WindowDesc _graph_legend_desc = {
static void ShowGraphLegend()
{
- AllocateWindowDescFront(&_graph_legend_desc, 0);
+ AllocateWindowDescFront<Window>(&_graph_legend_desc, 0);
}
/********************/
@@ -438,7 +438,7 @@ static const WindowDesc _operating_profit_desc = {
void ShowOperatingProfitGraph()
{
- if (AllocateWindowDescFront(&_operating_profit_desc, 0)) {
+ if (AllocateWindowDescFront<Window>(&_operating_profit_desc, 0)) {
InvalidateWindow(WC_GRAPH_LEGEND, 0);
}
}
@@ -506,7 +506,7 @@ static const WindowDesc _income_graph_desc = {
void ShowIncomeGraph()
{
- if (AllocateWindowDescFront(&_income_graph_desc, 0)) {
+ if (AllocateWindowDescFront<Window>(&_income_graph_desc, 0)) {
InvalidateWindow(WC_GRAPH_LEGEND, 0);
}
}
@@ -573,7 +573,7 @@ static const WindowDesc _delivered_cargo_graph_desc = {
void ShowDeliveredCargoGraph()
{
- if (AllocateWindowDescFront(&_delivered_cargo_graph_desc, 0)) {
+ if (AllocateWindowDescFront<Window>(&_delivered_cargo_graph_desc, 0)) {
InvalidateWindow(WC_GRAPH_LEGEND, 0);
}
}
@@ -642,7 +642,7 @@ static const WindowDesc _performance_history_desc = {
void ShowPerformanceHistoryGraph()
{
- if (AllocateWindowDescFront(&_performance_history_desc, 0)) {
+ if (AllocateWindowDescFront<Window>(&_performance_history_desc, 0)) {
InvalidateWindow(WC_GRAPH_LEGEND, 0);
}
}
@@ -709,7 +709,7 @@ static const WindowDesc _company_value_graph_desc = {
void ShowCompanyValueGraph()
{
- if (AllocateWindowDescFront(&_company_value_graph_desc, 0)) {
+ if (AllocateWindowDescFront<Window>(&_company_value_graph_desc, 0)) {
InvalidateWindow(WC_GRAPH_LEGEND, 0);
}
}
@@ -807,7 +807,7 @@ static const WindowDesc _cargo_payment_rates_desc = {
void ShowCargoPaymentRates()
{
- Window *w = AllocateWindowDescFront(&_cargo_payment_rates_desc, 0);
+ Window *w = AllocateWindowDescFront<Window>(&_cargo_payment_rates_desc, 0);
if (w == NULL) return;
/* Count the number of active cargo types */
@@ -928,7 +928,7 @@ static const WindowDesc _company_league_desc = {
void ShowCompanyLeagueTable()
{
- AllocateWindowDescFront(&_company_league_desc, 0);
+ AllocateWindowDescFront<Window>(&_company_league_desc, 0);
}
/*****************************/
@@ -1163,5 +1163,5 @@ static const WindowDesc _performance_rating_detail_desc = {
void ShowPerformanceRatingDetail()
{
- AllocateWindowDescFront(&_performance_rating_detail_desc, 0);
+ AllocateWindowDescFront<Window>(&_performance_rating_detail_desc, 0);
}
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index 4f7a551a4..baff7798d 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -811,7 +811,7 @@ void ShowPlayerGroup(PlayerID player, VehicleType vehicle_type)
WindowNumber num = (vehicle_type << 11) | VLW_GROUP_LIST | player;
DeleteWindowById(wc, num);
- Window *w = AllocateWindowDescFront(&_group_desc, num);
+ Window *w = AllocateWindowDescFront<Window>(&_group_desc, num);
if (w == NULL) return;
w->window_class = wc;
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 2f1f10f79..261c8d1cd 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -395,7 +395,7 @@ static const WindowDesc _build_industry_dynamic_desc = {
void ShowBuildIndustryWindow()
{
if (_game_mode != GM_EDITOR && !IsValidPlayer(_current_player)) return;
- AllocateWindowDescFront(&_build_industry_dynamic_desc, 0);
+ AllocateWindowDescFront<Window>(&_build_industry_dynamic_desc, 0);
}
static void UpdateIndustryProduction(Industry *i);
@@ -636,7 +636,7 @@ static const WindowDesc _industry_view_desc = {
void ShowIndustryViewWindow(int industry)
{
- Window *w = AllocateWindowDescFront(&_industry_view_desc, industry);
+ Window *w = AllocateWindowDescFront<Window>(&_industry_view_desc, industry);
if (w != NULL) {
w->flags4 |= WF_DISABLE_VP_SCROLL;
@@ -902,7 +902,7 @@ static const WindowDesc _industry_directory_desc = {
void ShowIndustryDirectory()
{
- Window *w = AllocateWindowDescFront(&_industry_directory_desc, 0);
+ Window *w = AllocateWindowDescFront<Window>(&_industry_directory_desc, 0);
if (w != NULL) {
w->vscroll.cap = 16;
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 59dea3bd3..bcc9d31b4 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -482,12 +482,12 @@ static const WindowDesc _build_trees_scen_desc = {
void ShowBuildTreesToolbar()
{
if (!IsValidPlayer(_current_player)) return;
- AllocateWindowDescFront(&_build_trees_desc, 0);
+ AllocateWindowDescFront<Window>(&_build_trees_desc, 0);
}
void ShowBuildTreesScenToolbar()
{
- AllocateWindowDescFront(&_build_trees_scen_desc, 0);
+ AllocateWindowDescFront<Window>(&_build_trees_scen_desc, 0);
}
static uint64 _errmsg_decode_params[20];
diff --git a/src/music_gui.cpp b/src/music_gui.cpp
index 59234dc79..7508ea9d2 100644
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -334,7 +334,7 @@ static const WindowDesc _music_track_selection_desc = {
static void ShowMusicTrackSelection()
{
- AllocateWindowDescFront(&_music_track_selection_desc, 0);
+ AllocateWindowDescFront<Window>(&_music_track_selection_desc, 0);
}
static void MusicWindowWndProc(Window *w, WindowEvent *e)
@@ -502,5 +502,5 @@ static const WindowDesc _music_window_desc = {
void ShowMusicWindow()
{
- AllocateWindowDescFront(&_music_window_desc, 0);
+ AllocateWindowDescFront<Window>(&_music_window_desc, 0);
}
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 670eff31b..569db534b 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -1617,7 +1617,7 @@ static void ClientListWndProc(Window *w, WindowEvent *e)
void ShowClientList()
{
- AllocateWindowDescFront(&_client_list_desc, 0);
+ AllocateWindowDescFront<Window>(&_client_list_desc, 0);
}
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 125118fcb..126600d27 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -1185,9 +1185,9 @@ void ShowOrdersWindow(const Vehicle *v)
DeleteWindowById(WC_VEHICLE_DETAILS, veh);
if (v->owner != _local_player) {
- w = AllocateWindowDescFront(&_other_orders_desc, veh);
+ w = AllocateWindowDescFront<Window>(&_other_orders_desc, veh);
} else {
- w = AllocateWindowDescFront((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? &_orders_train_desc : &_orders_desc, veh);
+ w = AllocateWindowDescFront<Window>((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? &_orders_train_desc : &_orders_desc, veh);
}
if (w != NULL) {
diff --git a/src/player_gui.cpp b/src/player_gui.cpp
index fb8a8b11d..4724a0dbb 100644
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -247,7 +247,7 @@ static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_sti
{
if (!IsValidPlayer(player)) return;
- Window *w = AllocateWindowDescFront(show_small ? &_player_finances_small_desc : &_player_finances_desc, player);
+ Window *w = AllocateWindowDescFront<Window>(show_small ? &_player_finances_small_desc : &_player_finances_desc, player);
if (w != NULL) {
w->caption_color = w->window_number;
WP(w, def_d).data_1 = show_small;
@@ -1018,7 +1018,7 @@ static void DoSelectPlayerFace(PlayerID player, bool adv, int top, int left)
{
if (!IsValidPlayer(player)) return;
- Window *w = AllocateWindowDescFront(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, player); // simple or advanced window
+ Window *w = AllocateWindowDescFront<Window>(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, player); // simple or advanced window
if (w != NULL) {
w->caption_color = w->window_number;
@@ -1235,7 +1235,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
case PCW_WIDGET_NEW_FACE: DoSelectPlayerFace((PlayerID)w->window_number, false); break;
case PCW_WIDGET_COLOR_SCHEME: {
- Window *wf = AllocateWindowDescFront(_loaded_newgrf_features.has_2CC ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number);
+ Window *wf = AllocateWindowDescFront<Window>(_loaded_newgrf_features.has_2CC ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number);
if (wf != NULL) {
wf->caption_color = wf->window_number;
WP(wf, livery_d).livery_class = LC_OTHER;
@@ -1355,7 +1355,7 @@ void ShowPlayerCompany(PlayerID player)
if (!IsValidPlayer(player)) return;
- w = AllocateWindowDescFront(&_player_company_desc, player);
+ w = AllocateWindowDescFront<Window>(&_player_company_desc, player);
if (w != NULL) w->caption_color = w->window_number;
}
@@ -1411,7 +1411,7 @@ static const WindowDesc _buy_company_desc = {
void ShowBuyCompanyDialog(uint player)
{
- AllocateWindowDescFront(&_buy_company_desc, player);
+ AllocateWindowDescFront<Window>(&_buy_company_desc, player);
}
/********** HIGHSCORE and ENDGAME windows */
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 2fcbc489c..a15e86382 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -752,7 +752,7 @@ void ShowBuildRailToolbar(RailType railtype, int button)
if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL))) {
DeleteWindowByClass(WC_BUILD_TOOLBAR);
_cur_railtype = railtype;
- w = AllocateWindowDescFront(&_build_rail_desc, TRANSPORT_RAIL);
+ w = AllocateWindowDescFront<Window>(&_build_rail_desc, TRANSPORT_RAIL);
SetupRailToolbar(railtype, w);
}
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index adad95164..07a6f1d0e 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -679,7 +679,7 @@ void ShowBuildRoadToolbar(RoadType roadtype)
_cur_roadtype = roadtype;
DeleteWindowByClass(WC_BUILD_TOOLBAR);
- Window *w = AllocateWindowDescFront(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
+ Window *w = AllocateWindowDescFront<Window>(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
}
@@ -714,7 +714,7 @@ static const WindowDesc _build_road_scen_desc = {
void ShowBuildRoadScenToolbar()
{
_cur_roadtype = ROADTYPE_ROAD;
- AllocateWindowDescFront(&_build_road_scen_desc, 0);
+ AllocateWindowDescFront<Window>(&_build_road_scen_desc, 0);
}
/** Enum referring to the widgets of the build road depot window */
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 328f02ad2..643caf8b3 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -135,7 +135,7 @@ static const WindowDesc _sign_list_desc = {
void ShowSignList()
{
- Window *w = AllocateWindowDescFront(&_sign_list_desc, 0);
+ Window *w = AllocateWindowDescFront<Window>(&_sign_list_desc, 0);
if (w != NULL) {
w->vscroll.cap = 12;
w->resize.step_height = 10;
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 17f690b54..9651bf12f 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -1055,7 +1055,7 @@ void ShowSmallMap()
{
Window *w;
- w = AllocateWindowDescFront(&_smallmap_desc, 0);
+ w = AllocateWindowDescFront<Window>(&_smallmap_desc, 0);
if (w == NULL) return;
/* Resize the window to fit industries list */
@@ -1199,7 +1199,7 @@ void ShowExtraViewPortWindow(TileIndex tile)
/* find next free window number for extra viewport */
while (FindWindowById(WC_EXTRA_VIEW_PORT, i) != NULL) i++;
- Window *w = AllocateWindowDescFront(&_extra_view_port_desc, i);
+ Window *w = AllocateWindowDescFront<Window>(&_extra_view_port_desc, i);
if (w != NULL) {
Point pt;
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 376a234d5..578fcc832 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -620,7 +620,7 @@ void ShowPlayerStations(PlayerID player)
{
if (!IsValidPlayer(player)) return;
- Window *w = AllocateWindowDescFront(&_player_stations_desc, player);
+ Window *w = AllocateWindowDescFront<Window>(&_player_stations_desc, player);
if (w == NULL) return;
w->caption_color = (byte)w->window_number;
@@ -1043,7 +1043,7 @@ static const WindowDesc _station_view_desc = {
*/
void ShowStationViewWindow(StationID station)
{
- Window *w = AllocateWindowDescFront(&_station_view_desc, station);
+ Window *w = AllocateWindowDescFront<Window>(&_station_view_desc, station);
if (w == NULL) return;
PlayerID owner = GetStation(w->window_number)->owner;
diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp
index 7c88ef68a..a9c62154f 100644
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -197,5 +197,5 @@ static const WindowDesc _subsidies_list_desc = {
void ShowSubsidiesList()
{
- AllocateWindowDescFront(&_subsidies_list_desc, 0);
+ AllocateWindowDescFront<Window>(&_subsidies_list_desc, 0);
}
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index 81c46959b..12831c293 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -304,7 +304,7 @@ static const WindowDesc _terraform_desc = {
void ShowTerraformToolbar(Window *link)
{
if (!IsValidPlayer(_current_player)) return;
- Window *w = AllocateWindowDescFront(&_terraform_desc, 0);
+ Window *w = AllocateWindowDescFront<Window>(&_terraform_desc, 0);
if (w != NULL && link != NULL) {
/* Align the terraform toolbar under the main toolbar and put the linked
* toolbar to left of it
@@ -679,5 +679,5 @@ static const WindowDesc _scen_edit_land_gen_desc = {
void ShowEditorTerraformToolbar()
{
- AllocateWindowDescFront(&_scen_edit_land_gen_desc, 0);
+ AllocateWindowDescFront<Window>(&_scen_edit_land_gen_desc, 0);
}
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index 8379c7486..e63e8f305 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -301,7 +301,7 @@ static const WindowDesc _timetable_desc = {
void ShowTimetableWindow(const Vehicle *v)
{
- Window *w = AllocateWindowDescFront(&_timetable_desc, v->index);
+ Window *w = AllocateWindowDescFront<Window>(&_timetable_desc, v->index);
if (w != NULL) {
w->caption_color = v->owner;
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index d67d42469..283cd448c 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -268,7 +268,7 @@ static const WindowDesc _town_authority_desc = {
static void ShowTownAuthorityWindow(uint town)
{
- Window *w = AllocateWindowDescFront(&_town_authority_desc, town);
+ Window *w = AllocateWindowDescFront<Window>(&_town_authority_desc, town);
if (w != NULL) {
w->vscroll.cap = 5;
@@ -397,7 +397,7 @@ void ShowTownViewWindow(TownID town)
{
Window *w;
- w = AllocateWindowDescFront(&_town_view_desc, town);
+ w = AllocateWindowDescFront<Window>(&_town_view_desc, town);
if (w != NULL) {
w->flags4 |= WF_DISABLE_VP_SCROLL;
@@ -576,7 +576,7 @@ static const WindowDesc _town_directory_desc = {
void ShowTownDirectory()
{
- Window *w = AllocateWindowDescFront(&_town_directory_desc, 0);
+ Window *w = AllocateWindowDescFront<Window>(&_town_directory_desc, 0);
if (w != NULL) {
w->vscroll.cap = 16;
@@ -705,6 +705,6 @@ static const WindowDesc _scen_edit_town_gen_desc = {
void ShowBuildTownWindow()
{
if (_game_mode != GM_EDITOR && !IsValidPlayer(_current_player)) return;
- AllocateWindowDescFront(&_scen_edit_town_gen_desc, 0);
+ AllocateWindowDescFront<Window>(&_scen_edit_town_gen_desc, 0);
}
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp
index eee61bd16..7e4b7ddfd 100644
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -126,5 +126,5 @@ static const WindowDesc _transparency_desc = {
void ShowTransparencyToolbar(void)
{
- AllocateWindowDescFront(&_transparency_desc, 0);
+ AllocateWindowDescFront<Window>(&_transparency_desc, 0);
}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 13156b350..bab13faa5 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -451,7 +451,7 @@ void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order)
DeleteWindowById(WC_VEHICLE_REFIT, v->index);
- w = AllocateWindowDescFront(&_vehicle_refit_desc, v->index);
+ w = AllocateWindowDescFront<Window>(&_vehicle_refit_desc, v->index);
WP(w, refit_d).order = order;
if (w != NULL) {
@@ -1244,18 +1244,18 @@ static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, Vehicle
switch (vehicle_type) {
default: NOT_REACHED();
case VEH_TRAIN:
- w = AllocateWindowDescFront(&_player_vehicle_list_train_desc, num);
+ w = AllocateWindowDescFront<Window>(&_player_vehicle_list_train_desc, num);
if (w != NULL) ResizeWindow(w, 65, 38);
break;
case VEH_ROAD:
- w = AllocateWindowDescFront(&_player_vehicle_list_road_veh_desc, num);
+ w = AllocateWindowDescFront<Window>(&_player_vehicle_list_road_veh_desc, num);
if (w != NULL) ResizeWindow(w, 0, 38);
break;
case VEH_SHIP:
- w = AllocateWindowDescFront(&_player_vehicle_list_ship_desc, num);
+ w = AllocateWindowDescFront<Window>(&_player_vehicle_list_ship_desc, num);
break;
case VEH_AIRCRAFT:
- w = AllocateWindowDescFront(&_player_vehicle_list_aircraft_desc, num);
+ w = AllocateWindowDescFront<Window>(&_player_vehicle_list_aircraft_desc, num);
break;
}
@@ -1671,7 +1671,7 @@ static void ShowVehicleDetailsWindow(const Vehicle *v)
{
DeleteWindowById(WC_VEHICLE_ORDERS, v->index);
DeleteWindowById(WC_VEHICLE_DETAILS, v->index);
- AllocateWindowDescFront(&_vehicle_details_desc, v->index);
+ AllocateWindowDescFront<Window>(&_vehicle_details_desc, v->index);
}
@@ -1747,7 +1747,7 @@ static const int VV_INITIAL_VIEWPORT_HEIGHT_TRAIN = 102;
/** Shows the vehicle view window of the given vehicle. */
void ShowVehicleViewWindow(const Vehicle *v)
{
- Window *w = AllocateWindowDescFront((v->type == VEH_TRAIN) ? &_train_view_desc : &_vehicle_view_desc, v->index);
+ Window *w = AllocateWindowDescFront<Window>((v->type == VEH_TRAIN) ? &_train_view_desc : &_vehicle_view_desc, v->index);
if (w != NULL) {
w->caption_color = v->owner;
diff --git a/src/window.cpp b/src/window.cpp
index a220a9369..d59c39cef 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1012,19 +1012,6 @@ Window::Window(const WindowDesc *desc, void *data, WindowNumber window_number)
this->desc_flags = desc->flags;
}
-/**
- * Open a new window.
- * @param *desc The pointer to the WindowDesc to be created
- * @param window_number the window number of the new window
- * @param data arbitrary data that is send with the WE_CREATE message
- * @return see Window pointer of the newly created window
- */
-Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data)
-{
- if (BringWindowToFrontById(desc->cls, window_number)) return NULL;
- return new Window(desc, data, window_number);
-}
-
/** Do a search for a window at specific coordinates. For this we start
* at the topmost window, obviously and work our way down to the bottom
* @param x position x to query
diff --git a/src/window_gui.h b/src/window_gui.h
index 32352d3ea..14e666a63 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -561,7 +561,19 @@ Window *FindWindowFromPt(int x, int y);
bool IsWindowOfPrototype(const Window *w, const Widget *widget);
void AssignWidgetToWindow(Window *w, const Widget *widget);
-Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data = NULL);
+/**
+ * Open a new window.
+ * @param *desc The pointer to the WindowDesc to be created
+ * @param window_number the window number of the new window
+ * @param data arbitrary data that is send with the WE_CREATE message
+ * @return see Window pointer of the newly created window
+ */
+template <typename Wcls>
+Wcls *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data = NULL)
+{
+ if (BringWindowToFrontById(desc->cls, window_number)) return NULL;
+ return new Wcls(desc, data, window_number);
+}
void DrawWindowViewport(const Window *w);