mirror of https://github.com/OpenTTD/OpenTTD
(svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
parent
2eef026fe3
commit
23fc96c3e8
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1617,7 +1617,7 @@ static void ClientListWndProc(Window *w, WindowEvent *e)
|
|||
|
||||
void ShowClientList()
|
||||
{
|
||||
AllocateWindowDescFront(&_client_list_desc, 0);
|
||||
AllocateWindowDescFront<Window>(&_client_list_desc, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -197,5 +197,5 @@ static const WindowDesc _subsidies_list_desc = {
|
|||
|
||||
void ShowSubsidiesList()
|
||||
{
|
||||
AllocateWindowDescFront(&_subsidies_list_desc, 0);
|
||||
AllocateWindowDescFront<Window>(&_subsidies_list_desc, 0);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -126,5 +126,5 @@ static const WindowDesc _transparency_desc = {
|
|||
|
||||
void ShowTransparencyToolbar(void)
|
||||
{
|
||||
AllocateWindowDescFront(&_transparency_desc, 0);
|
||||
AllocateWindowDescFront<Window>(&_transparency_desc, 0);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue