src/vehicle_gui.h
author rubidium
Wed, 19 Dec 2007 23:26:02 +0000
changeset 8108 b42a0e5c67ef
parent 8106 e6790dd9e750
child 8144 65cec0877b78
permissions -rw-r--r--
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     2
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6385
diff changeset
     3
/** @file vehicle_gui.h */
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6385
diff changeset
     4
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
diff changeset
     5
#ifndef VEHICLE_GUI_H
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
diff changeset
     6
#define VEHICLE_GUI_H
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
diff changeset
     7
8106
e6790dd9e750 (svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps.
rubidium
parents: 7486
diff changeset
     8
#include "window_gui.h"
4734
24b34218c5ce (svn r6646) -Codechange: [vehicle list window] Cleaned up the drawing code
bjarni
parents: 4712
diff changeset
     9
#include "vehicle.h"
1752
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1246
diff changeset
    10
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2186
diff changeset
    11
void DrawVehicleProfitButton(const Vehicle *v, int x, int y);
4712
4335ad42e163 (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4681
diff changeset
    12
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5972
diff changeset
    13
void InitializeVehiclesGuiList();
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
diff changeset
    14
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
diff changeset
    15
/* sorter stuff */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5972
diff changeset
    16
void RebuildVehicleLists();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5972
diff changeset
    17
void ResortVehicleLists();
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    18
void SortVehicleList(vehiclelist_d *vl);
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    19
void BuildVehicleList(vehiclelist_d *vl, PlayerID owner, uint16 index, uint16 window_type);
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 505
diff changeset
    20
168
79f9ed5b23e6 (svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents: 164
diff changeset
    21
#define PERIODIC_RESORT_DAYS 10
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
diff changeset
    22
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    23
extern const StringID _vehicle_sort_listing[];
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    24
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    25
/* Start of functions regarding vehicle list windows */
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    26
enum {
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    27
	PLY_WND_PRC__OFFSET_TOP_WIDGET = 26,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    28
	PLY_WND_PRC__SIZE_OF_ROW_TINY  = 13,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    29
	PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    30
	PLY_WND_PRC__SIZE_OF_ROW_BIG   = 36,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    31
	PLY_WND_PRC__SIZE_OF_ROW_BIG2  = 39,
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    32
};
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    33
4449
820974aaa4a6 (svn r6227) -Codechange: added window type flags to use with PlayerVehWndProc
bjarni
parents: 4442
diff changeset
    34
/* Vehicle List Window type flags */
820974aaa4a6 (svn r6227) -Codechange: added window type flags to use with PlayerVehWndProc
bjarni
parents: 4442
diff changeset
    35
enum {
4546
507b7d9bd834 (svn r6378) -Codechange: Rename VLW_FLAGS to VLW_MASK as it is a mask
Darkvater
parents: 4545
diff changeset
    36
	VLW_STANDARD      = 0 << 8,
4449
820974aaa4a6 (svn r6227) -Codechange: added window type flags to use with PlayerVehWndProc
bjarni
parents: 4442
diff changeset
    37
	VLW_SHARED_ORDERS = 1 << 8,
820974aaa4a6 (svn r6227) -Codechange: added window type flags to use with PlayerVehWndProc
bjarni
parents: 4442
diff changeset
    38
	VLW_STATION_LIST  = 2 << 8,
4681
bc077405e9a8 (svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents: 4668
diff changeset
    39
	VLW_DEPOT_LIST    = 3 << 8,
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    40
	VLW_GROUP_LIST    = 4 << 8,
4546
507b7d9bd834 (svn r6378) -Codechange: Rename VLW_FLAGS to VLW_MASK as it is a mask
Darkvater
parents: 4545
diff changeset
    41
	VLW_MASK          = 0x700,
4449
820974aaa4a6 (svn r6227) -Codechange: added window type flags to use with PlayerVehWndProc
bjarni
parents: 4442
diff changeset
    42
};
820974aaa4a6 (svn r6227) -Codechange: added window type flags to use with PlayerVehWndProc
bjarni
parents: 4442
diff changeset
    43
4506
e6a56518135c (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4485
diff changeset
    44
static inline bool ValidVLWFlags(uint16 flags)
e6a56518135c (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4485
diff changeset
    45
{
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    46
	return (flags == VLW_STANDARD || flags == VLW_SHARED_ORDERS || flags == VLW_STATION_LIST || flags == VLW_DEPOT_LIST || flags == VLW_GROUP_LIST);
4506
e6a56518135c (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4485
diff changeset
    47
}
e6a56518135c (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4485
diff changeset
    48
4442
9f8bb348d58f (svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents: 4434
diff changeset
    49
void PlayerVehWndProc(Window *w, WindowEvent *e);
9f8bb348d58f (svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents: 4434
diff changeset
    50
6385
78f5307ce501 (svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents: 6259
diff changeset
    51
int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number);
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 588
diff changeset
    52
4442
9f8bb348d58f (svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents: 4434
diff changeset
    53
void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection);
6857
60130753e595 (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 6643
diff changeset
    54
void DrawRoadVehImage(const Vehicle *v, int x, int y, int count, VehicleID selection);
4442
9f8bb348d58f (svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents: 4434
diff changeset
    55
void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection);
4542
f42ecc669275 (svn r6372) -Codechange: static, unneeded decleration in headers, superfluous header includes
Darkvater
parents: 4506
diff changeset
    56
void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection);
4442
9f8bb348d58f (svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents: 4434
diff changeset
    57
6638
09c5d7bf69a5 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents: 6423
diff changeset
    58
void ShowBuildVehicleWindow(TileIndex tile, VehicleType type);
4442
9f8bb348d58f (svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents: 4434
diff changeset
    59
2552
5b586a545665 (svn r3081) -Codechange: [autoreplace] complete rewrite of autoreplace
bjarni
parents: 2548
diff changeset
    60
void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v);
5b586a545665 (svn r3081) -Codechange: [autoreplace] complete rewrite of autoreplace
bjarni
parents: 2548
diff changeset
    61
4932
4bf213d0ed53 (svn r6912) - Feature: Show a list of cargo types that a vehicle is refittable to in the purchase information window. (mart3p)
peter1138
parents: 4930
diff changeset
    62
uint ShowAdditionalText(int x, int y, uint w, EngineID engine);
4bf213d0ed53 (svn r6912) - Feature: Show a list of cargo types that a vehicle is refittable to in the purchase information window. (mart3p)
peter1138
parents: 4930
diff changeset
    63
uint ShowRefitOptionsList(int x, int y, uint w, EngineID engine);
2552
5b586a545665 (svn r3081) -Codechange: [autoreplace] complete rewrite of autoreplace
bjarni
parents: 2548
diff changeset
    64
5745
c8069ea3af5d (svn r8293) -Codechange: overloaded ShowVehicleListWindow() so it can open all types of vehicle lists (depending on arguments)
bjarni
parents: 5475
diff changeset
    65
void ShowVehicleListWindow(const Vehicle *v);
6638
09c5d7bf69a5 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents: 6423
diff changeset
    66
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type);
09c5d7bf69a5 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents: 6423
diff changeset
    67
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station);
09c5d7bf69a5 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents: 6423
diff changeset
    68
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex depot_tile);
4668
f7256d0e7682 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4642
diff changeset
    69
6638
09c5d7bf69a5 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents: 6423
diff changeset
    70
void ShowReplaceVehicleWindow(VehicleType vehicletype);
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    71
void DrawSmallOrderList(const Vehicle *v, int x, int y);
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6638
diff changeset
    72
void ShowReplaceGroupVehicleWindow(GroupID group, VehicleType veh);
4734
24b34218c5ce (svn r6646) -Codechange: [vehicle list window] Cleaned up the drawing code
bjarni
parents: 4712
diff changeset
    73
24b34218c5ce (svn r6646) -Codechange: [vehicle list window] Cleaned up the drawing code
bjarni
parents: 4712
diff changeset
    74
static inline void DrawVehicleImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection)
24b34218c5ce (svn r6646) -Codechange: [vehicle list window] Cleaned up the drawing code
bjarni
parents: 4712
diff changeset
    75
{
24b34218c5ce (svn r6646) -Codechange: [vehicle list window] Cleaned up the drawing code
bjarni
parents: 4712
diff changeset
    76
	switch (v->type) {
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6247
diff changeset
    77
		case VEH_TRAIN:    DrawTrainImage(v, x, y, count, skip, selection); break;
6857
60130753e595 (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 6643
diff changeset
    78
		case VEH_ROAD:     DrawRoadVehImage(v, x, y, count, selection);     break;
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6247
diff changeset
    79
		case VEH_SHIP:     DrawShipImage(v, x, y, selection);               break;
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6247
diff changeset
    80
		case VEH_AIRCRAFT: DrawAircraftImage(v, x, y, selection);           break;
4734
24b34218c5ce (svn r6646) -Codechange: [vehicle list window] Cleaned up the drawing code
bjarni
parents: 4712
diff changeset
    81
		default: NOT_REACHED();
24b34218c5ce (svn r6646) -Codechange: [vehicle list window] Cleaned up the drawing code
bjarni
parents: 4712
diff changeset
    82
	}
24b34218c5ce (svn r6646) -Codechange: [vehicle list window] Cleaned up the drawing code
bjarni
parents: 4712
diff changeset
    83
}
24b34218c5ce (svn r6646) -Codechange: [vehicle list window] Cleaned up the drawing code
bjarni
parents: 4712
diff changeset
    84
6638
09c5d7bf69a5 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents: 6423
diff changeset
    85
static inline uint GetVehicleListHeight(VehicleType type)
4796
20f8d2582b7b (svn r6718) -Codechange: added function to get the line height for a vehicle type
bjarni
parents: 4734
diff changeset
    86
{
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6247
diff changeset
    87
	return (type == VEH_TRAIN || type == VEH_ROAD) ? 14 : 24;
4796
20f8d2582b7b (svn r6718) -Codechange: added function to get the line height for a vehicle type
bjarni
parents: 4734
diff changeset
    88
}
20f8d2582b7b (svn r6718) -Codechange: added function to get the line height for a vehicle type
bjarni
parents: 4734
diff changeset
    89
7486
bf6a94009823 (svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents: 6857
diff changeset
    90
/* Unified window procedure */
bf6a94009823 (svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents: 6857
diff changeset
    91
void ShowVehicleViewWindow(const Vehicle *v);
bf6a94009823 (svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents: 6857
diff changeset
    92
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
diff changeset
    93
#endif /* VEHICLE_GUI_H */