changeset 9143:00b40c2158ff draft

(svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
author rubidium <rubidium@openttd.org>
date Thu, 08 May 2008 11:50:34 +0000 (2008-05-08)
parents ce2b22b5ad16
children e45afd45d64c
files src/airport_gui.cpp src/autoreplace_gui.cpp src/build_vehicle_gui.cpp src/depot_gui.cpp src/dock_gui.cpp src/engine_gui.cpp src/genworld_gui.cpp src/graph_gui.cpp src/group_gui.cpp src/industry_gui.cpp src/misc_gui.cpp src/music_gui.cpp src/network/network_gui.cpp src/order_gui.cpp src/player_gui.cpp src/rail_gui.cpp src/road_gui.cpp src/signs_gui.cpp src/smallmap_gui.cpp src/station_gui.cpp src/subsidy_gui.cpp src/terraform_gui.cpp src/timetable_gui.cpp src/town_gui.cpp src/transparency_gui.cpp src/vehicle_gui.cpp src/window.cpp src/window_gui.h
diffstat 28 files changed, 75 insertions(+), 76 deletions(-) [+]
line wrap: on
line diff
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -136,7 +136,7 @@
 	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);
 }
 
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -527,8 +527,8 @@
 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;
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -1192,7 +1192,7 @@
 
 	DeleteWindowById(WC_BUILD_VEHICLE, num);
 
-	w = AllocateWindowDescFront(&_build_vehicle_desc, num, &type);
+	w = AllocateWindowDescFront<Window>(&_build_vehicle_desc, num, &type);
 
 	if (w == NULL) return;
 
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -997,13 +997,13 @@
 	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) {
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -229,7 +229,7 @@
 	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);
 }
 
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -114,7 +114,7 @@
 
 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)
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -577,7 +577,7 @@
 		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 @@
 void ShowCreateScenario()
 {
 	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
-	AllocateWindowDescFront(&_create_scenario_desc, GLWP_SCENARIO);
+	AllocateWindowDescFront<Window>(&_create_scenario_desc, GLWP_SCENARIO);
 }
 
 
@@ -896,7 +896,7 @@
  */
 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)
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -339,7 +339,7 @@
 
 static void ShowGraphLegend()
 {
-	AllocateWindowDescFront(&_graph_legend_desc, 0);
+	AllocateWindowDescFront<Window>(&_graph_legend_desc, 0);
 }
 
 /********************/
@@ -438,7 +438,7 @@
 
 void ShowOperatingProfitGraph()
 {
-	if (AllocateWindowDescFront(&_operating_profit_desc, 0)) {
+	if (AllocateWindowDescFront<Window>(&_operating_profit_desc, 0)) {
 		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 	}
 }
@@ -506,7 +506,7 @@
 
 void ShowIncomeGraph()
 {
-	if (AllocateWindowDescFront(&_income_graph_desc, 0)) {
+	if (AllocateWindowDescFront<Window>(&_income_graph_desc, 0)) {
 		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 	}
 }
@@ -573,7 +573,7 @@
 
 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 @@
 
 void ShowPerformanceHistoryGraph()
 {
-	if (AllocateWindowDescFront(&_performance_history_desc, 0)) {
+	if (AllocateWindowDescFront<Window>(&_performance_history_desc, 0)) {
 		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 	}
 }
@@ -709,7 +709,7 @@
 
 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 @@
 
 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 @@
 
 void ShowCompanyLeagueTable()
 {
-	AllocateWindowDescFront(&_company_league_desc, 0);
+	AllocateWindowDescFront<Window>(&_company_league_desc, 0);
 }
 
 /*****************************/
@@ -1163,5 +1163,5 @@
 
 void ShowPerformanceRatingDetail()
 {
-	AllocateWindowDescFront(&_performance_rating_detail_desc, 0);
+	AllocateWindowDescFront<Window>(&_performance_rating_detail_desc, 0);
 }
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -811,7 +811,7 @@
 
 	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;
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -395,7 +395,7 @@
 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 @@
 
 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 @@
 
 void ShowIndustryDirectory()
 {
-	Window *w = AllocateWindowDescFront(&_industry_directory_desc, 0);
+	Window *w = AllocateWindowDescFront<Window>(&_industry_directory_desc, 0);
 
 	if (w != NULL) {
 		w->vscroll.cap = 16;
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -482,12 +482,12 @@
 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];
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -334,7 +334,7 @@
 
 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 @@
 
 void ShowMusicWindow()
 {
-	AllocateWindowDescFront(&_music_window_desc, 0);
+	AllocateWindowDescFront<Window>(&_music_window_desc, 0);
 }
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -1617,7 +1617,7 @@
 
 void ShowClientList()
 {
-	AllocateWindowDescFront(&_client_list_desc, 0);
+	AllocateWindowDescFront<Window>(&_client_list_desc, 0);
 }
 
 
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -1185,9 +1185,9 @@
 	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) {
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -247,7 +247,7 @@
 {
 	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 @@
 {
 	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 @@
 				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 @@
 
 	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 @@
 
 void ShowBuyCompanyDialog(uint player)
 {
-	AllocateWindowDescFront(&_buy_company_desc, player);
+	AllocateWindowDescFront<Window>(&_buy_company_desc, player);
 }
 
 /********** HIGHSCORE and ENDGAME windows */
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -752,7 +752,7 @@
 	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);
 	}
 
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -679,7 +679,7 @@
 	_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 @@
 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 */
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -135,7 +135,7 @@
 
 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;
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -1055,7 +1055,7 @@
 {
 	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 @@
 	/* 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;
 
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -620,7 +620,7 @@
 {
 	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 @@
  */
 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;
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -197,5 +197,5 @@
 
 void ShowSubsidiesList()
 {
-	AllocateWindowDescFront(&_subsidies_list_desc, 0);
+	AllocateWindowDescFront<Window>(&_subsidies_list_desc, 0);
 }
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -304,7 +304,7 @@
 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 @@
 
 void ShowEditorTerraformToolbar()
 {
-	AllocateWindowDescFront(&_scen_edit_land_gen_desc, 0);
+	AllocateWindowDescFront<Window>(&_scen_edit_land_gen_desc, 0);
 }
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -301,7 +301,7 @@
 
 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;
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -268,7 +268,7 @@
 
 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 @@
 {
 	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 @@
 
 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 @@
 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);
 }
 
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -126,5 +126,5 @@
 
 void ShowTransparencyToolbar(void)
 {
-	AllocateWindowDescFront(&_transparency_desc, 0);
+	AllocateWindowDescFront<Window>(&_transparency_desc, 0);
 }
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -451,7 +451,7 @@
 
 	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 @@
 	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 @@
 {
 	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 @@
 /** 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;
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1012,19 +1012,6 @@
 	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
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -561,7 +561,19 @@
 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);