mirror of https://github.com/OpenTTD/OpenTTD
Change: Set DepotID related window numbers to WC_BUILD_VEHICLE windows.
parent
d643e77800
commit
742f1de7b4
|
@ -38,6 +38,7 @@
|
|||
#include "querystring_gui.h"
|
||||
#include "stringfilter_type.h"
|
||||
#include "hotkeys.h"
|
||||
#include "depot_base.h"
|
||||
|
||||
#include "widgets/build_vehicle_widget.h"
|
||||
|
||||
|
@ -1201,11 +1202,12 @@ struct BuildVehicleWindow : Window {
|
|||
}
|
||||
}
|
||||
|
||||
BuildVehicleWindow(WindowDesc &desc, TileIndex tile, VehicleType type) : Window(desc), vehicle_editbox(MAX_LENGTH_VEHICLE_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_VEHICLE_NAME_CHARS)
|
||||
BuildVehicleWindow(WindowDesc &desc, DepotID depot_id, VehicleType type) : Window(desc), vehicle_editbox(MAX_LENGTH_VEHICLE_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_VEHICLE_NAME_CHARS)
|
||||
{
|
||||
this->vehicle_type = type;
|
||||
this->listview_mode = tile == INVALID_TILE;
|
||||
this->window_number = this->listview_mode ? (int)type : tile.base();
|
||||
this->listview_mode = (depot_id == INVALID_DEPOT);
|
||||
if (this->listview_mode) depot_id -= type;
|
||||
this->window_number = depot_id;
|
||||
|
||||
this->sel_engine = INVALID_ENGINE;
|
||||
|
||||
|
@ -1240,16 +1242,13 @@ struct BuildVehicleWindow : Window {
|
|||
|
||||
this->details_height = ((this->vehicle_type == VEH_TRAIN) ? 10 : 9);
|
||||
|
||||
if (tile == INVALID_TILE) {
|
||||
this->FinishInitNested(type);
|
||||
} else {
|
||||
this->FinishInitNested(tile);
|
||||
}
|
||||
this->FinishInitNested(depot_id);
|
||||
|
||||
this->querystrings[WID_BV_FILTER] = &this->vehicle_editbox;
|
||||
this->vehicle_editbox.cancel_button = QueryString::ACTION_CLEAR;
|
||||
|
||||
this->owner = (tile != INVALID_TILE) ? GetTileOwner(tile) : _local_company;
|
||||
Depot *depot = Depot::GetIfValid(depot_id);
|
||||
this->owner = (depot != nullptr) ? GetTileOwner(depot->xy) : _local_company;
|
||||
|
||||
this->eng_list.ForceRebuild();
|
||||
this->GenerateBuildList(); // generate the list, since we need it in the next line
|
||||
|
@ -1264,13 +1263,16 @@ struct BuildVehicleWindow : Window {
|
|||
/** Set the filter type according to the depot type */
|
||||
void UpdateFilterByTile()
|
||||
{
|
||||
TileIndex tile = INVALID_TILE;
|
||||
if (!this->listview_mode) tile = Depot::Get(this->window_number)->xy;
|
||||
|
||||
switch (this->vehicle_type) {
|
||||
default: NOT_REACHED();
|
||||
case VEH_TRAIN:
|
||||
if (this->listview_mode) {
|
||||
this->filter.railtype = INVALID_RAILTYPE;
|
||||
} else {
|
||||
this->filter.railtype = GetRailType(this->window_number);
|
||||
this->filter.railtype = GetRailType(tile);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1278,9 +1280,9 @@ struct BuildVehicleWindow : Window {
|
|||
if (this->listview_mode) {
|
||||
this->filter.roadtype = INVALID_ROADTYPE;
|
||||
} else {
|
||||
this->filter.roadtype = GetRoadTypeRoad(this->window_number);
|
||||
this->filter.roadtype = GetRoadTypeRoad(tile);
|
||||
if (this->filter.roadtype == INVALID_ROADTYPE) {
|
||||
this->filter.roadtype = GetRoadTypeTram(this->window_number);
|
||||
this->filter.roadtype = GetRoadTypeTram(tile);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1326,7 +1328,7 @@ struct BuildVehicleWindow : Window {
|
|||
|
||||
if (!this->listview_mode) {
|
||||
/* Query for cost and refitted capacity */
|
||||
auto [ret, veh_id, refit_capacity, refit_mail, cargo_capacities] = Command<CMD_BUILD_VEHICLE>::Do(DC_QUERY_COST, this->window_number, this->sel_engine, true, cargo, INVALID_CLIENT_ID);
|
||||
auto [ret, veh_id, refit_capacity, refit_mail, cargo_capacities] = Command<CMD_BUILD_VEHICLE>::Do(DC_QUERY_COST, Depot::Get(this->window_number)->xy, this->sel_engine, true, cargo, INVALID_CLIENT_ID);
|
||||
if (ret.Succeeded()) {
|
||||
this->te.cost = ret.GetCost() - e->GetCost();
|
||||
this->te.capacity = refit_capacity;
|
||||
|
@ -1613,10 +1615,15 @@ struct BuildVehicleWindow : Window {
|
|||
|
||||
CargoID cargo = this->cargo_filter_criteria;
|
||||
if (cargo == CargoFilterCriteria::CF_ANY || cargo == CargoFilterCriteria::CF_ENGINES || cargo == CargoFilterCriteria::CF_NONE) cargo = INVALID_CARGO;
|
||||
|
||||
assert(Depot::IsValidID(this->window_number));
|
||||
Depot *depot = Depot::Get(this->window_number);
|
||||
assert(depot->xy != INVALID_TILE);
|
||||
|
||||
if (this->vehicle_type == VEH_TRAIN && RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) {
|
||||
Command<CMD_BUILD_VEHICLE>::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildWagon, this->window_number, sel_eng, true, cargo, INVALID_CLIENT_ID);
|
||||
Command<CMD_BUILD_VEHICLE>::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildWagon, depot->xy, sel_eng, true, cargo, INVALID_CLIENT_ID);
|
||||
} else {
|
||||
Command<CMD_BUILD_VEHICLE>::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildPrimaryVehicle, this->window_number, sel_eng, true, cargo, INVALID_CLIENT_ID);
|
||||
Command<CMD_BUILD_VEHICLE>::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildPrimaryVehicle, depot->xy, sel_eng, true, cargo, INVALID_CLIENT_ID);
|
||||
}
|
||||
|
||||
/* Update last used variant in hierarchy and refresh if necessary. */
|
||||
|
@ -1930,17 +1937,12 @@ static WindowDesc _build_vehicle_desc(
|
|||
&BuildVehicleWindow::hotkeys
|
||||
);
|
||||
|
||||
void ShowBuildVehicleWindow(TileIndex tile, VehicleType type)
|
||||
void ShowBuildVehicleWindow(DepotID depot_id, VehicleType type)
|
||||
{
|
||||
/* We want to be able to open both Available Train as Available Ships,
|
||||
* so if tile == INVALID_TILE (Available XXX Window), use 'type' as unique number.
|
||||
* As it always is a low value, it won't collide with any real tile
|
||||
* number. */
|
||||
uint num = (tile == INVALID_TILE) ? (int)type : tile.base();
|
||||
|
||||
assert(IsCompanyBuildableVehicleType(type));
|
||||
assert(depot_id == INVALID_DEPOT || Depot::IsValidID(depot_id));
|
||||
|
||||
CloseWindowById(WC_BUILD_VEHICLE, num);
|
||||
CloseWindowById(WC_BUILD_VEHICLE, depot_id != INVALID_DEPOT ? depot_id : (INVALID_DEPOT - type));
|
||||
|
||||
new BuildVehicleWindow(_build_vehicle_desc, tile, type);
|
||||
new BuildVehicleWindow(_build_vehicle_desc, depot_id, type);
|
||||
}
|
||||
|
|
|
@ -769,7 +769,7 @@ struct DepotWindow : Window {
|
|||
|
||||
case WID_D_BUILD: // Build vehicle
|
||||
ResetObjectToPlace();
|
||||
ShowBuildVehicleWindow(Depot::Get(this->window_number)->xy, this->type);
|
||||
ShowBuildVehicleWindow(this->window_number, this->type);
|
||||
break;
|
||||
|
||||
case WID_D_CLONE: // Clone button
|
||||
|
@ -824,7 +824,7 @@ struct DepotWindow : Window {
|
|||
break;
|
||||
|
||||
case WID_D_VEHICLE_LIST:
|
||||
ShowVehicleListWindow(this->owner, this->type, Depot::Get(this->window_number)->xy);
|
||||
ShowVehicleListWindow(this->owner, this->type, this->window_number);
|
||||
break;
|
||||
|
||||
case WID_D_AUTOREPLACE:
|
||||
|
|
|
@ -842,7 +842,7 @@ public:
|
|||
break;
|
||||
|
||||
case WID_GL_AVAILABLE_VEHICLES:
|
||||
ShowBuildVehicleWindow(INVALID_TILE, this->vli.vtype);
|
||||
ShowBuildVehicleWindow(INVALID_DEPOT, this->vli.vtype);
|
||||
break;
|
||||
|
||||
case WID_GL_MANAGE_VEHICLES_DROPDOWN: {
|
||||
|
|
|
@ -2123,7 +2123,7 @@ public:
|
|||
}
|
||||
|
||||
case WID_VL_AVAILABLE_VEHICLES:
|
||||
ShowBuildVehicleWindow(INVALID_TILE, this->vli.vtype);
|
||||
ShowBuildVehicleWindow(INVALID_DEPOT, this->vli.vtype);
|
||||
break;
|
||||
|
||||
case WID_VL_MANAGE_VEHICLES_DROPDOWN: {
|
||||
|
@ -2268,16 +2268,9 @@ void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationI
|
|||
ShowVehicleListWindowLocal(company, VL_STATION_LIST, vehicle_type, station);
|
||||
}
|
||||
|
||||
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile)
|
||||
void ShowVehicleListWindowDepot(CompanyID company, VehicleType vehicle_type, DepotID depot_id)
|
||||
{
|
||||
uint16_t depot_airport_index;
|
||||
|
||||
if (vehicle_type == VEH_AIRCRAFT) {
|
||||
depot_airport_index = GetStationIndex(depot_tile);
|
||||
} else {
|
||||
depot_airport_index = GetDepotIndex(depot_tile);
|
||||
}
|
||||
ShowVehicleListWindowLocal(company, VL_DEPOT_LIST, vehicle_type, depot_airport_index);
|
||||
ShowVehicleListWindowLocal(company, VL_DEPOT_LIST, vehicle_type, depot_id);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "station_type.h"
|
||||
#include "engine_type.h"
|
||||
#include "company_type.h"
|
||||
#include "depot_type.h"
|
||||
|
||||
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit = false);
|
||||
|
||||
|
@ -56,7 +57,7 @@ void DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, Engi
|
|||
void DrawShipImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type);
|
||||
void DrawAircraftImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type);
|
||||
|
||||
void ShowBuildVehicleWindow(TileIndex tile, VehicleType type);
|
||||
void ShowBuildVehicleWindow(DepotID depot_id, VehicleType type);
|
||||
|
||||
uint ShowRefitOptionsList(int left, int right, int y, EngineID engine);
|
||||
StringID GetCargoSubtypeText(const Vehicle *v);
|
||||
|
@ -64,7 +65,7 @@ StringID GetCargoSubtypeText(const Vehicle *v);
|
|||
void ShowVehicleListWindow(const Vehicle *v);
|
||||
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type);
|
||||
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station);
|
||||
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile);
|
||||
void ShowVehicleListWindowDepot(CompanyID company, VehicleType vehicle_type, DepotID depot_id);
|
||||
|
||||
/**
|
||||
* Get the height of a single vehicle in the GUIs.
|
||||
|
|
|
@ -383,8 +383,8 @@ enum WindowClass {
|
|||
|
||||
/**
|
||||
* Build vehicle; %Window numbers:
|
||||
* - #VehicleType = #BuildVehicleWidgets
|
||||
* - #TileIndex = #BuildVehicleWidgets
|
||||
* - #INVALID_DEPOT - VehicleType = #BuildVehicleWidgets
|
||||
* - #DepotID = #BuildVehicleWidgets
|
||||
*/
|
||||
WC_BUILD_VEHICLE,
|
||||
|
||||
|
|
Loading…
Reference in New Issue