Changeset - r9143:e484ce861c88
[Not reviewed]
master
0 28 0
rubidium - 16 years ago 2008-05-08 11:50:34
rubidium@openttd.org
(svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
28 files changed with 75 insertions and 76 deletions:
0 comments (0 inline, 0 general)
src/airport_gui.cpp
Show inline comments
 
@@ -133,13 +133,13 @@ static const WindowDesc _air_toolbar_des
 

	
 
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);
 
}
 

	
 
enum {
 
	BAW_BOTTOMPANEL = 10,
 
	BAW_SMALL_AIRPORT,
src/autoreplace_gui.cpp
Show inline comments
 
@@ -524,14 +524,14 @@ static const WindowDesc _replace_vehicle
 
};
 

	
 

	
 
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;
 

	
 
	Widget *widget = w->widget;
 
	widget[RVW_WIDGET_LEFT_MATRIX].data = widget[RVW_WIDGET_RIGHT_MATRIX].data = (w->vscroll.cap << 8) + 1;
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1189,13 +1189,13 @@ void ShowBuildVehicleWindow(TileIndex ti
 
	uint num = (tile == 0) ? (int)type : tile;
 

	
 
	assert(IsPlayerBuildableVehicleType(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;
 

	
 
	w->caption_color = (tile != 0) ? GetTileOwner(tile) : _local_player;
 

	
 
	bv = &WP(w, buildvehicle_d);
src/depot_gui.cpp
Show inline comments
 
@@ -994,19 +994,19 @@ void ShowDepotWindow(TileIndex tile, Veh
 
{
 
	Window *w;
 

	
 
	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) {
 
		w->caption_color = GetTileOwner(tile);
 
		CreateDepotListWindow(w, type);
 
	}
src/dock_gui.cpp
Show inline comments
 
@@ -226,13 +226,13 @@ static const WindowDesc _build_docks_too
 

	
 
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);
 
}
 

	
 
static void BuildDockStationWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
src/engine_gui.cpp
Show inline comments
 
@@ -111,13 +111,13 @@ static const WindowDesc _engine_preview_
 
	EnginePreviewWndProc
 
};
 

	
 

	
 
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)
 
{
 
	const RailVehicleInfo *rvi = RailVehInfo(engine);
 
	int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD) ? 1 : 0;
src/genworld_gui.cpp
Show inline comments
 
@@ -574,13 +574,13 @@ static void _ShowGenerateLandscape(glwp_
 

	
 
	if (mode == GLWP_HEIGHTMAP) {
 
		/* If the function returns negative, it means there was a problem loading the heightmap */
 
		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;
 

	
 
	if (mode == GLWP_HEIGHTMAP) {
 
		WP(w, generate_d).x = x;
 
		WP(w, generate_d).y = y;
 
@@ -799,13 +799,13 @@ static const WindowDesc _create_scenario
 
	CreateScenarioWndProc,
 
};
 

	
 
void ShowCreateScenario()
 
{
 
	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
 
	AllocateWindowDescFront(&_create_scenario_desc, GLWP_SCENARIO);
 
	AllocateWindowDescFront<Window>(&_create_scenario_desc, GLWP_SCENARIO);
 
}
 

	
 

	
 
static const Widget _show_terrain_progress_widgets[] = {
 
{    WWT_CAPTION,   RESIZE_NONE,    14,     0,   180,     0,    13, STR_GENERATION_WORLD,   STR_018C_WINDOW_TITLE_DRAG_THIS},
 
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   180,    14,    96, 0x0,                    STR_NULL},
 
@@ -893,13 +893,13 @@ void PrepareGenerateWorldProgress()
 

	
 
/**
 
 * Show the window where a user can follow the process of the map generation.
 
 */
 
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)
 
{
 
	static const int percent_table[GWP_CLASS_COUNT + 1] = {0, 5, 15, 20, 40, 60, 65, 80, 85, 99, 100 };
 
	static const StringID class_table[GWP_CLASS_COUNT]  = {
src/graph_gui.cpp
Show inline comments
 
@@ -336,13 +336,13 @@ static const WindowDesc _graph_legend_de
 
	_graph_legend_widgets,
 
	GraphLegendWndProc
 
};
 

	
 
static void ShowGraphLegend()
 
{
 
	AllocateWindowDescFront(&_graph_legend_desc, 0);
 
	AllocateWindowDescFront<Window>(&_graph_legend_desc, 0);
 
}
 

	
 
/********************/
 
/* OPERATING PROFIT */
 
/********************/
 

	
 
@@ -435,13 +435,13 @@ static const WindowDesc _operating_profi
 
	OperatingProfitWndProc
 
};
 

	
 

	
 
void ShowOperatingProfitGraph()
 
{
 
	if (AllocateWindowDescFront(&_operating_profit_desc, 0)) {
 
	if (AllocateWindowDescFront<Window>(&_operating_profit_desc, 0)) {
 
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 
	}
 
}
 

	
 

	
 
/****************/
 
@@ -503,13 +503,13 @@ static const WindowDesc _income_graph_de
 
	_income_graph_widgets,
 
	IncomeGraphWndProc
 
};
 

	
 
void ShowIncomeGraph()
 
{
 
	if (AllocateWindowDescFront(&_income_graph_desc, 0)) {
 
	if (AllocateWindowDescFront<Window>(&_income_graph_desc, 0)) {
 
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 
	}
 
}
 

	
 
/*******************/
 
/* DELIVERED CARGO */
 
@@ -570,13 +570,13 @@ static const WindowDesc _delivered_cargo
 
	_delivered_cargo_graph_widgets,
 
	DeliveredCargoGraphWndProc
 
};
 

	
 
void ShowDeliveredCargoGraph()
 
{
 
	if (AllocateWindowDescFront(&_delivered_cargo_graph_desc, 0)) {
 
	if (AllocateWindowDescFront<Window>(&_delivered_cargo_graph_desc, 0)) {
 
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 
	}
 
}
 

	
 
/***********************/
 
/* PERFORMANCE HISTORY */
 
@@ -639,13 +639,13 @@ static const WindowDesc _performance_his
 
	_performance_history_widgets,
 
	PerformanceHistoryWndProc
 
};
 

	
 
void ShowPerformanceHistoryGraph()
 
{
 
	if (AllocateWindowDescFront(&_performance_history_desc, 0)) {
 
	if (AllocateWindowDescFront<Window>(&_performance_history_desc, 0)) {
 
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 
	}
 
}
 

	
 
/*****************/
 
/* COMPANY VALUE */
 
@@ -706,13 +706,13 @@ static const WindowDesc _company_value_g
 
	_company_value_graph_widgets,
 
	CompanyValueGraphWndProc
 
};
 

	
 
void ShowCompanyValueGraph()
 
{
 
	if (AllocateWindowDescFront(&_company_value_graph_desc, 0)) {
 
	if (AllocateWindowDescFront<Window>(&_company_value_graph_desc, 0)) {
 
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 
	}
 
}
 

	
 
/*****************/
 
/* PAYMENT RATES */
 
@@ -804,13 +804,13 @@ static const WindowDesc _cargo_payment_r
 
	CargoPaymentRatesWndProc
 
};
 

	
 

	
 
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 */
 
	uint num_active = 0;
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		if (GetCargo(c)->IsValid()) num_active++;
 
@@ -925,13 +925,13 @@ static const WindowDesc _company_league_
 
	_company_league_widgets,
 
	CompanyLeagueWndProc
 
};
 

	
 
void ShowCompanyLeagueTable()
 
{
 
	AllocateWindowDescFront(&_company_league_desc, 0);
 
	AllocateWindowDescFront<Window>(&_company_league_desc, 0);
 
}
 

	
 
/*****************************/
 
/* PERFORMANCE RATING DETAIL */
 
/*****************************/
 

	
 
@@ -1160,8 +1160,8 @@ static const WindowDesc _performance_rat
 
	_performance_rating_detail_widgets,
 
	PerformanceRatingDetailWndProc
 
};
 

	
 
void ShowPerformanceRatingDetail()
 
{
 
	AllocateWindowDescFront(&_performance_rating_detail_desc, 0);
 
	AllocateWindowDescFront<Window>(&_performance_rating_detail_desc, 0);
 
}
src/group_gui.cpp
Show inline comments
 
@@ -808,11 +808,11 @@ void ShowPlayerGroup(PlayerID player, Ve
 
		case VEH_SHIP:     wc = WC_SHIPS_LIST;    break;
 
		case VEH_AIRCRAFT: wc = WC_AIRCRAFT_LIST; break;
 
	}
 

	
 
	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;
 
}
src/industry_gui.cpp
Show inline comments
 
@@ -392,13 +392,13 @@ static const WindowDesc _build_industry_
 
	BuildDynamicIndustryWndProc,
 
};
 

	
 
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);
 

	
 
static inline bool IsProductionMinimum(const Industry *i, int pt)
 
{
 
@@ -633,13 +633,13 @@ static const WindowDesc _industry_view_d
 
	_industry_view_widgets,
 
	IndustryViewWndProc
 
};
 

	
 
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;
 
		WP(w, indview_d).editbox_line = 0;
 
		WP(w, indview_d).clicked_line = 0;
 
		WP(w, indview_d).clicked_button = 0;
 
@@ -899,13 +899,13 @@ static const WindowDesc _industry_direct
 
	_industry_directory_widgets,
 
	IndustryDirectoryWndProc
 
};
 

	
 
void ShowIndustryDirectory()
 
{
 
	Window *w = AllocateWindowDescFront(&_industry_directory_desc, 0);
 
	Window *w = AllocateWindowDescFront<Window>(&_industry_directory_desc, 0);
 

	
 
	if (w != NULL) {
 
		w->vscroll.cap = 16;
 
		w->resize.height = w->height - 6 * 10; // minimum 10 items
 
		w->resize.step_height = 10;
 
		w->SetDirty();
src/misc_gui.cpp
Show inline comments
 
@@ -479,18 +479,18 @@ static const WindowDesc _build_trees_sce
 
};
 

	
 

	
 
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];
 
static StringID _errmsg_message_1, _errmsg_message_2;
 
static uint _errmsg_duration;
 

	
src/music_gui.cpp
Show inline comments
 
@@ -331,13 +331,13 @@ static const WindowDesc _music_track_sel
 
	_music_track_selection_widgets,
 
	MusicTrackSelectionWndProc
 
};
 

	
 
static void ShowMusicTrackSelection()
 
{
 
	AllocateWindowDescFront(&_music_track_selection_desc, 0);
 
	AllocateWindowDescFront<Window>(&_music_track_selection_desc, 0);
 
}
 

	
 
static void MusicWindowWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
	case WE_PAINT: {
 
@@ -499,8 +499,8 @@ static const WindowDesc _music_window_de
 
	_music_window_widgets,
 
	MusicWindowWndProc
 
};
 

	
 
void ShowMusicWindow()
 
{
 
	AllocateWindowDescFront(&_music_window_desc, 0);
 
	AllocateWindowDescFront<Window>(&_music_window_desc, 0);
 
}
src/network/network_gui.cpp
Show inline comments
 
@@ -1614,13 +1614,13 @@ static void ClientListWndProc(Window *w,
 
			break;
 
	}
 
}
 

	
 
void ShowClientList()
 
{
 
	AllocateWindowDescFront(&_client_list_desc, 0);
 
	AllocateWindowDescFront<Window>(&_client_list_desc, 0);
 
}
 

	
 

	
 
static NetworkPasswordType pw_type;
 

	
 

	
src/order_gui.cpp
Show inline comments
 
@@ -1182,15 +1182,15 @@ void ShowOrdersWindow(const Vehicle *v)
 
	VehicleID veh = v->index;
 

	
 
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 
	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) {
 
		w->caption_color = v->owner;
 
		w->vscroll.cap = 6;
 
		w->resize.step_height = 10;
src/player_gui.cpp
Show inline comments
 
@@ -244,13 +244,13 @@ static const WindowDesc _player_finances
 
 * @pre is player a valid player
 
 */
 
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied, int top, int left)
 
{
 
	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;
 

	
 
		if (show_stickied) w->flags4 |= WF_STICKY;
 

	
 
@@ -1015,13 +1015,13 @@ static const WindowDesc _select_player_f
 
 * @pre is player a valid player
 
 */
 
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;
 
		WP(w, facesel_d).face = GetPlayer((PlayerID)w->window_number)->face;
 
		WP(w, facesel_d).advanced = adv;
 

	
 
@@ -1232,13 +1232,13 @@ static void PlayerCompanyWndProc(Window 
 

	
 
		case WE_CLICK:
 
			switch (e->we.click.widget) {
 
				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;
 
						WP(wf, livery_d).sel = 1;
 
						wf->LowerWidget(2);
 
					}
 
@@ -1352,13 +1352,13 @@ static const WindowDesc _player_company_
 
void ShowPlayerCompany(PlayerID player)
 
{
 
	Window *w;
 

	
 
	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;
 
}
 

	
 

	
 

	
 
static void BuyCompanyWndProc(Window *w, WindowEvent *e)
 
@@ -1408,13 +1408,13 @@ static const WindowDesc _buy_company_des
 
	BuyCompanyWndProc
 
};
 

	
 

	
 
void ShowBuyCompanyDialog(uint player)
 
{
 
	AllocateWindowDescFront(&_buy_company_desc, player);
 
	AllocateWindowDescFront<Window>(&_buy_company_desc, player);
 
}
 

	
 
/********** HIGHSCORE and ENDGAME windows */
 

	
 
/* Always draw a maximized window and within there the centered background */
 
static void SetupHighScoreEndWindow(Window *w, uint *x, uint *y)
src/rail_gui.cpp
Show inline comments
 
@@ -749,13 +749,13 @@ void ShowBuildRailToolbar(RailType railt
 
	if (!ValParamRailtype(railtype)) return;
 

	
 
	// don't recreate the window if we're clicking on a button and the window exists.
 
	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);
 
	}
 

	
 
	_remove_button_clicked = false;
 
	if (w != NULL && button >= RTW_CLOSEBOX) {
 
		_build_railroad_button_proc[button](w);
src/road_gui.cpp
Show inline comments
 
@@ -676,13 +676,13 @@ static const WindowDesc _build_tramway_d
 
void ShowBuildRoadToolbar(RoadType roadtype)
 
{
 
	if (!IsValidPlayer(_current_player)) return;
 
	_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);
 
}
 

	
 
/** Widget definition of the build road toolbar in the scenario editor */
 
static const Widget _build_road_scen_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},            // RTW_CLOSEBOX
 
@@ -711,13 +711,13 @@ static const WindowDesc _build_road_scen
 
	BuildRoadToolbWndProc
 
};
 

	
 
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 */
 
enum BuildRoadDepotWidgets {
 
	BRDW_CLOSEBOX = 0,
 
	BRDW_CAPTION,
src/signs_gui.cpp
Show inline comments
 
@@ -132,13 +132,13 @@ static const WindowDesc _sign_list_desc 
 
	SignListWndProc
 
};
 

	
 

	
 
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;
 
		w->resize.height = w->height - 10 * 7; // minimum if 5 in the list
 
	}
 
}
src/smallmap_gui.cpp
Show inline comments
 
@@ -1052,13 +1052,13 @@ static const WindowDesc _smallmap_desc =
 
};
 

	
 
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 */
 
	if (_industries_per_column > BASE_NB_PER_COLUMN) {
 
		uint diff = ((_industries_per_column - BASE_NB_PER_COLUMN) * BASE_NB_PER_COLUMN) + 1;
 

	
 
@@ -1196,13 +1196,13 @@ void ShowExtraViewPortWindow(TileIndex t
 
{
 
	int i = 0;
 

	
 
	/* 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;
 

	
 
		if (tile == INVALID_TILE) {
 
			/* the main window with the main view */
 
			const Window *v = FindWindowById(WC_MAIN_WINDOW, 0);
src/station_gui.cpp
Show inline comments
 
@@ -617,13 +617,13 @@ static const WindowDesc _player_stations
 
 * @param player player whose stations' list show
 
 */
 
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;
 
	w->vscroll.cap = 12;
 
	w->resize.step_height = 10;
 
	w->resize.height = w->height - 10 * 7; // minimum if 5 in the list
 
@@ -1040,13 +1040,13 @@ static const WindowDesc _station_view_de
 
 * Opens StationViewWindow for given station
 
 *
 
 * @param station station which window should be opened
 
 */
 
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;
 
	if (owner != OWNER_NONE) w->caption_color = owner;
 
	w->vscroll.cap = 5;
 
	w->resize.step_height = 10;
src/subsidy_gui.cpp
Show inline comments
 
@@ -194,8 +194,8 @@ static const WindowDesc _subsidies_list_
 
	SubsidiesListWndProc
 
};
 

	
 

	
 
void ShowSubsidiesList()
 
{
 
	AllocateWindowDescFront(&_subsidies_list_desc, 0);
 
	AllocateWindowDescFront<Window>(&_subsidies_list_desc, 0);
 
}
src/terraform_gui.cpp
Show inline comments
 
@@ -301,13 +301,13 @@ static const WindowDesc _terraform_desc 
 
	TerraformToolbWndProc
 
};
 

	
 
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
 
		 */
 
		w->top = 22;
 
		link->left = w->left - link->width;
 
@@ -676,8 +676,8 @@ static const WindowDesc _scen_edit_land_
 
	_scen_edit_land_gen_widgets,
 
	ScenEditLandGenWndProc,
 
};
 

	
 
void ShowEditorTerraformToolbar()
 
{
 
	AllocateWindowDescFront(&_scen_edit_land_gen_desc, 0);
 
	AllocateWindowDescFront<Window>(&_scen_edit_land_gen_desc, 0);
 
}
src/timetable_gui.cpp
Show inline comments
 
@@ -298,13 +298,13 @@ static const WindowDesc _timetable_desc 
 
	_timetable_widgets,
 
	TimetableWndProc
 
};
 

	
 
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;
 
		w->vscroll.cap = 8;
 
		w->resize.step_height = 10;
 
		WP(w, timetable_d).sel = -1;
src/town_gui.cpp
Show inline comments
 
@@ -265,13 +265,13 @@ static const WindowDesc _town_authority_
 
	_town_authority_widgets,
 
	TownAuthorityWndProc
 
};
 

	
 
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;
 
		WP(w, def_d).data_1 = -1;
 
	}
 
}
 
@@ -394,13 +394,13 @@ static const WindowDesc _town_view_desc 
 
};
 

	
 
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;
 
		InitializeWindowViewport(w, 3, 17, 254, 86, GetTown(town)->xy, ZOOM_LVL_TOWN);
 
	}
 
}
 
@@ -573,13 +573,13 @@ static const WindowDesc _town_directory_
 
	TownDirectoryWndProc
 
};
 

	
 

	
 
void ShowTownDirectory()
 
{
 
	Window *w = AllocateWindowDescFront(&_town_directory_desc, 0);
 
	Window *w = AllocateWindowDescFront<Window>(&_town_directory_desc, 0);
 

	
 
	if (w != NULL) {
 
		w->vscroll.cap = 16;
 
		w->resize.step_height = 10;
 
		w->resize.height = w->height - 10 * 6; // minimum of 10 items in the list, each item 10 high
 
	}
 
@@ -702,9 +702,9 @@ static const WindowDesc _scen_edit_town_
 
	ScenEditTownGenWndProc,
 
};
 

	
 
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);
 
}
 

	
src/transparency_gui.cpp
Show inline comments
 
@@ -123,8 +123,8 @@ static const WindowDesc _transparency_de
 
	_transparency_widgets,
 
	TransparencyToolbWndProc
 
};
 

	
 
void ShowTransparencyToolbar(void)
 
{
 
	AllocateWindowDescFront(&_transparency_desc, 0);
 
	AllocateWindowDescFront<Window>(&_transparency_desc, 0);
 
}
src/vehicle_gui.cpp
Show inline comments
 
@@ -448,13 +448,13 @@ static const WindowDesc _vehicle_refit_d
 
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order)
 
{
 
	Window *w;
 

	
 
	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) {
 
		w->caption_color = v->owner;
 
		w->vscroll.cap = 8;
 
		w->resize.step_height = 14;
 
@@ -1241,24 +1241,24 @@ static void ShowVehicleListWindowLocal(P
 
	/* The vehicle list windows have been unified. Just some strings need
 
	 * to be changed which happens in the WE_CREATE event and resizing
 
	 * some of the windows to the correct size */
 
	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;
 
	}
 

	
 
	if (w != NULL) {
 
		/* Set the minimum window size to the current window size */
 
		w->resize.width = w->width;
 
@@ -1668,13 +1668,13 @@ static const WindowDesc _vehicle_details
 

	
 
/** Shows the vehicle details window of the given vehicle. */
 
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);
 
}
 

	
 

	
 
/* Unified vehicle GUI - Vehicle View Window */
 

	
 
/** Vehicle view widgets. */
 
@@ -1744,13 +1744,13 @@ static const int VV_INITIAL_VIEWPORT_WID
 
static const int VV_INITIAL_VIEWPORT_HEIGHT = 84;
 
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;
 
		InitializeWindowViewport(w, VV_VIEWPORT_X, VV_VIEWPORT_Y, VV_INITIAL_VIEWPORT_WIDTH,
 
												 (v->type == VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT,
 
												 w->window_number | (1 << 31), _vehicle_view_zoom_levels[v->type]);
src/window.cpp
Show inline comments
 
@@ -1009,25 +1009,12 @@ Window::Window(const WindowDesc *desc, v
 
{
 
	Point pt = LocalGetWindowPlacement(desc, window_number);
 
	this->Initialize(pt.x, pt.y, desc->minimum_width, desc->minimum_height, desc->default_width, desc->default_height, desc->proc, desc->cls, desc->widgets, window_number, data);
 
	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
 
 * @param y position y to query
 
 * @return a pointer to the found window if any, NULL otherwise */
 
Window *FindWindowFromPt(int x, int y)
src/window_gui.h
Show inline comments
 
@@ -558,13 +558,25 @@ void CallWindowTickEvent();
 
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number);
 
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);
 

	
 
int GetMenuItemIndex(const Window *w, int x, int y);
 
void RelocateAllWindows(int neww, int newh);
 

	
0 comments (0 inline, 0 general)