author | rubidium |
Sat, 12 Jan 2008 14:10:35 +0000 | |
changeset 8750 | fdd6054e7bae |
parent 8720 | 4e60c30e2006 |
child 8760 | ce0891c412ce |
permissions | -rw-r--r-- |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1 |
/* $Id$ */ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
2 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6417
diff
changeset
|
3 |
/** @file build_vehicle_gui.cpp */ |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6417
diff
changeset
|
4 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
6 |
#include "openttd.h" |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
7 |
#include "train.h" |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
8 |
#include "roadveh.h" |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
9 |
#include "ship.h" |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
10 |
#include "aircraft.h" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
11 |
#include "debug.h" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
12 |
#include "table/sprites.h" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
13 |
#include "table/strings.h" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
14 |
#include "gui.h" |
7268
9c77f6baef3b
(svn r10008) -Codechange: Move a couple of functions related to articulated vehicles to a file of their own.
maedhros
parents:
7181
diff
changeset
|
15 |
#include "articulated_vehicles.h" |
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
16 |
#include "textbuf_gui.h" |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
17 |
#include "station.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8610
diff
changeset
|
18 |
#include "command_func.h" |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
19 |
#include "engine.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8720
diff
changeset
|
20 |
#include "player_func.h" |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
21 |
#include "depot.h" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
22 |
#include "airport.h" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
23 |
#include "vehicle_gui.h" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
24 |
#include "newgrf_engine.h" |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6413
diff
changeset
|
25 |
#include "cargotype.h" |
7139
4ae3ab180d05
(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:
7134
diff
changeset
|
26 |
#include "group.h" |
7181
f966d75af3a6
(svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents:
7139
diff
changeset
|
27 |
#include "road_map.h" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8603
diff
changeset
|
28 |
#include "strings_func.h" |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8617
diff
changeset
|
29 |
#include "window_func.h" |
8636
2b158acb649c
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8627
diff
changeset
|
30 |
#include "date_func.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8636
diff
changeset
|
31 |
#include "vehicle_func.h" |
8707
55835d8fbfcd
(svn r11774) -Change: do not include variables.h in a header when it is not needed.
rubidium
parents:
8644
diff
changeset
|
32 |
#include "settings_type.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8718
diff
changeset
|
33 |
#include "gfx_func.h" |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
34 |
|
8718
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
35 |
struct buildvehicle_d { |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
36 |
VehicleType vehicle_type; |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
37 |
union { |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
38 |
RailTypeByte railtype; |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
39 |
AirportFTAClass::Flags flags; |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
40 |
RoadTypes roadtypes; |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
41 |
} filter; |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
42 |
byte sel_index; ///< deprecated value, used for 'unified' ship and road |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
43 |
bool descending_sort_order; |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
44 |
byte sort_criteria; |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
45 |
bool regenerate_list; |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
46 |
EngineID sel_engine; |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
47 |
EngineID rename_engine; |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
48 |
EngineList eng_list; |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
49 |
}; |
1f536d980531
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8714
diff
changeset
|
50 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d)); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
51 |
|
5273
5fde4b8c94c4
(svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents:
5215
diff
changeset
|
52 |
enum BuildVehicleWidgets { |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
53 |
BUILD_VEHICLE_WIDGET_CLOSEBOX = 0, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
54 |
BUILD_VEHICLE_WIDGET_CAPTION, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
55 |
BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
56 |
BUILD_VEHICLE_WIDGET_SORT_TEXT, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
57 |
BUILD_VEHICLE_WIDGET_SORT_DROPDOWN, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
58 |
BUILD_VEHICLE_WIDGET_LIST, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
59 |
BUILD_VEHICLE_WIDGET_SCROLLBAR, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
60 |
BUILD_VEHICLE_WIDGET_PANEL, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
61 |
BUILD_VEHICLE_WIDGET_BUILD, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
62 |
BUILD_VEHICLE_WIDGET_RENAME, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
63 |
BUILD_VEHICLE_WIDGET_RESIZE, |
6711
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
64 |
BUILD_VEHICLE_WIDGET_END |
5273
5fde4b8c94c4
(svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents:
5215
diff
changeset
|
65 |
}; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
66 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
67 |
static const Widget _build_vehicle_widgets[] = { |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
68 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
6712
d100bbf7f752
(svn r9476) -Codechange: Make build windows for all vehicle types the same width.
maedhros
parents:
6711
diff
changeset
|
69 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 239, 0, 13, 0x0, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
70 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP}, |
6712
d100bbf7f752
(svn r9476) -Codechange: Make build windows for all vehicle types the same width.
maedhros
parents:
6711
diff
changeset
|
71 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 81, 227, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
d100bbf7f752
(svn r9476) -Codechange: Make build windows for all vehicle types the same width.
maedhros
parents:
6711
diff
changeset
|
72 |
{ WWT_TEXTBTN, RESIZE_LR, 14, 228, 239, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
7864
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
73 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 227, 26, 39, 0x101, STR_NULL }, |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
74 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 228, 239, 26, 39, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST }, |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
75 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 239, 40, 161, 0x0, STR_NULL }, |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
76 |
|
7864
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
77 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 114, 162, 173, 0x0, STR_NULL }, |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
78 |
{ WWT_PUSHTXTBTN, RESIZE_RTB, 14, 115, 227, 162, 173, 0x0, STR_NULL }, |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
79 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 228, 239, 162, 173, 0x0, STR_RESIZE_BUTTON }, |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
80 |
{ WIDGETS_END}, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
81 |
}; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
82 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
83 |
/* Setup widget strings to fit the different types of vehicles */ |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
84 |
static void SetupWindowStrings(Window *w, byte type) |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
85 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
86 |
switch (type) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
87 |
case VEH_TRAIN: |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
88 |
w->widget[BUILD_VEHICLE_WIDGET_CAPTION].data = STR_JUST_STRING; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
89 |
w->widget[BUILD_VEHICLE_WIDGET_LIST].tooltips = STR_8843_TRAIN_VEHICLE_SELECTION; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
90 |
w->widget[BUILD_VEHICLE_WIDGET_BUILD].data = STR_881F_BUILD_VEHICLE; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
91 |
w->widget[BUILD_VEHICLE_WIDGET_BUILD].tooltips = STR_8844_BUILD_THE_HIGHLIGHTED_TRAIN; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
92 |
w->widget[BUILD_VEHICLE_WIDGET_RENAME].data = STR_8820_RENAME; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
93 |
w->widget[BUILD_VEHICLE_WIDGET_RENAME].tooltips = STR_8845_RENAME_TRAIN_VEHICLE_TYPE; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
94 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
95 |
case VEH_ROAD: |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
96 |
w->widget[BUILD_VEHICLE_WIDGET_CAPTION].data = STR_9006_NEW_ROAD_VEHICLES; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
97 |
w->widget[BUILD_VEHICLE_WIDGET_LIST].tooltips = STR_9026_ROAD_VEHICLE_SELECTION; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
98 |
w->widget[BUILD_VEHICLE_WIDGET_BUILD].data = STR_9007_BUILD_VEHICLE; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
99 |
w->widget[BUILD_VEHICLE_WIDGET_BUILD].tooltips = STR_9027_BUILD_THE_HIGHLIGHTED_ROAD; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
100 |
w->widget[BUILD_VEHICLE_WIDGET_RENAME].data = STR_9034_RENAME; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
101 |
w->widget[BUILD_VEHICLE_WIDGET_RENAME].tooltips = STR_9035_RENAME_ROAD_VEHICLE_TYPE; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
102 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
103 |
case VEH_SHIP: |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
104 |
w->widget[BUILD_VEHICLE_WIDGET_CAPTION].data = STR_9808_NEW_SHIPS; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
105 |
w->widget[BUILD_VEHICLE_WIDGET_LIST].tooltips = STR_9825_SHIP_SELECTION_LIST_CLICK; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
106 |
w->widget[BUILD_VEHICLE_WIDGET_BUILD].data = STR_9809_BUILD_SHIP; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
107 |
w->widget[BUILD_VEHICLE_WIDGET_BUILD].tooltips = STR_9826_BUILD_THE_HIGHLIGHTED_SHIP; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
108 |
w->widget[BUILD_VEHICLE_WIDGET_RENAME].data = STR_9836_RENAME; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
109 |
w->widget[BUILD_VEHICLE_WIDGET_RENAME].tooltips = STR_9837_RENAME_SHIP_TYPE; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
110 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
111 |
case VEH_AIRCRAFT: |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
112 |
w->widget[BUILD_VEHICLE_WIDGET_CAPTION].data = STR_A005_NEW_AIRCRAFT; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
113 |
w->widget[BUILD_VEHICLE_WIDGET_LIST].tooltips = STR_A025_AIRCRAFT_SELECTION_LIST; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
114 |
w->widget[BUILD_VEHICLE_WIDGET_BUILD].data = STR_A006_BUILD_AIRCRAFT; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
115 |
w->widget[BUILD_VEHICLE_WIDGET_BUILD].tooltips = STR_A026_BUILD_THE_HIGHLIGHTED_AIRCRAFT; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
116 |
w->widget[BUILD_VEHICLE_WIDGET_RENAME].data = STR_A037_RENAME; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
117 |
w->widget[BUILD_VEHICLE_WIDGET_RENAME].tooltips = STR_A038_RENAME_AIRCRAFT_TYPE; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
118 |
break; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
119 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
120 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
121 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
122 |
static bool _internal_sort_order; // descending/ascending |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
123 |
|
6035
7c56c182a490
(svn r8336) -Codechange: added function to translate vehicle types to 0,1,2... for use for index to arrays
bjarni
parents:
6034
diff
changeset
|
124 |
static byte _last_sort_criteria[] = {0, 0, 0, 0}; |
7c56c182a490
(svn r8336) -Codechange: added function to translate vehicle types to 0,1,2... for use for index to arrays
bjarni
parents:
6034
diff
changeset
|
125 |
static bool _last_sort_order[] = {false, false, false, false}; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
126 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
127 |
static int CDECL EngineNumberSorter(const void *a, const void *b) |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
128 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
129 |
const EngineID va = *(const EngineID*)a; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
130 |
const EngineID vb = *(const EngineID*)b; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
131 |
int r = va - vb; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
132 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
133 |
return _internal_sort_order ? -r : r; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
134 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
135 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
136 |
static int CDECL EngineIntroDateSorter(const void *a, const void *b) |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
137 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
138 |
const int va = GetEngine(*(const EngineID*)a)->intro_date; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
139 |
const int vb = GetEngine(*(const EngineID*)b)->intro_date; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
140 |
const int r = va - vb; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
141 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
142 |
if (r == 0) { |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
143 |
/* Use EngineID to sort instead since we want consistent sorting */ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
144 |
return EngineNumberSorter(a, b); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
145 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
146 |
return _internal_sort_order ? -r : r; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
147 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
148 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
149 |
static int CDECL EngineNameSorter(const void *a, const void *b) |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
150 |
{ |
4804
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
151 |
static EngineID last_engine[2] = { INVALID_ENGINE, INVALID_ENGINE }; |
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
152 |
static char last_name[2][64] = { "\0", "\0" }; |
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
153 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
154 |
const EngineID va = *(const EngineID*)a; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
155 |
const EngineID vb = *(const EngineID*)b; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
156 |
int r; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
157 |
|
4804
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
158 |
if (va != last_engine[0]) { |
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
159 |
last_engine[0] = va; |
7555
e20900912fa2
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7505
diff
changeset
|
160 |
SetDParam(0, va); |
e20900912fa2
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7505
diff
changeset
|
161 |
GetString(last_name[0], STR_ENGINE_NAME, lastof(last_name[0])); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
162 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
163 |
|
4804
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
164 |
if (vb != last_engine[1]) { |
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
165 |
last_engine[1] = vb; |
7555
e20900912fa2
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7505
diff
changeset
|
166 |
SetDParam(0, vb); |
e20900912fa2
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7505
diff
changeset
|
167 |
GetString(last_name[1], STR_ENGINE_NAME, lastof(last_name[1])); |
4804
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
168 |
} |
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
169 |
|
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
170 |
r = strcmp(last_name[0], last_name[1]); // sort by name |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
171 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
172 |
if (r == 0) { |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
173 |
/* Use EngineID to sort instead since we want consistent sorting */ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
174 |
return EngineNumberSorter(a, b); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
175 |
} |
4804
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
176 |
return _internal_sort_order ? -r : r; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
177 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
178 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
179 |
static int CDECL EngineReliabilitySorter(const void *a, const void *b) |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
180 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
181 |
const int va = GetEngine(*(const EngineID*)a)->reliability; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
182 |
const int vb = GetEngine(*(const EngineID*)b)->reliability; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
183 |
const int r = va - vb; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
184 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
185 |
if (r == 0) { |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
186 |
/* Use EngineID to sort instead since we want consistent sorting */ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
187 |
return EngineNumberSorter(a, b); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
188 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
189 |
return _internal_sort_order ? -r : r; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
190 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
191 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
192 |
/* Train sorting functions */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
193 |
static int CDECL TrainEngineCostSorter(const void *a, const void *b) |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
194 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
195 |
int va = RailVehInfo(*(const EngineID*)a)->base_cost; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
196 |
int vb = RailVehInfo(*(const EngineID*)b)->base_cost; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
197 |
int r = va - vb; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
198 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
199 |
return _internal_sort_order ? -r : r; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
200 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
201 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
202 |
static int CDECL TrainEngineSpeedSorter(const void *a, const void *b) |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
203 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
204 |
int va = RailVehInfo(*(const EngineID*)a)->max_speed; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
205 |
int vb = RailVehInfo(*(const EngineID*)b)->max_speed; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
206 |
int r = va - vb; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
207 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
208 |
return _internal_sort_order ? -r : r; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
209 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
210 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
211 |
static int CDECL TrainEnginePowerSorter(const void *a, const void *b) |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
212 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
213 |
const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
214 |
const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
215 |
|
6119
b47985557d1e
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
6075
diff
changeset
|
216 |
int va = rvi_a->power << (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0); |
b47985557d1e
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
6075
diff
changeset
|
217 |
int vb = rvi_b->power << (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
218 |
int r = va - vb; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
219 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
220 |
return _internal_sort_order ? -r : r; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
221 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
222 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
223 |
static int CDECL TrainEngineRunningCostSorter(const void *a, const void *b) |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
224 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
225 |
const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
226 |
const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
227 |
|
7486
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7283
diff
changeset
|
228 |
Money va = rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class] * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1); |
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7283
diff
changeset
|
229 |
Money vb = rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class] * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1); |
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7283
diff
changeset
|
230 |
int r = ClampToI32(va - vb); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
231 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
232 |
return _internal_sort_order ? -r : r; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
233 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
234 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
235 |
static int CDECL TrainEnginePowerVsRunningCostSorter(const void *a, const void *b) |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
236 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
237 |
const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
238 |
const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
239 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
240 |
/* Here we are using a few tricks to get the right sort. |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
241 |
* We want power/running cost, but since we usually got higher running cost than power and we store the result in an int, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
242 |
* we will actually calculate cunning cost/power (to make it more than 1). |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
243 |
* Because of this, the return value have to be reversed as well and we return b - a instead of a - b. |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
244 |
* Another thing is that both power and running costs should be doubled for multiheaded engines. |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
245 |
* Since it would be multipling with 2 in both numerator and denumerator, it will even themselves out and we skip checking for multiheaded. */ |
8259
127e5d73637d
(svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
rubidium
parents:
8179
diff
changeset
|
246 |
Money va = (rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class]) / max(1U, (uint)rvi_a->power); |
127e5d73637d
(svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
rubidium
parents:
8179
diff
changeset
|
247 |
Money vb = (rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class]) / max(1U, (uint)rvi_b->power); |
7486
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7283
diff
changeset
|
248 |
int r = ClampToI32(vb - va); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
249 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
250 |
return _internal_sort_order ? -r : r; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
251 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
252 |
|
6349
c22327023623
(svn r8746) -Regression r8331: build train window could sort incorrectly by EngineID with certain newGRF sets
bjarni
parents:
6206
diff
changeset
|
253 |
static int CDECL TrainEngineNumberSorter(const void *a, const void *b) |
c22327023623
(svn r8746) -Regression r8331: build train window could sort incorrectly by EngineID with certain newGRF sets
bjarni
parents:
6206
diff
changeset
|
254 |
{ |
c22327023623
(svn r8746) -Regression r8331: build train window could sort incorrectly by EngineID with certain newGRF sets
bjarni
parents:
6206
diff
changeset
|
255 |
const EngineID va = *(const EngineID*)a; |
c22327023623
(svn r8746) -Regression r8331: build train window could sort incorrectly by EngineID with certain newGRF sets
bjarni
parents:
6206
diff
changeset
|
256 |
const EngineID vb = *(const EngineID*)b; |
c22327023623
(svn r8746) -Regression r8331: build train window could sort incorrectly by EngineID with certain newGRF sets
bjarni
parents:
6206
diff
changeset
|
257 |
int r = ListPositionOfEngine(va) - ListPositionOfEngine(vb); |
c22327023623
(svn r8746) -Regression r8331: build train window could sort incorrectly by EngineID with certain newGRF sets
bjarni
parents:
6206
diff
changeset
|
258 |
|
c22327023623
(svn r8746) -Regression r8331: build train window could sort incorrectly by EngineID with certain newGRF sets
bjarni
parents:
6206
diff
changeset
|
259 |
return _internal_sort_order ? -r : r; |
c22327023623
(svn r8746) -Regression r8331: build train window could sort incorrectly by EngineID with certain newGRF sets
bjarni
parents:
6206
diff
changeset
|
260 |
} |
c22327023623
(svn r8746) -Regression r8331: build train window could sort incorrectly by EngineID with certain newGRF sets
bjarni
parents:
6206
diff
changeset
|
261 |
|
7282
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
262 |
static int CDECL TrainEngineCapacitySorter(const void *a, const void *b) |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
263 |
{ |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
264 |
int va = RailVehInfo(*(const EngineID*)a)->capacity; |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
265 |
int vb = RailVehInfo(*(const EngineID*)b)->capacity; |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
266 |
int r = va - vb; |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
267 |
|
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
268 |
if (r == 0) { |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
269 |
/* Use EngineID to sort instead since we want consistent sorting */ |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
270 |
return EngineNumberSorter(a, b); |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
271 |
} |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
272 |
return _internal_sort_order ? -r : r; |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
273 |
} |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
274 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
275 |
static int CDECL TrainEnginesThenWagonsSorter(const void *a, const void *b) |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
276 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
277 |
EngineID va = *(const EngineID*)a; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
278 |
EngineID vb = *(const EngineID*)b; |
6122
33ce525e85ff
(svn r8460) -Fix (r8455): the build train window put locomotives and wagons in appeantly random order
bjarni
parents:
6119
diff
changeset
|
279 |
int val_a = (RailVehInfo(va)->railveh_type == RAILVEH_WAGON ? 1 : 0); |
33ce525e85ff
(svn r8460) -Fix (r8455): the build train window put locomotives and wagons in appeantly random order
bjarni
parents:
6119
diff
changeset
|
280 |
int val_b = (RailVehInfo(vb)->railveh_type == RAILVEH_WAGON ? 1 : 0); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
281 |
int r = val_a - val_b; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
282 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
283 |
/* Use EngineID to sort instead since we want consistent sorting */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
284 |
if (r == 0) return EngineNumberSorter(a, b); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
285 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
286 |
return _internal_sort_order ? -r : r; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
287 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
288 |
|
8644
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
289 |
/* Road vehicle sorting functions */ |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
290 |
static int CDECL RoadVehEngineCostSorter(const void *a, const void *b) |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
291 |
{ |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
292 |
int va = RoadVehInfo(*(const EngineID*)a)->base_cost; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
293 |
int vb = RoadVehInfo(*(const EngineID*)b)->base_cost; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
294 |
int r = va - vb; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
295 |
|
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
296 |
return _internal_sort_order ? -r : r; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
297 |
} |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
298 |
|
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
299 |
static int CDECL RoadVehEngineSpeedSorter(const void *a, const void *b) |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
300 |
{ |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
301 |
int va = RoadVehInfo(*(const EngineID*)a)->max_speed; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
302 |
int vb = RoadVehInfo(*(const EngineID*)b)->max_speed; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
303 |
int r = va - vb; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
304 |
|
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
305 |
return _internal_sort_order ? -r : r; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
306 |
} |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
307 |
|
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
308 |
static int CDECL RoadVehEngineRunningCostSorter(const void *a, const void *b) |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
309 |
{ |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
310 |
const int va = RoadVehInfo(*(const EngineID*)a)->running_cost; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
311 |
const int vb = RoadVehInfo(*(const EngineID*)b)->running_cost; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
312 |
const int r = va - vb; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
313 |
|
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
314 |
if (r == 0) { |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
315 |
/* Use EngineID to sort instead since we want consistent sorting */ |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
316 |
return EngineNumberSorter(a, b); |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
317 |
} |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
318 |
return _internal_sort_order ? -r : r; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
319 |
} |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
320 |
|
7282
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
321 |
static int CDECL RoadVehEngineCapacitySorter(const void *a, const void *b) |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
322 |
{ |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
323 |
int va = RoadVehInfo(*(const EngineID*)a)->capacity; |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
324 |
int vb = RoadVehInfo(*(const EngineID*)b)->capacity; |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
325 |
int r = va - vb; |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
326 |
|
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
327 |
if (r == 0) { |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
328 |
/* Use EngineID to sort instead since we want consistent sorting */ |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
329 |
return EngineNumberSorter(a, b); |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
330 |
} |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
331 |
return _internal_sort_order ? -r : r; |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
332 |
} |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
333 |
|
8644
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
334 |
/* Road vehicle sorting functions */ |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
335 |
static int CDECL ShipEngineCostSorter(const void *a, const void *b) |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
336 |
{ |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
337 |
int va = ShipVehInfo(*(const EngineID*)a)->base_cost; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
338 |
int vb = ShipVehInfo(*(const EngineID*)b)->base_cost; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
339 |
int r = va - vb; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
340 |
|
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
341 |
return _internal_sort_order ? -r : r; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
342 |
} |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
343 |
|
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
344 |
static int CDECL ShipEngineSpeedSorter(const void *a, const void *b) |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
345 |
{ |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
346 |
int va = ShipVehInfo(*(const EngineID*)a)->max_speed; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
347 |
int vb = ShipVehInfo(*(const EngineID*)b)->max_speed; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
348 |
int r = va - vb; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
349 |
|
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
350 |
return _internal_sort_order ? -r : r; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
351 |
} |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
352 |
|
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
353 |
static int CDECL ShipEngineRunningCostSorter(const void *a, const void *b) |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
354 |
{ |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
355 |
const int va = ShipVehInfo(*(const EngineID*)a)->running_cost; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
356 |
const int vb = ShipVehInfo(*(const EngineID*)b)->running_cost; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
357 |
const int r = va - vb; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
358 |
|
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
359 |
if (r == 0) { |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
360 |
/* Use EngineID to sort instead since we want consistent sorting */ |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
361 |
return EngineNumberSorter(a, b); |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
362 |
} |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
363 |
return _internal_sort_order ? -r : r; |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
364 |
} |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
365 |
|
7282
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
366 |
static int CDECL ShipEngineCapacitySorter(const void *a, const void *b) |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
367 |
{ |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
368 |
int va = ShipVehInfo(*(const EngineID*)a)->capacity; |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
369 |
int vb = ShipVehInfo(*(const EngineID*)b)->capacity; |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
370 |
int r = va - vb; |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
371 |
|
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
372 |
if (r == 0) { |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
373 |
/* Use EngineID to sort instead since we want consistent sorting */ |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
374 |
return EngineNumberSorter(a, b); |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
375 |
} |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
376 |
return _internal_sort_order ? -r : r; |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
377 |
} |
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
378 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
379 |
/* Aircraft sorting functions */ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
380 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
381 |
static int CDECL AircraftEngineCostSorter(const void *a, const void *b) |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
382 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
383 |
const int va = AircraftVehInfo(*(const EngineID*)a)->base_cost; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
384 |
const int vb = AircraftVehInfo(*(const EngineID*)b)->base_cost; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
385 |
int r = va - vb; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
386 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
387 |
return _internal_sort_order ? -r : r; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
388 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
389 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
390 |
static int CDECL AircraftEngineSpeedSorter(const void *a, const void *b) |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
391 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
392 |
const int va = AircraftVehInfo(*(const EngineID*)a)->max_speed; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
393 |
const int vb = AircraftVehInfo(*(const EngineID*)b)->max_speed; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
394 |
const int r = va - vb; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
395 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
396 |
if (r == 0) { |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
397 |
/* Use EngineID to sort instead since we want consistent sorting */ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
398 |
return EngineNumberSorter(a, b); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
399 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
400 |
return _internal_sort_order ? -r : r; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
401 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
402 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
403 |
static int CDECL AircraftEngineRunningCostSorter(const void *a, const void *b) |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
404 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
405 |
const int va = AircraftVehInfo(*(const EngineID*)a)->running_cost; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
406 |
const int vb = AircraftVehInfo(*(const EngineID*)b)->running_cost; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
407 |
const int r = va - vb; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
408 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
409 |
if (r == 0) { |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
410 |
/* Use EngineID to sort instead since we want consistent sorting */ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
411 |
return EngineNumberSorter(a, b); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
412 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
413 |
return _internal_sort_order ? -r : r; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
414 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
415 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
416 |
static int CDECL AircraftEngineCargoSorter(const void *a, const void *b) |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
417 |
{ |
7283
3f3b3828b412
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
7282
diff
changeset
|
418 |
int va = AircraftVehInfo(*(const EngineID*)a)->passenger_capacity; |
3f3b3828b412
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
7282
diff
changeset
|
419 |
int vb = AircraftVehInfo(*(const EngineID*)b)->passenger_capacity; |
3f3b3828b412
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
7282
diff
changeset
|
420 |
int r = va - vb; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
421 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
422 |
if (r == 0) { |
7283
3f3b3828b412
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
7282
diff
changeset
|
423 |
/* The planes has the same passenger capacity. Check mail capacity instead */ |
3f3b3828b412
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
7282
diff
changeset
|
424 |
va = AircraftVehInfo(*(const EngineID*)a)->mail_capacity; |
3f3b3828b412
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
7282
diff
changeset
|
425 |
vb = AircraftVehInfo(*(const EngineID*)b)->mail_capacity; |
3f3b3828b412
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
7282
diff
changeset
|
426 |
r = va - vb; |
3f3b3828b412
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
7282
diff
changeset
|
427 |
|
3f3b3828b412
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
7282
diff
changeset
|
428 |
if (r == 0) { |
3f3b3828b412
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
7282
diff
changeset
|
429 |
/* Use EngineID to sort instead since we want consistent sorting */ |
3f3b3828b412
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
7282
diff
changeset
|
430 |
return EngineNumberSorter(a, b); |
3f3b3828b412
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
7282
diff
changeset
|
431 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
432 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
433 |
return _internal_sort_order ? -r : r; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
434 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
435 |
|
7282
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
436 |
static EngList_SortTypeFunction * const _sorter[][10] = {{ |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
437 |
/* Trains */ |
6349
c22327023623
(svn r8746) -Regression r8331: build train window could sort incorrectly by EngineID with certain newGRF sets
bjarni
parents:
6206
diff
changeset
|
438 |
&TrainEngineNumberSorter, |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
439 |
&TrainEngineCostSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
440 |
&TrainEngineSpeedSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
441 |
&TrainEnginePowerSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
442 |
&EngineIntroDateSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
443 |
&EngineNameSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
444 |
&TrainEngineRunningCostSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
445 |
&TrainEnginePowerVsRunningCostSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
446 |
&EngineReliabilitySorter, |
7282
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
447 |
&TrainEngineCapacitySorter, |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6712
diff
changeset
|
448 |
}, { |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
449 |
/* Road vehicles */ |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
450 |
&EngineNumberSorter, |
8644
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
451 |
&RoadVehEngineCostSorter, |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
452 |
&RoadVehEngineSpeedSorter, |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
453 |
&EngineIntroDateSorter, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
454 |
&EngineNameSorter, |
8644
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
455 |
&RoadVehEngineRunningCostSorter, |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
456 |
&EngineReliabilitySorter, |
7282
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
457 |
&RoadVehEngineCapacitySorter, |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6712
diff
changeset
|
458 |
}, { |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
459 |
/* Ships */ |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
460 |
&EngineNumberSorter, |
8644
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
461 |
&ShipEngineCostSorter, |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
462 |
&ShipEngineSpeedSorter, |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
463 |
&EngineIntroDateSorter, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
464 |
&EngineNameSorter, |
8644
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
465 |
&ShipEngineRunningCostSorter, |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
466 |
&EngineReliabilitySorter, |
7282
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
467 |
&ShipEngineCapacitySorter, |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6712
diff
changeset
|
468 |
}, { |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
469 |
/* Aircraft */ |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
470 |
&EngineNumberSorter, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
471 |
&AircraftEngineCostSorter, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
472 |
&AircraftEngineSpeedSorter, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
473 |
&EngineIntroDateSorter, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
474 |
&EngineNameSorter, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
475 |
&AircraftEngineRunningCostSorter, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
476 |
&EngineReliabilitySorter, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
477 |
&AircraftEngineCargoSorter, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
478 |
}}; |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
479 |
|
7282
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
480 |
static const StringID _sort_listing[][11] = {{ |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
481 |
/* Trains */ |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
482 |
STR_ENGINE_SORT_ENGINE_ID, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
483 |
STR_ENGINE_SORT_COST, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
484 |
STR_SORT_BY_MAX_SPEED, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
485 |
STR_ENGINE_SORT_POWER, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
486 |
STR_ENGINE_SORT_INTRO_DATE, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
487 |
STR_SORT_BY_DROPDOWN_NAME, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
488 |
STR_ENGINE_SORT_RUNNING_COST, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
489 |
STR_ENGINE_SORT_POWER_VS_RUNNING_COST, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
490 |
STR_SORT_BY_RELIABILITY, |
7282
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
491 |
STR_ENGINE_SORT_CARGO_CAPACITY, |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
492 |
INVALID_STRING_ID |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6712
diff
changeset
|
493 |
}, { |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
494 |
/* Road vehicles */ |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
495 |
STR_ENGINE_SORT_ENGINE_ID, |
8644
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
496 |
STR_ENGINE_SORT_COST, |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
497 |
STR_SORT_BY_MAX_SPEED, |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
498 |
STR_ENGINE_SORT_INTRO_DATE, |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
499 |
STR_SORT_BY_DROPDOWN_NAME, |
8644
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
500 |
STR_ENGINE_SORT_RUNNING_COST, |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
501 |
STR_SORT_BY_RELIABILITY, |
7282
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
502 |
STR_ENGINE_SORT_CARGO_CAPACITY, |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
503 |
INVALID_STRING_ID |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6712
diff
changeset
|
504 |
}, { |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
505 |
/* Ships */ |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
506 |
STR_ENGINE_SORT_ENGINE_ID, |
8644
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
507 |
STR_ENGINE_SORT_COST, |
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
508 |
STR_SORT_BY_MAX_SPEED, |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
509 |
STR_ENGINE_SORT_INTRO_DATE, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
510 |
STR_SORT_BY_DROPDOWN_NAME, |
8644
7c12bf33e220
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8640
diff
changeset
|
511 |
STR_ENGINE_SORT_RUNNING_COST, |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
512 |
STR_SORT_BY_RELIABILITY, |
7282
e8bb56823496
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
7268
diff
changeset
|
513 |
STR_ENGINE_SORT_CARGO_CAPACITY, |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
514 |
INVALID_STRING_ID |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6712
diff
changeset
|
515 |
}, { |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
516 |
/* Aircraft */ |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
517 |
STR_ENGINE_SORT_ENGINE_ID, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
518 |
STR_ENGINE_SORT_COST, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
519 |
STR_SORT_BY_MAX_SPEED, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
520 |
STR_ENGINE_SORT_INTRO_DATE, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
521 |
STR_SORT_BY_DROPDOWN_NAME, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
522 |
STR_ENGINE_SORT_RUNNING_COST, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
523 |
STR_SORT_BY_RELIABILITY, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
524 |
STR_ENGINE_SORT_CARGO_CAPACITY, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
525 |
INVALID_STRING_ID |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
526 |
}}; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
527 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
528 |
/* Draw rail wagon specific details */ |
6068
286d4dfa1d39
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
6067
diff
changeset
|
529 |
static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi) |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
530 |
{ |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
531 |
/* Purchase cost */ |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7487
diff
changeset
|
532 |
SetDParam(0, (GetEngineProperty(engine_number, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
533 |
DrawString(x, y, STR_PURCHASE_INFO_COST, TC_FROMSTRING); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
534 |
y += 10; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
535 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
536 |
/* Wagon weight - (including cargo) */ |
7091
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
537 |
uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight); |
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
538 |
SetDParam(0, weight); |
7104
59f24cd8470b
(svn r9828) -Codechange: [NewGRF] Add support for changing cargo capacity with callback 36. This is set on construction for ships and roadvehicles, and whenever carriages are attached for trains.
peter1138
parents:
7091
diff
changeset
|
539 |
SetDParam(1, (GetCargo(rvi->cargo_type)->weight * GetEngineProperty(engine_number, 0x14, rvi->capacity) >> 4) + weight); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
540 |
DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, TC_FROMSTRING); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
541 |
y += 10; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
542 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
543 |
/* Wagon speed limit, displayed if above zero */ |
7091
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
544 |
if (_patches.wagon_speed_limits) { |
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
545 |
uint max_speed = GetEngineProperty(engine_number, 0x09, rvi->max_speed); |
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
546 |
if (max_speed > 0) { |
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
547 |
SetDParam(0, max_speed * 10 / 16); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
548 |
DrawString(x, y, STR_PURCHASE_INFO_SPEED, TC_FROMSTRING); |
7091
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
549 |
y += 10; |
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
550 |
} |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
551 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
552 |
return y; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
553 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
554 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
555 |
/* Draw locomotive specific details */ |
6074 | 556 |
static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi) |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
557 |
{ |
6119
b47985557d1e
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
6075
diff
changeset
|
558 |
int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0); |
7091
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
559 |
uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
560 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
561 |
/* Purchase Cost - Engine weight */ |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7487
diff
changeset
|
562 |
SetDParam(0, GetEngineProperty(engine_number, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5); |
7091
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
563 |
SetDParam(1, weight << multihead); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
564 |
DrawString(x, y, STR_PURCHASE_INFO_COST_WEIGHT, TC_FROMSTRING); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
565 |
y += 10; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
566 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
567 |
/* Max speed - Engine power */ |
7091
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
568 |
SetDParam(0, GetEngineProperty(engine_number, 0x09, rvi->max_speed) * 10 / 16); |
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
569 |
SetDParam(1, GetEngineProperty(engine_number, 0x0B, rvi->power) << multihead); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
570 |
DrawString(x, y, STR_PURCHASE_INFO_SPEED_POWER, TC_FROMSTRING); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
571 |
y += 10; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
572 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
573 |
/* Max tractive effort - not applicable if old acceleration or maglev */ |
6074 | 574 |
if (_patches.realistic_acceleration && rvi->railtype != RAILTYPE_MAGLEV) { |
7091
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
575 |
SetDParam(0, ((weight << multihead) * 10 * GetEngineProperty(engine_number, 0x1F, rvi->tractive_effort)) / 256); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
576 |
DrawString(x, y, STR_PURCHASE_INFO_MAX_TE, TC_FROMSTRING); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
577 |
y += 10; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
578 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
579 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
580 |
/* Running cost */ |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7487
diff
changeset
|
581 |
SetDParam(0, (GetEngineProperty(engine_number, 0x0D, rvi->running_cost_base) * _price.running_rail[rvi->running_cost_class] >> 8) << multihead); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
582 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
583 |
y += 10; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
584 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
585 |
/* Powered wagons power - Powered wagons extra weight */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
586 |
if (rvi->pow_wag_power != 0) { |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
587 |
SetDParam(0, rvi->pow_wag_power); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
588 |
SetDParam(1, rvi->pow_wag_weight); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
589 |
DrawString(x, y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT, TC_FROMSTRING); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
590 |
y += 10; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
591 |
}; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
592 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
593 |
return y; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
594 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
595 |
|
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
596 |
/* Draw road vehicle specific details */ |
6068
286d4dfa1d39
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
6067
diff
changeset
|
597 |
static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const RoadVehicleInfo *rvi) |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
598 |
{ |
7769
33ec8ba894ef
(svn r10603) -Codechange: avoid direct access to _engine_info
peter1138
parents:
7754
diff
changeset
|
599 |
bool refittable = (EngInfo(engine_number)->refit_mask != 0); |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
600 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
601 |
/* Purchase cost - Max speed */ |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7487
diff
changeset
|
602 |
SetDParam(0, GetEngineProperty(engine_number, 0x11, rvi->base_cost) * (_price.roadveh_base >> 3) >> 5); |
6125
492a1c0440af
(svn r8464) -Revert (r4322): Change back to converting to mph in the GUI code, as 1 mph == 1.6 km/h is too far out for some people.
peter1138
parents:
6122
diff
changeset
|
603 |
SetDParam(1, rvi->max_speed * 10 / 32); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
604 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING); |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
605 |
y += 10; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
606 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
607 |
/* Running cost */ |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7487
diff
changeset
|
608 |
SetDParam(0, rvi->running_cost * _price.roadveh_running >> 8); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
609 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING); |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
610 |
y += 10; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
611 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
612 |
/* Cargo type + capacity */ |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
613 |
SetDParam(0, rvi->cargo_type); |
7104
59f24cd8470b
(svn r9828) -Codechange: [NewGRF] Add support for changing cargo capacity with callback 36. This is set on construction for ships and roadvehicles, and whenever carriages are attached for trains.
peter1138
parents:
7091
diff
changeset
|
614 |
SetDParam(1, GetEngineProperty(engine_number, 0x0F, rvi->capacity)); |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
615 |
SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
616 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING); |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
617 |
y += 10; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
618 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
619 |
return y; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
620 |
} |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
621 |
|
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
622 |
/* Draw ship specific details */ |
6068
286d4dfa1d39
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
6067
diff
changeset
|
623 |
static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi) |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
624 |
{ |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
625 |
/* Purchase cost - Max speed */ |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7487
diff
changeset
|
626 |
SetDParam(0, GetEngineProperty(engine_number, 0x0A, svi->base_cost) * (_price.ship_base >> 3) >> 5); |
7091
ebc570e995c4
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
7088
diff
changeset
|
627 |
SetDParam(1, GetEngineProperty(engine_number, 0x0B, svi->max_speed) * 10 / 32); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
628 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING); |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
629 |
y += 10; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
630 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
631 |
/* Cargo type + capacity */ |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
632 |
SetDParam(0, svi->cargo_type); |
7104
59f24cd8470b
(svn r9828) -Codechange: [NewGRF] Add support for changing cargo capacity with callback 36. This is set on construction for ships and roadvehicles, and whenever carriages are attached for trains.
peter1138
parents:
7091
diff
changeset
|
633 |
SetDParam(1, GetEngineProperty(engine_number, 0x0D, svi->capacity)); |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
634 |
SetDParam(2, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
635 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING); |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
636 |
y += 10; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
637 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
638 |
/* Running cost */ |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7487
diff
changeset
|
639 |
SetDParam(0, GetEngineProperty(engine_number, 0x0F, svi->running_cost) * _price.ship_running >> 8); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
640 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING); |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
641 |
y += 10; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
642 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
643 |
return y; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
644 |
} |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
645 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
646 |
/* Draw aircraft specific details */ |
6068
286d4dfa1d39
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
6067
diff
changeset
|
647 |
static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const AircraftVehicleInfo *avi) |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
648 |
{ |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
649 |
CargoID cargo; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
650 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
651 |
/* Purchase cost - Max speed */ |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7487
diff
changeset
|
652 |
SetDParam(0, GetEngineProperty(engine_number, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5); |
6519
367d6f96e23f
(svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar
parents:
6449
diff
changeset
|
653 |
SetDParam(1, avi->max_speed * 10 / 16); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
654 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
655 |
y += 10; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
656 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
657 |
/* Cargo capacity */ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
658 |
cargo = FindFirstRefittableCargo(engine_number); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
659 |
if (cargo == CT_INVALID || cargo == CT_PASSENGERS) { |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
660 |
SetDParam(0, avi->passenger_capacity); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
661 |
SetDParam(1, avi->mail_capacity); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
662 |
DrawString(x, y, STR_PURCHASE_INFO_AIRCRAFT_CAPACITY, TC_FROMSTRING); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
663 |
} else { |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
664 |
/* Note, if the default capacity is selected by the refit capacity |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
665 |
* callback, then the capacity shown is likely to be incorrect. */ |
4896
72d7a8614580
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4807
diff
changeset
|
666 |
SetDParam(0, cargo); |
6413 | 667 |
SetDParam(1, AircraftDefaultCargoCapacity(cargo, avi)); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
668 |
SetDParam(2, STR_9842_REFITTABLE); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
669 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
670 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
671 |
y += 10; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
672 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
673 |
/* Running cost */ |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7487
diff
changeset
|
674 |
SetDParam(0, GetEngineProperty(engine_number, 0x0E, avi->running_cost) * _price.aircraft_running >> 8); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
675 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
676 |
y += 10; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
677 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
678 |
return y; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
679 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
680 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
681 |
/** |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
682 |
* Draw the purchase info details of a vehicle at a given location. |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
683 |
* @param x,y location where to draw the info |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
684 |
* @param w how wide are the text allowed to be (size of widget/window to Draw in) |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
685 |
* @param engine_number the engine of which to draw the info of |
6711
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
686 |
* @return y after drawing all the text |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
687 |
*/ |
6711
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
688 |
int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number) |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
689 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
690 |
const Engine *e = GetEngine(engine_number); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
691 |
YearMonthDay ymd; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
692 |
ConvertDateToYMD(e->intro_date, &ymd); |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
693 |
bool refitable = false; |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
694 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
695 |
switch (e->type) { |
7134
c5a90dd41166
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents:
7104
diff
changeset
|
696 |
default: NOT_REACHED(); |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
697 |
case VEH_TRAIN: { |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
698 |
const RailVehicleInfo *rvi = RailVehInfo(engine_number); |
7104
59f24cd8470b
(svn r9828) -Codechange: [NewGRF] Add support for changing cargo capacity with callback 36. This is set on construction for ships and roadvehicles, and whenever carriages are attached for trains.
peter1138
parents:
7091
diff
changeset
|
699 |
uint capacity = GetEngineProperty(engine_number, 0x14, rvi->capacity); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
700 |
|
7104
59f24cd8470b
(svn r9828) -Codechange: [NewGRF] Add support for changing cargo capacity with callback 36. This is set on construction for ships and roadvehicles, and whenever carriages are attached for trains.
peter1138
parents:
7091
diff
changeset
|
701 |
refitable = (EngInfo(engine_number)->refit_mask != 0) && (capacity > 0); |
6070
e5a6d7b94c63
(svn r8381) -Fix (r8377): [build vehicle window] cleaned up the train refitable detection. It had two variables doing the same thing, but not always set to the same (oops)
bjarni
parents:
6068
diff
changeset
|
702 |
|
6119
b47985557d1e
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
6075
diff
changeset
|
703 |
if (rvi->railveh_type == RAILVEH_WAGON) { |
6068
286d4dfa1d39
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
6067
diff
changeset
|
704 |
y = DrawRailWagonPurchaseInfo(x, y, engine_number, rvi); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
705 |
} else { |
6074 | 706 |
y = DrawRailEnginePurchaseInfo(x, y, engine_number, rvi); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
707 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
708 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
709 |
/* Cargo type + capacity, or N/A */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
710 |
if (rvi->capacity == 0) { |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
711 |
SetDParam(0, CT_INVALID); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
712 |
SetDParam(2, STR_EMPTY); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
713 |
} else { |
6119
b47985557d1e
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
6075
diff
changeset
|
714 |
int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0); |
6066
917bc7592745
(svn r8377) -Fix (r8331): [build vehicle window] train cargo capacity now only add "(refitable)" if the engine in question is refitable
bjarni
parents:
6053
diff
changeset
|
715 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
716 |
SetDParam(0, rvi->cargo_type); |
8091
f24d360b6ba1
(svn r11122) -Fix [FS#1234]: crash when building a NewGRF vehicle when the articulated build vehicle callback returneed a different value for the purchase window than the normal build. Thanks for Dalestan and _minime_ for pointers to possible causes.
rubidium
parents:
7977
diff
changeset
|
717 |
SetDParam(1, (capacity * (CountArticulatedParts(engine_number, true) + 1)) << multihead); |
6070
e5a6d7b94c63
(svn r8381) -Fix (r8377): [build vehicle window] cleaned up the train refitable detection. It had two variables doing the same thing, but not always set to the same (oops)
bjarni
parents:
6068
diff
changeset
|
718 |
SetDParam(2, refitable ? STR_9842_REFITTABLE : STR_EMPTY); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
719 |
} |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
720 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
721 |
y += 10; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
722 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
723 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
724 |
case VEH_ROAD: |
6068
286d4dfa1d39
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
6067
diff
changeset
|
725 |
y = DrawRoadVehPurchaseInfo(x, y, engine_number, RoadVehInfo(engine_number)); |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
726 |
refitable = true; |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
727 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
728 |
case VEH_SHIP: { |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
729 |
const ShipVehicleInfo *svi = ShipVehInfo(engine_number); |
6068
286d4dfa1d39
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
6067
diff
changeset
|
730 |
y = DrawShipPurchaseInfo(x, y, engine_number, svi); |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
731 |
refitable = svi->refittable; |
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
732 |
} break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
733 |
case VEH_AIRCRAFT: |
6068
286d4dfa1d39
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
6067
diff
changeset
|
734 |
y = DrawAircraftPurchaseInfo(x, y, engine_number, AircraftVehInfo(engine_number)); |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
735 |
refitable = true; |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
736 |
break; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
737 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
738 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
739 |
/* Draw details, that applies to all types except rail wagons */ |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
740 |
if (e->type != VEH_TRAIN || RailVehInfo(engine_number)->railveh_type != RAILVEH_WAGON) { |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
741 |
/* Design date - Life length */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
742 |
SetDParam(0, ymd.year); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
743 |
SetDParam(1, e->lifelength); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
744 |
DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, TC_FROMSTRING); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
745 |
y += 10; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
746 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
747 |
/* Reliability */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
748 |
SetDParam(0, e->reliability * 100 >> 16); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
749 |
DrawString(x, y, STR_PURCHASE_INFO_RELIABILITY, TC_FROMSTRING); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
750 |
y += 10; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
751 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
752 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
753 |
/* Additional text from NewGRF */ |
4930
fd91a88d6ef6
(svn r6910) - Codechange: Supply width of area when drawing purchase info instead of using hardcoded values. (mart3p)
peter1138
parents:
4912
diff
changeset
|
754 |
y += ShowAdditionalText(x, y, w, engine_number); |
6041
c1c8b674d756
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
6038
diff
changeset
|
755 |
if (refitable) y += ShowRefitOptionsList(x, y, w, engine_number); |
6711
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
756 |
|
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
757 |
return y; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
758 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
759 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
760 |
/* Figure out what train EngineIDs to put in the list */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
761 |
static void GenerateBuildTrainList(Window *w) |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
762 |
{ |
8714
8a87b6988514
(svn r11781) -Codechange: variable scope and initialization
peter1138
parents:
8707
diff
changeset
|
763 |
EngineID sel_id = INVALID_ENGINE; |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
764 |
int num_engines = 0; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
765 |
int num_wagons = 0; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
766 |
buildvehicle_d *bv = &WP(w, buildvehicle_d); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
767 |
|
7747
71faad59535b
(svn r10552) -Fix [FS#1034, r10546]: opening Available Aircrafts segfaulted
truelight
parents:
7742
diff
changeset
|
768 |
bv->filter.railtype = (w->window_number <= VEH_END) ? RAILTYPE_END : GetRailType(w->window_number); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
769 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
770 |
EngList_RemoveAll(&bv->eng_list); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
771 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
772 |
/* Make list of all available train engines and wagons. |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6417
diff
changeset
|
773 |
* Also check to see if the previously selected engine is still available, |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6417
diff
changeset
|
774 |
* and if not, reset selection to INVALID_ENGINE. This could be the case |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6417
diff
changeset
|
775 |
* when engines become obsolete and are removed */ |
8714
8a87b6988514
(svn r11781) -Codechange: variable scope and initialization
peter1138
parents:
8707
diff
changeset
|
776 |
for (EngineID eid = 0; eid < NUM_TRAIN_ENGINES; eid++) { |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
777 |
const RailVehicleInfo *rvi = RailVehInfo(eid); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
778 |
|
6074 | 779 |
if (bv->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, bv->filter.railtype)) continue; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
780 |
if (!IsEngineBuildable(eid, VEH_TRAIN, _local_player)) continue; |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
781 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
782 |
EngList_Add(&bv->eng_list, eid); |
6119
b47985557d1e
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
6075
diff
changeset
|
783 |
if (rvi->railveh_type != RAILVEH_WAGON) { |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
784 |
num_engines++; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
785 |
} else { |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
786 |
num_wagons++; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
787 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
788 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
789 |
if (eid == bv->sel_engine) sel_id = eid; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
790 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
791 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
792 |
bv->sel_engine = sel_id; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
793 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6417
diff
changeset
|
794 |
/* make engines first, and then wagons, sorted by ListPositionOfEngine() */ |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
795 |
_internal_sort_order = false; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
796 |
EngList_Sort(&bv->eng_list, TrainEnginesThenWagonsSorter); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
797 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6417
diff
changeset
|
798 |
/* and then sort engines */ |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
799 |
_internal_sort_order = bv->descending_sort_order; |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
800 |
EngList_SortPartial(&bv->eng_list, _sorter[0][bv->sort_criteria], 0, num_engines); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
801 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6417
diff
changeset
|
802 |
/* and finally sort wagons */ |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
803 |
EngList_SortPartial(&bv->eng_list, _sorter[0][bv->sort_criteria], num_engines, num_wagons); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
804 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
805 |
|
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
806 |
/* Figure out what road vehicle EngineIDs to put in the list */ |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
807 |
static void GenerateBuildRoadVehList(Window *w) |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
808 |
{ |
8714
8a87b6988514
(svn r11781) -Codechange: variable scope and initialization
peter1138
parents:
8707
diff
changeset
|
809 |
EngineID sel_id = INVALID_ENGINE; |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
810 |
buildvehicle_d *bv = &WP(w, buildvehicle_d); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
811 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
812 |
EngList_RemoveAll(&bv->eng_list); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
813 |
|
8714
8a87b6988514
(svn r11781) -Codechange: variable scope and initialization
peter1138
parents:
8707
diff
changeset
|
814 |
for (EngineID eid = ROAD_ENGINES_INDEX; eid < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; eid++) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
815 |
if (!IsEngineBuildable(eid, VEH_ROAD, _local_player)) continue; |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8320
diff
changeset
|
816 |
if (!HasBit(bv->filter.roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue; |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
817 |
EngList_Add(&bv->eng_list, eid); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
818 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
819 |
if (eid == bv->sel_engine) sel_id = eid; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
820 |
} |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
821 |
bv->sel_engine = sel_id; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
822 |
} |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
823 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
824 |
/* Figure out what ship EngineIDs to put in the list */ |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
825 |
static void GenerateBuildShipList(Window *w) |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
826 |
{ |
8714
8a87b6988514
(svn r11781) -Codechange: variable scope and initialization
peter1138
parents:
8707
diff
changeset
|
827 |
EngineID sel_id = INVALID_ENGINE; |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
828 |
buildvehicle_d *bv = &WP(w, buildvehicle_d); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
829 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
830 |
EngList_RemoveAll(&bv->eng_list); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
831 |
|
8714
8a87b6988514
(svn r11781) -Codechange: variable scope and initialization
peter1138
parents:
8707
diff
changeset
|
832 |
for (EngineID eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
833 |
if (!IsEngineBuildable(eid, VEH_SHIP, _local_player)) continue; |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
834 |
EngList_Add(&bv->eng_list, eid); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
835 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
836 |
if (eid == bv->sel_engine) sel_id = eid; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
837 |
} |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
838 |
bv->sel_engine = sel_id; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
839 |
} |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
840 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
841 |
/* Figure out what aircraft EngineIDs to put in the list */ |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
842 |
static void GenerateBuildAircraftList(Window *w) |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
843 |
{ |
8714
8a87b6988514
(svn r11781) -Codechange: variable scope and initialization
peter1138
parents:
8707
diff
changeset
|
844 |
EngineID sel_id = INVALID_ENGINE; |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
845 |
buildvehicle_d *bv = &WP(w, buildvehicle_d); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
846 |
|
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
847 |
EngList_RemoveAll(&bv->eng_list); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
848 |
|
5200
603e30641448
(svn r7315) -Fix: Have the first engine in the list be selected once again when the window is opened
Darkvater
parents:
5199
diff
changeset
|
849 |
/* Make list of all available planes. |
603e30641448
(svn r7315) -Fix: Have the first engine in the list be selected once again when the window is opened
Darkvater
parents:
5199
diff
changeset
|
850 |
* Also check to see if the previously selected plane is still available, |
603e30641448
(svn r7315) -Fix: Have the first engine in the list be selected once again when the window is opened
Darkvater
parents:
5199
diff
changeset
|
851 |
* and if not, reset selection to INVALID_ENGINE. This could be the case |
603e30641448
(svn r7315) -Fix: Have the first engine in the list be selected once again when the window is opened
Darkvater
parents:
5199
diff
changeset
|
852 |
* when planes become obsolete and are removed */ |
8714
8a87b6988514
(svn r11781) -Codechange: variable scope and initialization
peter1138
parents:
8707
diff
changeset
|
853 |
for (EngineID eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
854 |
if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) continue; |
7747
71faad59535b
(svn r10552) -Fix [FS#1034, r10546]: opening Available Aircrafts segfaulted
truelight
parents:
7742
diff
changeset
|
855 |
/* First VEH_END window_numbers are fake to allow a window open for all different types at once */ |
8179
1fa8cc3fbeb8
(svn r11214) -Fix [FS#1296]: planes can't use heliports so refuse these orders
glx
parents:
8091
diff
changeset
|
856 |
if (w->window_number > VEH_END && !CanAircraftUseStation(eid, w->window_number)) continue; |
6370
c0266faf1722
(svn r8771) -Fix r8343: build aircraft windows will no longer show aircraft that can't use the airport in question
bjarni
parents:
6358
diff
changeset
|
857 |
|
6563
d08d813ecd42
(svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents:
6519
diff
changeset
|
858 |
EngList_Add(&bv->eng_list, eid); |
d08d813ecd42
(svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents:
6519
diff
changeset
|
859 |
if (eid == bv->sel_engine) sel_id = eid; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
860 |
} |
5200
603e30641448
(svn r7315) -Fix: Have the first engine in the list be selected once again when the window is opened
Darkvater
parents:
5199
diff
changeset
|
861 |
|
603e30641448
(svn r7315) -Fix: Have the first engine in the list be selected once again when the window is opened
Darkvater
parents:
5199
diff
changeset
|
862 |
bv->sel_engine = sel_id; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
863 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
864 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
865 |
/* Generate the list of vehicles */ |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
866 |
static void GenerateBuildList(Window *w) |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
867 |
{ |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
868 |
buildvehicle_d *bv = &WP(w, buildvehicle_d); |
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
869 |
|
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
870 |
switch (bv->vehicle_type) { |
7134
c5a90dd41166
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents:
7104
diff
changeset
|
871 |
default: NOT_REACHED(); |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
872 |
case VEH_TRAIN: |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
873 |
GenerateBuildTrainList(w); |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
874 |
return; // trains should not reach the last sorting |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
875 |
case VEH_ROAD: |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
876 |
GenerateBuildRoadVehList(w); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
877 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
878 |
case VEH_SHIP: |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
879 |
GenerateBuildShipList(w); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
880 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
881 |
case VEH_AIRCRAFT: |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
882 |
GenerateBuildAircraftList(w); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
883 |
break; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
884 |
} |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
885 |
_internal_sort_order = bv->descending_sort_order; |
6206
67358999d80d
(svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents:
6195
diff
changeset
|
886 |
EngList_Sort(&bv->eng_list, _sorter[bv->vehicle_type][bv->sort_criteria]); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
887 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
888 |
|
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
889 |
static void DrawVehicleEngine(byte type, int x, int y, EngineID engine, SpriteID pal) |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
890 |
{ |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
891 |
switch (type) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
892 |
case VEH_TRAIN: DrawTrainEngine( x, y, engine, pal); break; |
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
893 |
case VEH_ROAD: DrawRoadVehEngine( x, y, engine, pal); break; |
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
894 |
case VEH_SHIP: DrawShipEngine( x, y, engine, pal); break; |
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
895 |
case VEH_AIRCRAFT: DrawAircraftEngine(x, y, engine, pal); break; |
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
896 |
default: NOT_REACHED(); |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
897 |
} |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
898 |
} |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
899 |
|
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
900 |
/** Engine drawing loop |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
901 |
* @param type Type of vehicle (VEH_*) |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
902 |
* @param x,y Where should the list start |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
903 |
* @param eng_list What engines to draw |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
904 |
* @param min where to start in the list |
6053
bec24ee21ccb
(svn r8364) -Codechange (r8362): added an assert to catch conditions where a request wants to draw more vehicles than the list contains
bjarni
parents:
6051
diff
changeset
|
905 |
* @param max where in the list to end |
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
906 |
* @param selected_id what engine to highlight as selected, if any |
6195
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6144
diff
changeset
|
907 |
* @param show_count Display the number of vehicles (used by autoreplace) |
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
908 |
*/ |
7139
4ae3ab180d05
(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:
7134
diff
changeset
|
909 |
void DrawEngineList(VehicleType type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group) |
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
910 |
{ |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
911 |
byte step_size = GetVehicleListHeight(type); |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
912 |
byte x_offset = 0; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
913 |
byte y_offset = 0; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
914 |
|
6053
bec24ee21ccb
(svn r8364) -Codechange (r8362): added an assert to catch conditions where a request wants to draw more vehicles than the list contains
bjarni
parents:
6051
diff
changeset
|
915 |
assert(max <= EngList_Count(&eng_list)); |
bec24ee21ccb
(svn r8364) -Codechange (r8362): added an assert to catch conditions where a request wants to draw more vehicles than the list contains
bjarni
parents:
6051
diff
changeset
|
916 |
|
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
917 |
switch (type) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
918 |
case VEH_TRAIN: |
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
919 |
x++; // train and road vehicles use the same offset, except trains are one more pixel to the right |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
920 |
/* Fallthough */ |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
921 |
case VEH_ROAD: |
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
922 |
x += 26; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
923 |
x_offset = 30; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
924 |
y += 2; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
925 |
y_offset = 4; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
926 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
927 |
case VEH_SHIP: |
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
928 |
x += 35; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
929 |
x_offset = 40; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
930 |
y += 7; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
931 |
y_offset = 3; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
932 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
933 |
case VEH_AIRCRAFT: |
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
934 |
x += 27; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
935 |
x_offset = 33; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
936 |
y += 7; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
937 |
y_offset = 3; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
938 |
break; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
939 |
default: NOT_REACHED(); |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
940 |
} |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
941 |
|
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
942 |
for (; min < max; min++, y += step_size) { |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
943 |
const EngineID engine = eng_list[min]; |
7977
b10b1a884892
(svn r10992) -Fix [FS#1132]: huge amount of vehicles in the "ungrouped" group. Patch by frosch.
rubidium
parents:
7864
diff
changeset
|
944 |
/* Note: num_engines is only used in the autoreplace GUI, so it is correct to use _local_player here. */ |
b10b1a884892
(svn r10992) -Fix [FS#1132]: huge amount of vehicles in the "ungrouped" group. Patch by frosch.
rubidium
parents:
7864
diff
changeset
|
945 |
const uint num_engines = GetGroupNumEngines(_local_player, selected_group, engine); |
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
946 |
|
7555
e20900912fa2
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7505
diff
changeset
|
947 |
SetDParam(0, engine); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
948 |
DrawString(x + x_offset, y, STR_ENGINE_NAME, engine == selected_id ? TC_WHITE : TC_BLACK); |
7139
4ae3ab180d05
(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:
7134
diff
changeset
|
949 |
DrawVehicleEngine(type, x, y + y_offset, engine, (show_count && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_player)); |
6195
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6144
diff
changeset
|
950 |
if (show_count) { |
7139
4ae3ab180d05
(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:
7134
diff
changeset
|
951 |
SetDParam(0, num_engines); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
952 |
DrawStringRightAligned(213, y + (GetVehicleListHeight(type) == 14 ? 3 : 8), STR_TINY_BLACK, TC_FROMSTRING); |
6195
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6144
diff
changeset
|
953 |
} |
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
954 |
} |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
955 |
} |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
956 |
|
6711
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
957 |
static void ExpandPurchaseInfoWidget(Window *w, int expand_by) |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
958 |
{ |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
959 |
Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL]; |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
960 |
|
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
961 |
SetWindowDirty(w); |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
962 |
wi->bottom += expand_by; |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
963 |
|
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
964 |
for (uint i = BUILD_VEHICLE_WIDGET_BUILD; i < BUILD_VEHICLE_WIDGET_END; i++) { |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
965 |
wi = &w->widget[i]; |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
966 |
wi->top += expand_by; |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
967 |
wi->bottom += expand_by; |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
968 |
} |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
969 |
|
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
970 |
w->height += expand_by; |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
971 |
SetWindowDirty(w); |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
972 |
} |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
973 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
974 |
static void DrawBuildVehicleWindow(Window *w) |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
975 |
{ |
5200
603e30641448
(svn r7315) -Fix: Have the first engine in the list be selected once again when the window is opened
Darkvater
parents:
5199
diff
changeset
|
976 |
const buildvehicle_d *bv = &WP(w, buildvehicle_d); |
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
977 |
uint max = min(w->vscroll.pos + w->vscroll.cap, EngList_Count(&bv->eng_list)); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
978 |
|
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
979 |
w->SetWidgetDisabledState(BUILD_VEHICLE_WIDGET_BUILD, w->window_number <= VEH_END); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
980 |
|
5201
db204cf84e2d
(svn r7316) -Codechange: Make train-build-gui and aircraft-build-gui (unified) look more alike.
Darkvater
parents:
5200
diff
changeset
|
981 |
SetVScrollCount(w, EngList_Count(&bv->eng_list)); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
982 |
SetDParam(0, bv->filter.railtype + STR_881C_NEW_RAIL_VEHICLES); // This should only affect rail vehicles |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
983 |
DrawWindowWidgets(w); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
984 |
|
7139
4ae3ab180d05
(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:
7134
diff
changeset
|
985 |
DrawEngineList(bv->vehicle_type, 2, 27, bv->eng_list, w->vscroll.pos, max, bv->sel_engine, false, DEFAULT_GROUP); |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
986 |
|
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
987 |
if (bv->sel_engine != INVALID_ENGINE) { |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
988 |
const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL]; |
6711
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
989 |
int text_end = DrawVehiclePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, bv->sel_engine); |
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
990 |
|
02a4b7b630bc
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6710
diff
changeset
|
991 |
if (text_end > wi->bottom) ExpandPurchaseInfoWidget(w, text_end - wi->bottom); |
6051
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
992 |
} |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
993 |
|
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
994 |
DrawString(85, 15, _sort_listing[bv->vehicle_type][bv->sort_criteria], TC_BLACK); |
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8259
diff
changeset
|
995 |
DoDrawString(bv->descending_sort_order ? DOWNARROW : UPARROW, 69, 15, TC_BLACK); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
996 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
997 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
998 |
static void BuildVehicleClickEvent(Window *w, WindowEvent *e) |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
999 |
{ |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1000 |
buildvehicle_d *bv = &WP(w, buildvehicle_d); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1001 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1002 |
switch (e->we.click.widget) { |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1003 |
case BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING: |
5199
523e7025d979
(svn r7314) -Cleanup: const, whitespace, coding style and variable usage.
Darkvater
parents:
5198
diff
changeset
|
1004 |
bv->descending_sort_order ^= true; |
6206
67358999d80d
(svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents:
6195
diff
changeset
|
1005 |
_last_sort_order[bv->vehicle_type] = bv->descending_sort_order; |
6032
cc75c53d40e9
(svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
bjarni
parents:
6031
diff
changeset
|
1006 |
bv->regenerate_list = true; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1007 |
SetWindowDirty(w); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1008 |
break; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1009 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1010 |
case BUILD_VEHICLE_WIDGET_LIST: { |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1011 |
uint i = (e->we.click.pt.y - 26) / GetVehicleListHeight(bv->vehicle_type) + w->vscroll.pos; |
5201
db204cf84e2d
(svn r7316) -Codechange: Make train-build-gui and aircraft-build-gui (unified) look more alike.
Darkvater
parents:
5200
diff
changeset
|
1012 |
uint num_items = EngList_Count(&bv->eng_list); |
db204cf84e2d
(svn r7316) -Codechange: Make train-build-gui and aircraft-build-gui (unified) look more alike.
Darkvater
parents:
5200
diff
changeset
|
1013 |
bv->sel_engine = (i < num_items) ? bv->eng_list[i] : INVALID_ENGINE; |
db204cf84e2d
(svn r7316) -Codechange: Make train-build-gui and aircraft-build-gui (unified) look more alike.
Darkvater
parents:
5200
diff
changeset
|
1014 |
SetWindowDirty(w); |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1015 |
break; |
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1016 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1017 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1018 |
case BUILD_VEHICLE_WIDGET_SORT_TEXT: case BUILD_VEHICLE_WIDGET_SORT_DROPDOWN: // Select sorting criteria dropdown menu |
6206
67358999d80d
(svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents:
6195
diff
changeset
|
1019 |
ShowDropDownMenu(w, _sort_listing[bv->vehicle_type], bv->sort_criteria, BUILD_VEHICLE_WIDGET_SORT_DROPDOWN, 0, 0); |
6036
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
1020 |
break; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1021 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1022 |
case BUILD_VEHICLE_WIDGET_BUILD: { |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1023 |
EngineID sel_eng = bv->sel_engine; |
5192 | 1024 |
if (sel_eng != INVALID_ENGINE) { |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1025 |
switch (bv->vehicle_type) { |
7134
c5a90dd41166
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents:
7104
diff
changeset
|
1026 |
default: NOT_REACHED(); |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1027 |
case VEH_TRAIN: |
6119
b47985557d1e
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
6075
diff
changeset
|
1028 |
DoCommandP(w->window_number, sel_eng, 0, (RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildLoco, |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1029 |
CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE)); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1030 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1031 |
case VEH_ROAD: |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
1032 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildRoadVeh, CMD_BUILD_ROAD_VEH | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE)); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
1033 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1034 |
case VEH_SHIP: |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
1035 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildShip, CMD_BUILD_SHIP | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP)); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
1036 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1037 |
case VEH_AIRCRAFT: |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1038 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1039 |
break; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1040 |
} |
5192 | 1041 |
} |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1042 |
break; |
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1043 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1044 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1045 |
case BUILD_VEHICLE_WIDGET_RENAME: { |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1046 |
EngineID sel_eng = bv->sel_engine; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1047 |
if (sel_eng != INVALID_ENGINE) { |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1048 |
StringID str = STR_NULL; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1049 |
|
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1050 |
bv->rename_engine = sel_eng; |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1051 |
switch (bv->vehicle_type) { |
7134
c5a90dd41166
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents:
7104
diff
changeset
|
1052 |
default: NOT_REACHED(); |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1053 |
case VEH_TRAIN: str = STR_886A_RENAME_TRAIN_VEHICLE_TYPE; break; |
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1054 |
case VEH_ROAD: str = STR_9036_RENAME_ROAD_VEHICLE_TYPE; break; |
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1055 |
case VEH_SHIP: str = STR_9838_RENAME_SHIP_TYPE; break; |
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1056 |
case VEH_AIRCRAFT: str = STR_A039_RENAME_AIRCRAFT_TYPE; break; |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1057 |
} |
7555
e20900912fa2
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7505
diff
changeset
|
1058 |
SetDParam(0, sel_eng); |
e20900912fa2
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7505
diff
changeset
|
1059 |
ShowQueryString(STR_ENGINE_NAME, str, 31, 160, w, CS_ALPHANUMERAL); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1060 |
} |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1061 |
break; |
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1062 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1063 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1064 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1065 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1066 |
static void NewVehicleWndProc(Window *w, WindowEvent *e) |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1067 |
{ |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1068 |
buildvehicle_d *bv = &WP(w, buildvehicle_d); |
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1069 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1070 |
switch (e->event) { |
7864
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1071 |
case WE_CREATE: { |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1072 |
bv->vehicle_type = *(VehicleType*)e->we.create.data; |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1073 |
int vlh = GetVehicleListHeight(bv->vehicle_type); |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1074 |
|
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1075 |
ResizeWindow(w, 0, vlh - 14); |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1076 |
w->resize.step_height = vlh; |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1077 |
w->vscroll.cap = 1; |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1078 |
w->widget[BUILD_VEHICLE_WIDGET_LIST].data = 0x101; |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1079 |
|
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1080 |
w->resize.width = w->width; |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1081 |
w->resize.height = w->height; |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1082 |
} break; |
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1083 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1084 |
case WE_INVALIDATE_DATA: |
6032
cc75c53d40e9
(svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
bjarni
parents:
6031
diff
changeset
|
1085 |
bv->regenerate_list = true; |
cc75c53d40e9
(svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
bjarni
parents:
6031
diff
changeset
|
1086 |
SetWindowDirty(w); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1087 |
break; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1088 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1089 |
case WE_DESTROY: |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1090 |
EngList_Destroy(&bv->eng_list); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1091 |
break; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1092 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1093 |
case WE_PAINT: |
6032
cc75c53d40e9
(svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
bjarni
parents:
6031
diff
changeset
|
1094 |
if (bv->regenerate_list) { |
cc75c53d40e9
(svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
bjarni
parents:
6031
diff
changeset
|
1095 |
bv->regenerate_list = false; |
cc75c53d40e9
(svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
bjarni
parents:
6031
diff
changeset
|
1096 |
GenerateBuildList(w); |
cc75c53d40e9
(svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
bjarni
parents:
6031
diff
changeset
|
1097 |
} |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1098 |
DrawBuildVehicleWindow(w); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1099 |
break; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1100 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1101 |
case WE_CLICK: |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1102 |
BuildVehicleClickEvent(w, e); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1103 |
break; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1104 |
|
7505
94a7391e0377
(svn r10265) -Feature: allow double-clicking on certain places: build-vehicle and town-action
truelight
parents:
7498
diff
changeset
|
1105 |
case WE_DOUBLE_CLICK: |
94a7391e0377
(svn r10265) -Feature: allow double-clicking on certain places: build-vehicle and town-action
truelight
parents:
7498
diff
changeset
|
1106 |
if (e->we.click.widget == BUILD_VEHICLE_WIDGET_LIST) { |
94a7391e0377
(svn r10265) -Feature: allow double-clicking on certain places: build-vehicle and town-action
truelight
parents:
7498
diff
changeset
|
1107 |
/* When double clicking, we want to buy a vehicle */ |
94a7391e0377
(svn r10265) -Feature: allow double-clicking on certain places: build-vehicle and town-action
truelight
parents:
7498
diff
changeset
|
1108 |
e->we.click.widget = BUILD_VEHICLE_WIDGET_BUILD; |
94a7391e0377
(svn r10265) -Feature: allow double-clicking on certain places: build-vehicle and town-action
truelight
parents:
7498
diff
changeset
|
1109 |
BuildVehicleClickEvent(w, e); |
94a7391e0377
(svn r10265) -Feature: allow double-clicking on certain places: build-vehicle and town-action
truelight
parents:
7498
diff
changeset
|
1110 |
} |
94a7391e0377
(svn r10265) -Feature: allow double-clicking on certain places: build-vehicle and town-action
truelight
parents:
7498
diff
changeset
|
1111 |
break; |
94a7391e0377
(svn r10265) -Feature: allow double-clicking on certain places: build-vehicle and town-action
truelight
parents:
7498
diff
changeset
|
1112 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1113 |
case WE_ON_EDIT_TEXT: { |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1114 |
if (e->we.edittext.str[0] != '\0') { |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1115 |
StringID str = STR_NULL; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1116 |
_cmd_text = e->we.edittext.str; |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1117 |
switch (bv->vehicle_type) { |
7134
c5a90dd41166
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents:
7104
diff
changeset
|
1118 |
default: NOT_REACHED(); |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1119 |
case VEH_TRAIN: str = STR_886B_CAN_T_RENAME_TRAIN_VEHICLE; break; |
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1120 |
case VEH_ROAD: str = STR_9037_CAN_T_RENAME_ROAD_VEHICLE; break; |
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1121 |
case VEH_SHIP: str = STR_9839_CAN_T_RENAME_SHIP_TYPE; break; |
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1122 |
case VEH_AIRCRAFT: str = STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE; break; |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1123 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1124 |
DoCommandP(0, bv->rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(str)); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1125 |
} |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1126 |
break; |
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1127 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1128 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6417
diff
changeset
|
1129 |
case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1130 |
if (bv->sort_criteria != e->we.dropdown.index) { |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1131 |
bv->sort_criteria = e->we.dropdown.index; |
6206
67358999d80d
(svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents:
6195
diff
changeset
|
1132 |
_last_sort_criteria[bv->vehicle_type] = bv->sort_criteria; |
6032
cc75c53d40e9
(svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
bjarni
parents:
6031
diff
changeset
|
1133 |
bv->regenerate_list = true; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1134 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1135 |
SetWindowDirty(w); |
5192 | 1136 |
break; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1137 |
|
5192 | 1138 |
case WE_RESIZE: |
6075
33cdb35f9af5
(svn r8390) -Codechange (r8384): Rewrote ResizeButtons()
bjarni
parents:
6074
diff
changeset
|
1139 |
if (e->we.sizing.diff.x != 0) ResizeButtons(w, BUILD_VEHICLE_WIDGET_BUILD, BUILD_VEHICLE_WIDGET_RENAME); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1140 |
if (e->we.sizing.diff.y == 0) break; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1141 |
|
6352
e2074b537a6d
(svn r8749) -Regression r8331: fixed signed/unsigned issue that could create too many lines in build vehicle windows and crash the game
bjarni
parents:
6350
diff
changeset
|
1142 |
w->vscroll.cap += e->we.sizing.diff.y / (int)GetVehicleListHeight(bv->vehicle_type); |
5192 | 1143 |
w->widget[BUILD_VEHICLE_WIDGET_LIST].data = (w->vscroll.cap << 8) + 1; |
1144 |
break; |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1145 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1146 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1147 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1148 |
static const WindowDesc _build_vehicle_desc = { |
7864
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1149 |
WDP_AUTO, WDP_AUTO, 240, 174, 240, 256, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6125
diff
changeset
|
1150 |
WC_BUILD_VEHICLE, WC_NONE, |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1151 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1152 |
_build_vehicle_widgets, |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1153 |
NewVehicleWndProc |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1154 |
}; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1155 |
|
7134
c5a90dd41166
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents:
7104
diff
changeset
|
1156 |
void ShowBuildVehicleWindow(TileIndex tile, VehicleType type) |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1157 |
{ |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1158 |
buildvehicle_d *bv; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1159 |
Window *w; |
7742
f40cca82d948
(svn r10546) -Fix [FS#1026]: you can now have both Available Train as Available Ship window open
truelight
parents:
7555
diff
changeset
|
1160 |
/* We want to be able to open both Available Train as Available Ships, |
f40cca82d948
(svn r10546) -Fix [FS#1026]: you can now have both Available Train as Available Ship window open
truelight
parents:
7555
diff
changeset
|
1161 |
* so if tile == 0 (Available XXX Window), use 'type' as unique number. |
f40cca82d948
(svn r10546) -Fix [FS#1026]: you can now have both Available Train as Available Ship window open
truelight
parents:
7555
diff
changeset
|
1162 |
* As it always is a low value, it won't collide with any real tile |
f40cca82d948
(svn r10546) -Fix [FS#1026]: you can now have both Available Train as Available Ship window open
truelight
parents:
7555
diff
changeset
|
1163 |
* number. */ |
f40cca82d948
(svn r10546) -Fix [FS#1026]: you can now have both Available Train as Available Ship window open
truelight
parents:
7555
diff
changeset
|
1164 |
uint num = (tile == 0) ? (int)type : tile; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1165 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1166 |
assert(IsPlayerBuildableVehicleType(type)); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1167 |
|
7742
f40cca82d948
(svn r10546) -Fix [FS#1026]: you can now have both Available Train as Available Ship window open
truelight
parents:
7555
diff
changeset
|
1168 |
DeleteWindowById(WC_BUILD_VEHICLE, num); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1169 |
|
7864
9b1e7d04aafa
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7837
diff
changeset
|
1170 |
w = AllocateWindowDescFront(&_build_vehicle_desc, num, &type); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1171 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1172 |
if (w == NULL) return; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1173 |
|
5199
523e7025d979
(svn r7314) -Cleanup: const, whitespace, coding style and variable usage.
Darkvater
parents:
5198
diff
changeset
|
1174 |
w->caption_color = (tile != 0) ? GetTileOwner(tile) : _local_player; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1175 |
|
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1176 |
bv = &WP(w, buildvehicle_d); |
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1177 |
EngList_Create(&bv->eng_list); |
6032
cc75c53d40e9
(svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
bjarni
parents:
6031
diff
changeset
|
1178 |
bv->sel_engine = INVALID_ENGINE; |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1179 |
|
6032
cc75c53d40e9
(svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
bjarni
parents:
6031
diff
changeset
|
1180 |
bv->regenerate_list = false; |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1181 |
|
6206
67358999d80d
(svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents:
6195
diff
changeset
|
1182 |
bv->sort_criteria = _last_sort_criteria[type]; |
67358999d80d
(svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents:
6195
diff
changeset
|
1183 |
bv->descending_sort_order = _last_sort_order[type]; |
6035
7c56c182a490
(svn r8336) -Codechange: added function to translate vehicle types to 0,1,2... for use for index to arrays
bjarni
parents:
6034
diff
changeset
|
1184 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1185 |
switch (type) { |
7134
c5a90dd41166
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents:
7104
diff
changeset
|
1186 |
default: NOT_REACHED(); |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1187 |
case VEH_TRAIN: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6712
diff
changeset
|
1188 |
WP(w, buildvehicle_d).filter.railtype = (tile == 0) ? RAILTYPE_END : GetRailType(tile); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1189 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1190 |
case VEH_ROAD: |
7181
f966d75af3a6
(svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents:
7139
diff
changeset
|
1191 |
WP(w, buildvehicle_d).filter.roadtypes = (tile == 0) ? ROADTYPES_ALL : GetRoadTypes(tile); |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1192 |
case VEH_SHIP: |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
1193 |
break; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6563
diff
changeset
|
1194 |
case VEH_AIRCRAFT: |
6350 | 1195 |
bv->filter.flags = |
6358 | 1196 |
tile == 0 ? AirportFTAClass::ALL : GetStationByTile(tile)->Airport()->flags; |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1197 |
break; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1198 |
} |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1199 |
SetupWindowStrings(w, type); |
6075
33cdb35f9af5
(svn r8390) -Codechange (r8384): Rewrote ResizeButtons()
bjarni
parents:
6074
diff
changeset
|
1200 |
ResizeButtons(w, BUILD_VEHICLE_WIDGET_BUILD, BUILD_VEHICLE_WIDGET_RENAME); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1201 |
|
6032
cc75c53d40e9
(svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
bjarni
parents:
6031
diff
changeset
|
1202 |
GenerateBuildList(w); // generate the list, since we need it in the next line |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
1203 |
/* Select the first engine in the list as default when opening the window */ |
5200
603e30641448
(svn r7315) -Fix: Have the first engine in the list be selected once again when the window is opened
Darkvater
parents:
5199
diff
changeset
|
1204 |
if (EngList_Count(&bv->eng_list) > 0) bv->sel_engine = bv->eng_list[0]; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1205 |
} |