(svn r6562) -Codechange: merged the vehicle list window widget arrays

It made no sense to maintain 8 nearly identically arrays when a single one can do the job
  Also made the two buttons always use half of the bottom width each, even when resizing
This commit is contained in:
bjarni 2006-09-28 23:05:03 +00:00
parent 1ae8aa4b80
commit 4ccdb0686f
13 changed files with 275 additions and 399 deletions

View File

@ -602,79 +602,3 @@ void DrawSmallOrderListAircraft(const Vehicle *v, int x, int y)
} }
} }
} }
static const Widget _player_aircraft_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_A009_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS },
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON },
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP },
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP },
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP },
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL },
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT },
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST },
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 170, 181, STR_SEND_TO_HANGARS, STR_SEND_TO_HANGARS_TIP },
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 125, 247, 170, 181, STR_REPLACE_VEHICLES, STR_REPLACE_HELP },
{ WWT_PANEL, RESIZE_RTB, 14, 248, 247, 170, 181, 0x0, STR_NULL },
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON },
{ WIDGETS_END},
};
static const Widget _other_player_aircraft_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_A009_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS },
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON },
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP },
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP },
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP },
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL },
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT },
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST },
{ WWT_PANEL, RESIZE_RTB, 14, 0, 247, 170, 181, 0x0, STR_NULL },
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON },
{ WIDGETS_END},
};
static const WindowDesc _player_aircraft_desc = {
-1, -1, 260, 182,
WC_AIRCRAFT_LIST,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
_player_aircraft_widgets,
PlayerVehWndProc
};
static const WindowDesc _other_player_aircraft_desc = {
-1, -1, 260, 182,
WC_AIRCRAFT_LIST,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
_other_player_aircraft_widgets,
PlayerVehWndProc
};
void ShowPlayerAircraftLocal(PlayerID player, StationID station, OrderID order, bool show_shared)
{
Window *w;
if (show_shared) {
w = AllocateWindowDescFront(&_player_aircraft_desc, (order << 16) | (VEH_Aircraft << 11) | VLW_SHARED_ORDERS | player);
} else {
uint16 VLW_flag = (station == INVALID_STATION) ? VLW_STANDARD : VLW_STATION_LIST;
if (player == _local_player) {
w = AllocateWindowDescFront(&_player_aircraft_desc, (station << 16) | (VEH_Aircraft << 11) | VLW_flag | player);
} else {
w = AllocateWindowDescFront(&_other_player_aircraft_desc, (station << 16) | (VEH_Aircraft << 11) | VLW_flag | player);
}
}
}
void ShowPlayerAircraft(PlayerID player, StationID station)
{
ShowPlayerAircraftLocal(player, station, INVALID_ORDER, false);
}
void ShowVehWithSharedOrdersAircraft(Vehicle *v)
{
if (v->orders == NULL) return; // no shared list to show
ShowPlayerAircraftLocal(v->owner, INVALID_STATION, v->orders->index, true);
}

View File

@ -18,23 +18,7 @@
#include "vehicle_gui.h" #include "vehicle_gui.h"
#include "station_map.h" #include "station_map.h"
#include "newgrf_engine.h" #include "newgrf_engine.h"
#include "resize_window_widgets.h"
enum {
WIDGET_DEPOT_MOVE_NONE = 0 << 0,
WIDGET_DEPOT_MOVE_RIGHT = 1 << 0,
WIDGET_DEPOT_MOVE_LEFT = 1 << 1,
WIDGET_DEPOT_MOVE_TOP = 1 << 2,
WIDGET_DEPOT_MOVE_BOTTOM = 1 << 3,
DEPOT_MOVE_NONE = WIDGET_DEPOT_MOVE_NONE,
DEPOT_STRETCH_RIGHT = WIDGET_DEPOT_MOVE_RIGHT,
DEPOT_MOVE_RIGHT = WIDGET_DEPOT_MOVE_RIGHT | WIDGET_DEPOT_MOVE_LEFT,
DEPOT_STRETCH_DOWN = WIDGET_DEPOT_MOVE_BOTTOM,
DEPOT_MOVE_DOWN = WIDGET_DEPOT_MOVE_BOTTOM | WIDGET_DEPOT_MOVE_TOP,
DEPOT_STRETCH_DOWN_RIGHT = DEPOT_STRETCH_DOWN | DEPOT_STRETCH_RIGHT,
DEPOT_MOVE_DOWN_RIGHT = DEPOT_MOVE_RIGHT | DEPOT_MOVE_DOWN,
DEPOT_MOVE_RIGHT_STRETCH_DOWN = DEPOT_MOVE_RIGHT | DEPOT_STRETCH_DOWN,
};
/* /*
* Since all depot window sizes aren't the same, we need to modify sizes a little. * Since all depot window sizes aren't the same, we need to modify sizes a little.
@ -65,22 +49,22 @@ typedef enum DepotWindowWidgets {
/* Define how to move each widget. The order is important */ /* Define how to move each widget. The order is important */
static const byte widget_moves[] = { static const byte widget_moves[] = {
DEPOT_MOVE_NONE, // DEPOT_WIDGET_CLOSEBOX WIDGET_MOVE_NONE, // DEPOT_WIDGET_CLOSEBOX
DEPOT_STRETCH_RIGHT, // DEPOT_WIDGET_CAPTION WIDGET_STRETCH_RIGHT, // DEPOT_WIDGET_CAPTION
DEPOT_MOVE_RIGHT, // DEPOT_WIDGET_STICKY WIDGET_MOVE_RIGHT, // DEPOT_WIDGET_STICKY
DEPOT_MOVE_RIGHT, // DEPOT_WIDGET_STOP_ALL WIDGET_MOVE_RIGHT, // DEPOT_WIDGET_STOP_ALL
DEPOT_MOVE_RIGHT, // DEPOT_WIDGET_START_ALL WIDGET_MOVE_RIGHT, // DEPOT_WIDGET_START_ALL
DEPOT_MOVE_RIGHT, // DEPOT_WIDGET_SELL WIDGET_MOVE_RIGHT, // DEPOT_WIDGET_SELL
DEPOT_MOVE_NONE, // DEPOT_WIDGET_SELL_CHAIN WIDGET_MOVE_NONE, // DEPOT_WIDGET_SELL_CHAIN
DEPOT_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_SELL_ALL WIDGET_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_SELL_ALL
DEPOT_STRETCH_DOWN_RIGHT, // DEPOT_WIDGET_MATRIX WIDGET_STRETCH_DOWN_RIGHT, // DEPOT_WIDGET_MATRIX
DEPOT_MOVE_RIGHT_STRETCH_DOWN, // DEPOT_WIDGET_V_SCROLL WIDGET_MOVE_RIGHT_STRETCH_DOWN, // DEPOT_WIDGET_V_SCROLL
DEPOT_MOVE_NONE, // DEPOT_WIDGET_H_SCROLL WIDGET_MOVE_NONE, // DEPOT_WIDGET_H_SCROLL
DEPOT_MOVE_DOWN, // DEPOT_WIDGET_BUILD WIDGET_MOVE_DOWN, // DEPOT_WIDGET_BUILD
DEPOT_MOVE_DOWN, // DEPOT_WIDGET_CLONE WIDGET_MOVE_DOWN, // DEPOT_WIDGET_CLONE
DEPOT_MOVE_DOWN, // DEPOT_WIDGET_LOCATION WIDGET_MOVE_DOWN, // DEPOT_WIDGET_LOCATION
DEPOT_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_AUTOREPLACE WIDGET_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_AUTOREPLACE
DEPOT_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_RESIZE WIDGET_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_RESIZE
}; };
/* Widget array for all depot windows. /* Widget array for all depot windows.
@ -906,18 +890,8 @@ void ShowDepotWindow(TileIndex tile, byte type)
SETBIT(w->hidden_state, DEPOT_WIDGET_SELL_CHAIN); SETBIT(w->hidden_state, DEPOT_WIDGET_SELL_CHAIN);
} }
/* Move the widgets to their right locations /* Move the widgets to their right locations */
* Note: it's signed values so negative will make the widget move left and not right, or up instead of down */ ResizeWindowWidgets(w, widget_moves, lengthof(widget_moves), horizontal, vertical);
{
byte i;
for (i = 0; i < lengthof(widget_moves); i++) {
if (widget_moves[i] & WIDGET_DEPOT_MOVE_LEFT) w->widget[i].left += horizontal;
if (widget_moves[i] & WIDGET_DEPOT_MOVE_RIGHT) w->widget[i].right += horizontal;
if (widget_moves[i] & WIDGET_DEPOT_MOVE_TOP) w->widget[i].top += vertical;
if (widget_moves[i] & WIDGET_DEPOT_MOVE_BOTTOM) w->widget[i].bottom += vertical;
}
}
if (type == VEH_Train) { if (type == VEH_Train) {
/* Now we move the train only widgets so they are placed correctly /* Now we move the train only widgets so they are placed correctly

8
gui.h
View File

@ -40,28 +40,20 @@ void ShowBuildRailToolbar(RailType railtype, int button);
void PlaceProc_BuyLand(TileIndex tile); void PlaceProc_BuyLand(TileIndex tile);
/* train_gui.c */ /* train_gui.c */
void ShowPlayerTrains(PlayerID player, StationID station);
void ShowTrainViewWindow(const Vehicle *v); void ShowTrainViewWindow(const Vehicle *v);
void ShowOrdersWindow(const Vehicle *v); void ShowOrdersWindow(const Vehicle *v);
void ShowVehWithSharedOrdersTrains(Vehicle *v);
/* road_gui.c */ /* road_gui.c */
void ShowBuildRoadToolbar(void); void ShowBuildRoadToolbar(void);
void ShowBuildRoadScenToolbar(void); void ShowBuildRoadScenToolbar(void);
void ShowPlayerRoadVehicles(PlayerID player, StationID station);
void ShowVehWithSharedOrdersRoadVehicles(Vehicle *v);
void ShowRoadVehViewWindow(const Vehicle *v); void ShowRoadVehViewWindow(const Vehicle *v);
/* dock_gui.c */ /* dock_gui.c */
void ShowBuildDocksToolbar(void); void ShowBuildDocksToolbar(void);
void ShowPlayerShips(PlayerID player, StationID station);
void ShowVehWithSharedOrdersShips(Vehicle *v);
void ShowShipViewWindow(const Vehicle *v); void ShowShipViewWindow(const Vehicle *v);
/* aircraft_gui.c */ /* aircraft_gui.c */
void ShowBuildAirToolbar(void); void ShowBuildAirToolbar(void);
void ShowPlayerAircraft(PlayerID player, StationID station);
void ShowVehWithSharedOrdersAircraft(Vehicle *v);
/* terraform_gui.c */ /* terraform_gui.c */
void ShowTerraformToolbar(void); void ShowTerraformToolbar(void);

View File

@ -33,6 +33,7 @@
#include "genworld.h" #include "genworld.h"
#include "settings.h" #include "settings.h"
#include "date.h" #include "date.h"
#include "vehicle_gui.h"
#include "network_data.h" #include "network_data.h"
#include "network_client.h" #include "network_client.h"
@ -268,22 +269,22 @@ static void MenuClickIndustry(int index)
static void MenuClickShowTrains(int index) static void MenuClickShowTrains(int index)
{ {
ShowPlayerTrains(index, INVALID_STATION); ShowVehicleListWindow(index, INVALID_STATION, VEH_Train);
} }
static void MenuClickShowRoad(int index) static void MenuClickShowRoad(int index)
{ {
ShowPlayerRoadVehicles(index, INVALID_STATION); ShowVehicleListWindow(index, INVALID_STATION, VEH_Road);
} }
static void MenuClickShowShips(int index) static void MenuClickShowShips(int index)
{ {
ShowPlayerShips(index, INVALID_STATION); ShowVehicleListWindow(index, INVALID_STATION, VEH_Ship);
} }
static void MenuClickShowAir(int index) static void MenuClickShowAir(int index)
{ {
ShowPlayerAircraft(index, INVALID_STATION); ShowVehicleListWindow(index, INVALID_STATION, VEH_Aircraft);
} }
static void MenuClickBuildRail(int index) static void MenuClickBuildRail(int index)
@ -1792,10 +1793,10 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
case WKC_F10:ShowOperatingProfitGraph(); break; case WKC_F10:ShowOperatingProfitGraph(); break;
case WKC_F11: ShowCompanyLeagueTable(); break; case WKC_F11: ShowCompanyLeagueTable(); break;
case WKC_F12: ShowBuildIndustryWindow(); break; case WKC_F12: ShowBuildIndustryWindow(); break;
case WKC_SHIFT | WKC_F1: ShowPlayerTrains(local, INVALID_STATION); break; case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(local, INVALID_STATION, VEH_Train); break;
case WKC_SHIFT | WKC_F2: ShowPlayerRoadVehicles(local, INVALID_STATION); break; case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(local, INVALID_STATION, VEH_Road); break;
case WKC_SHIFT | WKC_F3: ShowPlayerShips(local, INVALID_STATION); break; case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(local, INVALID_STATION, VEH_Ship); break;
case WKC_SHIFT | WKC_F4: ShowPlayerAircraft(local, INVALID_STATION); break; case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(local, INVALID_STATION, VEH_Aircraft); break;
case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break; case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break;
case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break; case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break;
case WKC_SHIFT | WKC_F7: ShowBuildRailToolbar(_last_built_railtype,-1); break; case WKC_SHIFT | WKC_F7: ShowBuildRailToolbar(_last_built_railtype,-1); break;

View File

@ -30,6 +30,7 @@
#include "tgp.h" #include "tgp.h"
#include "settings.h" #include "settings.h"
#include "date.h" #include "date.h"
#include "resize_window_widgets.h"
#include "fios.h" #include "fios.h"
/* Variables to display file lists */ /* Variables to display file lists */
@ -1867,3 +1868,22 @@ void ShowCheatWindow(void)
if (w != NULL) SetWindowDirty(w); if (w != NULL) SetWindowDirty(w);
} }
/** Resize the widgets in a window
* @param *w Window to resize in
* @param *resizearray Bytearray of the same length as the window contains widgets. Each byte tells how to move the widget of the same index using the flags in resize_window_widgets.h
* @param length Length of the bytearray
* @param horizontal Tells how far to the right the widgets should be moved (note: negative moves left)
* @param vertical Tells how far down the widgets should be moved (note: negative moves up)
*/
void ResizeWindowWidgets(Window *w, const byte *resizearray, byte length, byte horizontal, byte vertical)
{
byte i;
for (i = 0; i < length; i++) {
if (resizearray[i] & WIDGET_DEFINE_MOVE_LEFT) w->widget[i].left += horizontal;
if (resizearray[i] & WIDGET_DEFINE_MOVE_RIGHT) w->widget[i].right += horizontal;
if (resizearray[i] & WIDGET_DEFINE_MOVE_TOP) w->widget[i].top += vertical;
if (resizearray[i] & WIDGET_DEFINE_MOVE_BOTTOM) w->widget[i].bottom += vertical;
}
}

View File

@ -21,6 +21,7 @@
#include "waypoint.h" #include "waypoint.h"
#include "train.h" #include "train.h"
#include "water_map.h" #include "water_map.h"
#include "vehicle_gui.h"
static int OrderGetSel(const Window *w) static int OrderGetSel(const Window *w)
{ {
@ -463,13 +464,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
OrderClick_Transfer(w, v); OrderClick_Transfer(w, v);
break; break;
case 11: /* Vehicle with same shared Orders button */ case 11: /* Vehicle with same shared Orders button */
switch (v->type) { ShowVehWithSharedOrders(v, v->type);
case VEH_Train: ShowVehWithSharedOrdersTrains(v); break;
case VEH_Road: ShowVehWithSharedOrdersRoadVehicles(v); break;
case VEH_Ship: ShowVehWithSharedOrdersShips(v); break;
case VEH_Aircraft: ShowVehWithSharedOrdersAircraft(v); break;
default: NOT_REACHED(); break;
}
break; break;
} }
} break; } break;

31
resize_window_widgets.h Normal file
View File

@ -0,0 +1,31 @@
/* $Id$ */
/** @file resize_window_widgets.h */
#ifndef RESIZE_WINDOW_WIDGET_H
#define RESIZE_WINDOW_WIDGET_H
#include "stdafx.h"
#include "window.h"
enum {
WIDGET_DEFINE_MOVE_NONE = 0 << 0,
WIDGET_DEFINE_MOVE_RIGHT = 1 << 0,
WIDGET_DEFINE_MOVE_LEFT = 1 << 1,
WIDGET_DEFINE_MOVE_TOP = 1 << 2,
WIDGET_DEFINE_MOVE_BOTTOM = 1 << 3,
WIDGET_MOVE_NONE = WIDGET_DEFINE_MOVE_NONE,
WIDGET_STRETCH_RIGHT = WIDGET_DEFINE_MOVE_RIGHT,
WIDGET_MOVE_RIGHT = WIDGET_DEFINE_MOVE_RIGHT | WIDGET_DEFINE_MOVE_LEFT,
WIDGET_STRETCH_DOWN = WIDGET_DEFINE_MOVE_BOTTOM,
WIDGET_MOVE_DOWN = WIDGET_DEFINE_MOVE_BOTTOM | WIDGET_DEFINE_MOVE_TOP,
WIDGET_STRETCH_DOWN_RIGHT = WIDGET_STRETCH_DOWN | WIDGET_STRETCH_RIGHT,
WIDGET_MOVE_DOWN_RIGHT = WIDGET_MOVE_RIGHT | WIDGET_MOVE_DOWN,
WIDGET_MOVE_RIGHT_STRETCH_DOWN = WIDGET_MOVE_RIGHT | WIDGET_STRETCH_DOWN,
WIDGET_MOVE_DOWN_STRETCH_RIGHT = WIDGET_MOVE_DOWN | WIDGET_STRETCH_RIGHT,
};
void ResizeWindowWidgets(Window *w, const byte *resizearray, byte length, byte horizontal, byte vertical);
#endif

View File

@ -535,78 +535,3 @@ void ShowBuildRoadVehWindow(TileIndex tile)
} }
} }
static const Widget _player_roadveh_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP},
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP},
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP},
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL},
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 207, 0x701, STR_901A_ROAD_VEHICLES_CLICK_ON},
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 208, 219, STR_SEND_TO_DEPOTS, STR_SEND_TO_DEPOTS_TIP},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 125, 247, 208, 219, STR_REPLACE_VEHICLES, STR_REPLACE_HELP},
{ WWT_PANEL, RESIZE_RTB, 14, 248, 247, 208, 219, 0x0, STR_NULL},
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 208, 219, 0x0, STR_RESIZE_BUTTON},
{ WIDGETS_END},
};
static const Widget _other_player_roadveh_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP},
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP},
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP},
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL},
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 207, 0x701, STR_901A_ROAD_VEHICLES_CLICK_ON},
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PANEL, RESIZE_RTB, 14, 0, 247, 208, 219, 0x0, STR_NULL},
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 208, 219, 0x0, STR_RESIZE_BUTTON},
{ WIDGETS_END},
};
static const WindowDesc _player_roadveh_desc = {
-1, -1, 260, 220,
WC_ROADVEH_LIST,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
_player_roadveh_widgets,
PlayerVehWndProc
};
static const WindowDesc _other_player_roadveh_desc = {
-1, -1, 260, 220,
WC_ROADVEH_LIST,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
_other_player_roadveh_widgets,
PlayerVehWndProc
};
static void ShowPlayerRoadVehiclesLocal(PlayerID player, StationID station, OrderID order, bool show_shared)
{
Window *w;
if (show_shared) {
w = AllocateWindowDescFront(&_player_roadveh_desc, (order << 16) | (VEH_Road << 11) | VLW_SHARED_ORDERS | player);
} else {
uint16 VLW_flag = (station == INVALID_STATION) ? VLW_STANDARD : VLW_STATION_LIST;
if (player == _local_player) {
w = AllocateWindowDescFront(&_player_roadveh_desc, (station << 16) | (VEH_Road << 11) | VLW_flag | player);
} else {
w = AllocateWindowDescFront(&_other_player_roadveh_desc, (station << 16) | (VEH_Road << 11) | VLW_flag | player);
}
}
}
void ShowPlayerRoadVehicles(PlayerID player, StationID station)
{
ShowPlayerRoadVehiclesLocal(player, station, 0, false);
}
void ShowVehWithSharedOrdersRoadVehicles(Vehicle *v)
{
if (v->orders == NULL) return; // no shared list to show
ShowPlayerRoadVehiclesLocal(v->owner, INVALID_STATION, v->orders->index, true);
}

View File

@ -548,80 +548,3 @@ void DrawSmallOrderListShip(const Vehicle *v, int x, int y)
} }
} }
} }
static const Widget _player_ships_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP},
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP},
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP},
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL},
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_9823_SHIPS_CLICK_ON_SHIP_FOR},
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 170, 181, STR_SEND_TO_DEPOTS, STR_SEND_TO_DEPOTS_TIP},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 125, 247, 170, 181, STR_REPLACE_VEHICLES, STR_REPLACE_HELP},
{ WWT_PANEL, RESIZE_RTB, 14, 248, 247, 170, 181, 0x0, STR_NULL},
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON},
{ WIDGETS_END},
};
static const Widget _other_player_ships_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP},
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP},
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP},
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL},
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_9823_SHIPS_CLICK_ON_SHIP_FOR},
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PANEL, RESIZE_RTB, 14, 0, 247, 170, 181, 0x0, STR_NULL},
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON},
{ WIDGETS_END},
};
static const WindowDesc _player_ships_desc = {
-1, -1, 260, 182,
WC_SHIPS_LIST,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
_player_ships_widgets,
PlayerVehWndProc
};
static const WindowDesc _other_player_ships_desc = {
-1, -1, 260, 182,
WC_SHIPS_LIST,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
_other_player_ships_widgets,
PlayerVehWndProc
};
static void ShowPlayerShipsLocal(PlayerID player, StationID station, OrderID order, bool show_shared)
{
Window *w;
if (show_shared) {
w = AllocateWindowDescFront(&_player_ships_desc, (order << 16) | (VEH_Ship << 11) | VLW_SHARED_ORDERS | player);
} else {
uint16 VLW_flag = (station == INVALID_STATION) ? VLW_STANDARD : VLW_STATION_LIST;
if (player == _local_player) {
w = AllocateWindowDescFront(&_player_ships_desc, (station << 16) | (VEH_Ship << 11) | VLW_flag | player);
} else {
w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | (VEH_Ship << 11) | VLW_flag | player);
}
}
}
void ShowPlayerShips(PlayerID player, StationID station)
{
ShowPlayerShipsLocal(player, station, 0, false);
}
void ShowVehWithSharedOrdersShips(Vehicle *v)
{
if (v->orders == NULL) return; // no shared list to show
ShowPlayerShipsLocal(v->owner, INVALID_STATION, v->orders->index, true);
}

View File

@ -17,6 +17,7 @@
#include "variables.h" #include "variables.h"
#include "vehicle_gui.h" #include "vehicle_gui.h"
#include "date.h" #include "date.h"
#include "vehicle.h"
typedef int CDECL StationSortListingTypeFunction(const void*, const void*); typedef int CDECL StationSortListingTypeFunction(const void*, const void*);
@ -679,13 +680,13 @@ static void StationViewWndProc(Window *w, WindowEvent *e)
case 10: { /* Show a list of scheduled trains to this station */ case 10: { /* Show a list of scheduled trains to this station */
const Station *st = GetStation(w->window_number); const Station *st = GetStation(w->window_number);
ShowPlayerTrains(st->owner, w->window_number); ShowVehicleListWindow(st->owner, w->window_number, VEH_Train);
break; break;
} }
case 11: { /* Show a list of scheduled road-vehicles to this station */ case 11: { /* Show a list of scheduled road-vehicles to this station */
const Station *st = GetStation(w->window_number); const Station *st = GetStation(w->window_number);
ShowPlayerRoadVehicles(st->owner, w->window_number); ShowVehicleListWindow(st->owner, w->window_number, VEH_Road);
break; break;
} }
@ -693,7 +694,7 @@ static void StationViewWndProc(Window *w, WindowEvent *e)
const Station *st = GetStation(w->window_number); const Station *st = GetStation(w->window_number);
/* Since oilrigs have no owners, show the scheduled aircraft of current player */ /* Since oilrigs have no owners, show the scheduled aircraft of current player */
PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner; PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
ShowPlayerAircraft(owner, w->window_number); ShowVehicleListWindow(owner, w->window_number, VEH_Aircraft);
break; break;
} }
@ -701,7 +702,7 @@ static void StationViewWndProc(Window *w, WindowEvent *e)
const Station *st = GetStation(w->window_number); const Station *st = GetStation(w->window_number);
/* Since oilrigs/bouys have no owners, show the scheduled ships of current player */ /* Since oilrigs/bouys have no owners, show the scheduled ships of current player */
PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner; PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
ShowPlayerShips(owner, w->window_number); ShowVehicleListWindow(owner, w->window_number, VEH_Ship);
break; break;
} }
} }

View File

@ -873,78 +873,3 @@ static void ShowTrainDetailsWindow(const Vehicle *v)
WP(w,traindetails_d).tab = 0; WP(w,traindetails_d).tab = 0;
} }
static const Widget _player_trains_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 312, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, 14, 313, 324, 0, 13, 0x0, STR_STICKY_BUTTON},
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP},
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP},
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP},
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 324, 14, 25, 0x0, STR_NULL},
{ WWT_MATRIX, RESIZE_RB, 14, 0, 312, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR},
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 313, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 156, 208, 219, STR_SEND_TO_DEPOTS, STR_SEND_TO_DEPOTS_TIP},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 157, 312, 208, 219, STR_REPLACE_VEHICLES, STR_REPLACE_HELP},
{ WWT_PANEL, RESIZE_RTB, 14, 313, 312, 208, 219, 0x0, STR_NULL},
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 313, 324, 208, 219, 0x0, STR_RESIZE_BUTTON},
{ WIDGETS_END},
};
static const Widget _other_player_trains_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 312, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, 14, 313, 324, 0, 13, 0x0, STR_STICKY_BUTTON},
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP},
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP},
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP},
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 324, 14, 25, 0x0, STR_NULL},
{ WWT_MATRIX, RESIZE_RB, 14, 0, 312, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR},
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 313, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PANEL, RESIZE_RTB, 14, 0, 312, 208, 219, 0x0, STR_NULL},
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 313, 324, 208, 219, 0x0, STR_RESIZE_BUTTON},
{ WIDGETS_END},
};
static const WindowDesc _player_trains_desc = {
-1, -1, 325, 220,
WC_TRAINS_LIST,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
_player_trains_widgets,
PlayerVehWndProc
};
static const WindowDesc _other_player_trains_desc = {
-1, -1, 325, 220,
WC_TRAINS_LIST,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
_other_player_trains_widgets,
PlayerVehWndProc
};
static void ShowPlayerTrainsLocal(PlayerID player, StationID station, OrderID order, bool show_shared)
{
Window *w;
if (show_shared) {
w = AllocateWindowDescFront(&_player_trains_desc, (order << 16) | (VEH_Train << 11) | VLW_SHARED_ORDERS | player);
} else {
uint16 VLW_flag = (station == INVALID_STATION) ? VLW_STANDARD : VLW_STATION_LIST;
if (player == _local_player) {
w = AllocateWindowDescFront(&_player_trains_desc, (station << 16) | (VEH_Train << 11) | VLW_flag | player);
} else {
w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | (VEH_Train << 11) | VLW_flag | player);
}
}
}
void ShowPlayerTrains(PlayerID player, StationID station)
{
ShowPlayerTrainsLocal(player, station, INVALID_ORDER, false);
}
void ShowVehWithSharedOrdersTrains(Vehicle *v)
{
if (v->orders == NULL) return; // no shared list to show
ShowPlayerTrainsLocal(v->owner, INVALID_STATION, v->orders->index, true);
}

View File

@ -27,6 +27,7 @@
#include "aircraft.h" #include "aircraft.h"
#include "roadveh.h" #include "roadveh.h"
#include "depot.h" #include "depot.h"
#include "resize_window_widgets.h"
typedef struct Sorting { typedef struct Sorting {
Listing aircraft; Listing aircraft;
@ -1210,26 +1211,125 @@ enum {
PLY_WND_PRC__SIZE_OF_ROW_BIG = 36, PLY_WND_PRC__SIZE_OF_ROW_BIG = 36,
}; };
typedef enum VehicleListWindowWidgets {
VLW_WIDGET_CLOSEBOX = 0,
VLW_WIDGET_CAPTION,
VLW_WIDGET_STICKY,
VLW_WIDGET_SORT_ORDER,
VLW_WIDGET_SORT_BY_TEXT,
VLW_WIDGET_SORT_BY_PULLDOWN,
VLW_WIDGET_EMPTY_SPACE_TOP_RIGHT,
VLW_WIDGET_LIST,
VLW_WIDGET_SCROLLBAR,
VLW_WIDGET_OTHER_PLAYER_FILLER,
VLW_WIDGET_SEND_TO_DEPOT,
VLW_WIDGET_AUTOREPLACE,
VLW_WIDGET_RESIZE,
} VehicleListWindowWidget;
static const byte vehicle_list_widget_moves[] = {
WIDGET_MOVE_NONE, // VLW_WIDGET_CLOSEBOX
WIDGET_STRETCH_RIGHT, // VLW_WIDGET_CAPTION
WIDGET_MOVE_RIGHT, // VLW_WIDGET_STICKY
WIDGET_MOVE_NONE, // VLW_WIDGET_SORT_ORDER
WIDGET_MOVE_NONE, // VLW_WIDGET_SORT_BY_TEXT
WIDGET_MOVE_NONE, // VLW_WIDGET_SORT_BY_PULLDOWN
WIDGET_STRETCH_RIGHT, // VLW_WIDGET_EMPTY_SPACE_TOP_RIGHT
WIDGET_STRETCH_DOWN_RIGHT, // VLW_WIDGET_LIST
WIDGET_MOVE_RIGHT_STRETCH_DOWN, // VLW_WIDGET_SCROLLBAR
WIDGET_MOVE_DOWN_STRETCH_RIGHT, // VLW_WIDGET_OTHER_PLAYER_FILLER
WIDGET_MOVE_DOWN, // VLW_WIDGET_SEND_TO_DEPOT
WIDGET_MOVE_DOWN, // VLW_WIDGET_AUTOREPLACE
WIDGET_MOVE_DOWN_RIGHT, // VLW_WIDGET_RESIZE
};
static const Widget _vehicle_list_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, 0x0, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP},
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP},
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP},
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL},
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x0, STR_NULL},
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PANEL, RESIZE_RTB, 14, 0, 247, 170, 181, 0x0, STR_NULL},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 170, 181, STR_SEND_TO_DEPOTS, STR_SEND_TO_DEPOTS_TIP},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 125, 247, 170, 181, STR_REPLACE_VEHICLES, STR_REPLACE_HELP},
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON},
{ WIDGETS_END},
};
/* Resize the bottom row of buttons to make them equal in size when resizing */
static void ResizeVehicleListWidgets(Window *w)
{
w->widget[VLW_WIDGET_AUTOREPLACE].right = w->widget[VLW_WIDGET_RESIZE].left - 1;
w->widget[VLW_WIDGET_SEND_TO_DEPOT].right = w->widget[VLW_WIDGET_AUTOREPLACE].right / 2;
w->widget[VLW_WIDGET_AUTOREPLACE].left = w->widget[VLW_WIDGET_SEND_TO_DEPOT].right;
}
static void CreateVehicleListWindow(Window *w) static void CreateVehicleListWindow(Window *w)
{ {
vehiclelist_d *vl = &WP(w, vehiclelist_d); vehiclelist_d *vl = &WP(w, vehiclelist_d);
uint16 window_type = w->window_number & VLW_MASK; uint16 window_type = w->window_number & VLW_MASK;
PlayerID player = GB(w->window_number, 0, 8);
vl->vehicle_type = GB(w->window_number, 11, 5); vl->vehicle_type = GB(w->window_number, 11, 5);
w->caption_color = GB(w->window_number, 0, 8); // PlayerID w->caption_color = player;
/* Hide the widgets that we will not use in this window
* Some windows contains actions only fit for the owner */
if (player == _local_player) {
SETBIT(w->hidden_state, VLW_WIDGET_OTHER_PLAYER_FILLER);
} else {
SETBIT(w->hidden_state, VLW_WIDGET_SEND_TO_DEPOT);
SETBIT(w->hidden_state, VLW_WIDGET_AUTOREPLACE);
}
/* Set up the window widgets */ /* Set up the window widgets */
switch (vl->vehicle_type) {
case VEH_Train:
w->widget[VLW_WIDGET_LIST].tooltips = STR_883D_TRAINS_CLICK_ON_TRAIN_FOR;
break;
case VEH_Road:
w->widget[VLW_WIDGET_LIST].tooltips = STR_901A_ROAD_VEHICLES_CLICK_ON;
break;
case VEH_Ship:
w->widget[VLW_WIDGET_LIST].tooltips = STR_9823_SHIPS_CLICK_ON_SHIP_FOR;
break;
case VEH_Aircraft:
w->widget[VLW_WIDGET_CAPTION].data = STR_A009_AIRCRAFT;
w->widget[VLW_WIDGET_LIST].tooltips = STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT;
/* Aircraft uses hangars, not depots, so we will apply the hangar strings */
w->widget[VLW_WIDGET_SEND_TO_DEPOT].data = STR_SEND_TO_HANGARS;
w->widget[VLW_WIDGET_SEND_TO_DEPOT].tooltips = STR_SEND_TO_HANGARS_TIP;
break;
default: NOT_REACHED(); break;
}
switch (window_type) { switch (window_type) {
case VLW_SHARED_ORDERS: case VLW_SHARED_ORDERS:
w->widget[1].data = STR_VEH_WITH_SHARED_ORDERS_LIST; w->widget[VLW_WIDGET_CAPTION].data = STR_VEH_WITH_SHARED_ORDERS_LIST;
break; break;
case VLW_STANDARD: /* Company Name - standard widget setup */ case VLW_STANDARD: /* Company Name - standard widget setup */
switch (vl->vehicle_type) {
case VEH_Train: w->widget[VLW_WIDGET_CAPTION].data = STR_881B_TRAINS; break;
case VEH_Road: w->widget[VLW_WIDGET_CAPTION].data = STR_9001_ROAD_VEHICLES; break;
case VEH_Ship: w->widget[VLW_WIDGET_CAPTION].data = STR_9805_SHIPS; break;
case VEH_Aircraft: w->widget[VLW_WIDGET_CAPTION].data = STR_A009_AIRCRAFT; break;
default: NOT_REACHED(); break;
}
break; break;
case VLW_STATION_LIST: /* Station Name */ case VLW_STATION_LIST: /* Station Name */
switch (vl->vehicle_type) { switch (vl->vehicle_type) {
case VEH_Train: w->widget[1].data = STR_SCHEDULED_TRAINS; break; case VEH_Train: w->widget[VLW_WIDGET_CAPTION].data = STR_SCHEDULED_TRAINS; break;
case VEH_Road: w->widget[1].data = STR_SCHEDULED_ROAD_VEHICLES; break; case VEH_Road: w->widget[VLW_WIDGET_CAPTION].data = STR_SCHEDULED_ROAD_VEHICLES; break;
case VEH_Ship: w->widget[1].data = STR_SCHEDULED_SHIPS; break; case VEH_Ship: w->widget[VLW_WIDGET_CAPTION].data = STR_SCHEDULED_SHIPS; break;
case VEH_Aircraft: w->widget[1].data = STR_SCHEDULED_AIRCRAFT; break; case VEH_Aircraft: w->widget[VLW_WIDGET_CAPTION].data = STR_SCHEDULED_AIRCRAFT; break;
default: NOT_REACHED(); break; default: NOT_REACHED(); break;
} }
break; break;
@ -1254,7 +1354,7 @@ static void CreateVehicleListWindow(Window *w)
default: NOT_REACHED(); default: NOT_REACHED();
} }
w->widget[7].data = (w->vscroll.cap << 8) + 1; w->widget[VLW_WIDGET_LIST].data = (w->vscroll.cap << 8) + 1;
/* Set up sorting. Make the window-specific _sorting variable /* Set up sorting. Make the window-specific _sorting variable
* point to the correct global _sorting struct so we are freed * point to the correct global _sorting struct so we are freed
@ -1272,6 +1372,12 @@ static void CreateVehicleListWindow(Window *w)
vl->sort_list = NULL; vl->sort_list = NULL;
vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer
/* Resize the widgets to fit the window size.
* Aircraft and ships already got the right size widgets */
if (w->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_SMALL) {
ResizeWindowWidgets(w, vehicle_list_widget_moves, lengthof(vehicle_list_widget_moves), vl->vehicle_type == VEH_Train ? 65 : 0, 38);
ResizeVehicleListWidgets(w);
}
} }
static void DrawVehicleListWindow(Window *w) static void DrawVehicleListWindow(Window *w)
@ -1411,17 +1517,17 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
case WE_CLICK: { case WE_CLICK: {
switch (e->we.click.widget) { switch (e->we.click.widget) {
case 3: /* Flip sorting method ascending/descending */ case VLW_WIDGET_SORT_ORDER: /* Flip sorting method ascending/descending */
vl->l.flags ^= VL_DESC; vl->l.flags ^= VL_DESC;
vl->l.flags |= VL_RESORT; vl->l.flags |= VL_RESORT;
vl->_sorting->order = !!(vl->l.flags & VL_DESC); vl->_sorting->order = !!(vl->l.flags & VL_DESC);
SetWindowDirty(w); SetWindowDirty(w);
break; break;
case 4: case 5:/* Select sorting criteria dropdown menu */ case VLW_WIDGET_SORT_BY_TEXT: case VLW_WIDGET_SORT_BY_PULLDOWN:/* Select sorting criteria dropdown menu */
ShowDropDownMenu(w, _vehicle_sort_listing, vl->l.sort_type, 5, 0, 0); ShowDropDownMenu(w, _vehicle_sort_listing, vl->l.sort_type, VLW_WIDGET_SORT_BY_PULLDOWN, 0, 0);
return; return;
case 7: { /* Matrix to show vehicles */ case VLW_WIDGET_LIST: { /* Matrix to show vehicles */
uint32 id_v = (e->we.click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / w->resize.step_height; uint32 id_v = (e->we.click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / w->resize.step_height;
const Vehicle *v; const Vehicle *v;
@ -1442,15 +1548,13 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
} }
} break; } break;
case 9: // Left button case VLW_WIDGET_SEND_TO_DEPOT: // Left button
if ((PlayerID)w->caption_color != _local_player) break;
assert(vl->l.list_length != 0); assert(vl->l.list_length != 0);
DoCommandP(0, GB(w->window_number, 16, 16) /* StationID or OrderID (depending on VLW). Nomatter which one it is, it's needed here */, DoCommandP(0, GB(w->window_number, 16, 16) /* StationID or OrderID (depending on VLW). Nomatter which one it is, it's needed here */,
(w->window_number & VLW_MASK) | DEPOT_MASS_SEND | (_ctrl_pressed ? DEPOT_SERVICE : 0), NULL, CMD_SEND_TO_DEPOT(vl->vehicle_type)); (w->window_number & VLW_MASK) | DEPOT_MASS_SEND | (_ctrl_pressed ? DEPOT_SERVICE : 0), NULL, CMD_SEND_TO_DEPOT(vl->vehicle_type));
break; break;
case 10: // Right button case VLW_WIDGET_AUTOREPLACE: // Right button
ShowReplaceVehicleWindow(vl->vehicle_type); ShowReplaceVehicleWindow(vl->vehicle_type);
break; break;
} }
@ -1485,7 +1589,65 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
case WE_RESIZE: /* Update the scroll + matrix */ case WE_RESIZE: /* Update the scroll + matrix */
if (vl->vehicle_type == VEH_Train) w->hscroll.cap += e->we.sizing.diff.x; if (vl->vehicle_type == VEH_Train) w->hscroll.cap += e->we.sizing.diff.x;
w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height; w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height;
w->widget[7].data = (w->vscroll.cap << 8) + 1; w->widget[VLW_WIDGET_LIST].data = (w->vscroll.cap << 8) + 1;
ResizeVehicleListWidgets(w);
break; break;
} }
} }
static const WindowDesc _player_vehicle_list_large_desc = {
-1, -1, 260, 182,
WC_SHIPS_LIST,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
_vehicle_list_widgets,
PlayerVehWndProc
};
static const WindowDesc _player_vehicle_list_train_desc = {
-1, -1, 325, 220,
WC_TRAINS_LIST,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
_vehicle_list_widgets,
PlayerVehWndProc
};
static const WindowDesc _player_vehicle_list_road_veh_desc = {
-1, -1, 260, 220,
WC_TRAINS_LIST,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
_vehicle_list_widgets,
PlayerVehWndProc
};
static void ShowVehicleListWindowLocal(PlayerID player, byte vehicle_type, StationID station, OrderID order, bool show_shared)
{
Window *w;
WindowNumber num = (vehicle_type << 11) | player;
if (show_shared) {
num |= (order << 16) | VLW_SHARED_ORDERS;
} else if (station == INVALID_STATION) {
num |= VLW_STANDARD;
} else {
num |= (station << 16) | VLW_STATION_LIST;
}
if (vehicle_type == VEH_Train) {
w = AllocateWindowDescFront(&_player_vehicle_list_train_desc, num);
} else if (vehicle_type == VEH_Road) {
w = AllocateWindowDescFront(&_player_vehicle_list_road_veh_desc, num);
} else {
w = AllocateWindowDescFront(&_player_vehicle_list_large_desc, num);
}
}
void ShowVehicleListWindow(PlayerID player, StationID station, byte vehicle_type)
{
ShowVehicleListWindowLocal(player, vehicle_type, station, INVALID_ORDER, false);
}
void ShowVehWithSharedOrders(Vehicle *v, byte vehicle_type)
{
if (v->orders == NULL) return; // no shared list to show
ShowVehicleListWindowLocal(v->owner, vehicle_type, INVALID_STATION, v->orders->index, true);
}

View File

@ -52,4 +52,7 @@ void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v);
int ShowAdditionalText(int x, int y, int w, EngineID engine); int ShowAdditionalText(int x, int y, int w, EngineID engine);
void ShowVehicleListWindow(PlayerID player, StationID station, byte vehicle_type);
void ShowVehWithSharedOrders(Vehicle *v, byte vehicle_type);
#endif /* VEHICLE_GUI_H */ #endif /* VEHICLE_GUI_H */