diff options
author | bjarni <bjarni@openttd.org> | 2007-01-21 00:01:47 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2007-01-21 00:01:47 +0000 |
commit | 44494a8e93b9f28e8b609ac78d802c843a6329a6 (patch) | |
tree | 8c1a71e7972a3d2f2e3847db25fc4cf7a81aca7f | |
parent | 799fbda05acb77ed1b621ecdd4ffbfae9030b0b2 (diff) | |
download | openttd-44494a8e93b9f28e8b609ac78d802c843a6329a6.tar.xz |
(svn r8293) -Codechange: overloaded ShowVehicleListWindow() so it can open all types of vehicle lists (depending on arguments)
- Also removed some unneeded arguments
- this also allows removing an if-else cascade in ShowVehicleListWindowLocal()
-rw-r--r-- | src/depot_gui.cpp | 2 | ||||
-rw-r--r-- | src/main_gui.cpp | 16 | ||||
-rw-r--r-- | src/order_gui.cpp | 2 | ||||
-rw-r--r-- | src/station_gui.cpp | 8 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 32 | ||||
-rw-r--r-- | src/vehicle_gui.h | 7 |
6 files changed, 32 insertions, 35 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 00e5d9d96..1bcc9babd 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -793,7 +793,7 @@ static void DepotWndProc(Window *w, WindowEvent *e) break; case DEPOT_WIDGET_VEHICLE_LIST: - ShowVehDepotOrders(GetTileOwner(w->window_number), WP(w, depot_d).type, w->window_number); + ShowVehicleListWindow(GetTileOwner(w->window_number), WP(w, depot_d).type, (TileIndex)w->window_number); break; case DEPOT_WIDGET_AUTOREPLACE: diff --git a/src/main_gui.cpp b/src/main_gui.cpp index e88a306c5..38c269c0d 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -263,22 +263,22 @@ static void MenuClickIndustry(int index) static void MenuClickShowTrains(int index) { - ShowVehicleListWindow((PlayerID)index, INVALID_STATION, VEH_Train); + ShowVehicleListWindow((PlayerID)index, VEH_Train); } static void MenuClickShowRoad(int index) { - ShowVehicleListWindow((PlayerID)index, INVALID_STATION, VEH_Road); + ShowVehicleListWindow((PlayerID)index, VEH_Road); } static void MenuClickShowShips(int index) { - ShowVehicleListWindow((PlayerID)index, INVALID_STATION, VEH_Ship); + ShowVehicleListWindow((PlayerID)index, VEH_Ship); } static void MenuClickShowAir(int index) { - ShowVehicleListWindow((PlayerID)index, INVALID_STATION, VEH_Aircraft); + ShowVehicleListWindow((PlayerID)index, VEH_Aircraft); } static void MenuClickBuildRail(int index) @@ -1802,10 +1802,10 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e) case WKC_F10:ShowOperatingProfitGraph(); break; case WKC_F11: ShowCompanyLeagueTable(); break; case WKC_F12: ShowBuildIndustryWindow(); break; - case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(_local_player, INVALID_STATION, VEH_Train); break; - case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(_local_player, INVALID_STATION, VEH_Road); break; - case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(_local_player, INVALID_STATION, VEH_Ship); break; - case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(_local_player, INVALID_STATION, VEH_Aircraft); break; + case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(_local_player, VEH_Train); break; + case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(_local_player, VEH_Road); break; + case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(_local_player, VEH_Ship); break; + case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(_local_player, VEH_Aircraft); break; case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break; case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break; case WKC_SHIFT | WKC_F7: ShowBuildRailToolbar(_last_built_railtype, -1); break; diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 038309924..527b87ae3 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -482,7 +482,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e) OrderClick_Transfer(w, v); break; case 11: /* Vehicle with same shared Orders button */ - ShowVehWithSharedOrders(v, v->type); + ShowVehicleListWindow(v); break; case 12: OrderClick_Refit(w, v); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index b11a44090..fee50bba6 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -762,13 +762,13 @@ static void StationViewWndProc(Window *w, WindowEvent *e) case 10: { /* Show a list of scheduled trains to this station */ const Station *st = GetStation(w->window_number); - ShowVehicleListWindow(st->owner, w->window_number, VEH_Train); + ShowVehicleListWindow(st->owner, VEH_Train, (StationID)w->window_number); break; } case 11: { /* Show a list of scheduled road-vehicles to this station */ const Station *st = GetStation(w->window_number); - ShowVehicleListWindow(st->owner, w->window_number, VEH_Road); + ShowVehicleListWindow(st->owner, VEH_Road, (StationID)w->window_number); break; } @@ -776,7 +776,7 @@ static void StationViewWndProc(Window *w, WindowEvent *e) const Station *st = GetStation(w->window_number); /* Since oilrigs have no owners, show the scheduled aircraft of current player */ PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner; - ShowVehicleListWindow(owner, w->window_number, VEH_Aircraft); + ShowVehicleListWindow(owner, VEH_Aircraft, (StationID)w->window_number); break; } @@ -784,7 +784,7 @@ static void StationViewWndProc(Window *w, WindowEvent *e) const Station *st = GetStation(w->window_number); /* Since oilrigs/bouys have no owners, show the scheduled ships of current player */ PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner; - ShowVehicleListWindow(owner, w->window_number, VEH_Ship); + ShowVehicleListWindow(owner, VEH_Ship, (StationID)w->window_number); break; } } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 37b234fe5..edc430d53 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1874,29 +1874,19 @@ static const WindowDesc _player_vehicle_list_aircraft_desc = { PlayerVehWndProc }; -static void ShowVehicleListWindowLocal(PlayerID player, byte vehicle_type, StationID station, OrderID order, uint16 depot_airport_index) +static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, byte vehicle_type, uint16 unique_number) { Window *w; WindowNumber num; if (!IsValidPlayer(player)) return; - num = (vehicle_type << 11) | player; - if (order != INVALID_ORDER) { - num |= (order << 16) | VLW_SHARED_ORDERS; - } else if (depot_airport_index != INVALID_STATION) { - num |= (depot_airport_index << 16) | VLW_DEPOT_LIST; - } else if (station == INVALID_STATION) { - num |= VLW_STANDARD; - } else { - num |= (station << 16) | VLW_STATION_LIST; - } + num = (unique_number << 16) | (vehicle_type << 11) | VLW_flag | player; /* 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); if (w != NULL) ResizeWindow(w, 65, 38); @@ -1911,6 +1901,7 @@ static void ShowVehicleListWindowLocal(PlayerID player, byte vehicle_type, Stati case VEH_Aircraft: w = AllocateWindowDescFront(&_player_vehicle_list_aircraft_desc, num); break; + default: NOT_REACHED(); return; } if (w != NULL) { @@ -1920,18 +1911,23 @@ static void ShowVehicleListWindowLocal(PlayerID player, byte vehicle_type, Stati } } -void ShowVehicleListWindow(PlayerID player, StationID station, byte vehicle_type) +void ShowVehicleListWindow(PlayerID player, byte vehicle_type) { - ShowVehicleListWindowLocal(player, vehicle_type, station, INVALID_ORDER, INVALID_STATION); + ShowVehicleListWindowLocal(player, VLW_STANDARD, vehicle_type, 0); } -void ShowVehWithSharedOrders(Vehicle *v, byte vehicle_type) +void ShowVehicleListWindow(const Vehicle *v) { if (v->orders == NULL) return; // no shared list to show - ShowVehicleListWindowLocal(v->owner, vehicle_type, INVALID_STATION, v->orders->index, INVALID_STATION); + ShowVehicleListWindowLocal(v->owner, VLW_SHARED_ORDERS, v->type, v->orders->index); +} + +void ShowVehicleListWindow(PlayerID player, byte vehicle_type, StationID station) +{ + ShowVehicleListWindowLocal(player, VLW_STATION_LIST, vehicle_type, station); } -void ShowVehDepotOrders(PlayerID player, byte vehicle_type, TileIndex depot_tile) +void ShowVehicleListWindow(PlayerID player, byte vehicle_type, TileIndex depot_tile) { uint16 depot_airport_index; @@ -1942,5 +1938,5 @@ void ShowVehDepotOrders(PlayerID player, byte vehicle_type, TileIndex depot_tile if (depot == NULL) return; // no depot to show depot_airport_index = depot->index; } - ShowVehicleListWindowLocal(player, vehicle_type, INVALID_STATION, INVALID_ORDER, depot_airport_index); + ShowVehicleListWindowLocal(player, VLW_DEPOT_LIST, vehicle_type, depot_airport_index); } diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index 76f6a5bcc..a3d20e4f7 100644 --- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -53,9 +53,10 @@ void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v); uint ShowAdditionalText(int x, int y, uint w, EngineID engine); uint ShowRefitOptionsList(int x, int y, uint w, EngineID engine); -void ShowVehicleListWindow(PlayerID player, StationID station, byte vehicle_type); -void ShowVehWithSharedOrders(Vehicle *v, byte vehicle_type); -void ShowVehDepotOrders(PlayerID player, byte vehicle_type, TileIndex depot_tile); +void ShowVehicleListWindow(const Vehicle *v); +void ShowVehicleListWindow(PlayerID player, byte vehicle_type); +void ShowVehicleListWindow(PlayerID player, byte vehicle_type, StationID station); +void ShowVehicleListWindow(PlayerID player, byte vehicle_type, TileIndex depot_tile); static inline void DrawVehicleImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection) |