author | bjarni |
Tue, 13 Feb 2007 10:27:18 +0000 | |
branch | cpp_gui |
changeset 6240 | 8d4ea2d6befc |
parent 6238 | 1ff56ccccbb5 |
child 6241 | 6a7a41b0cd32 |
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 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
3 |
#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
|
4 |
#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
|
5 |
#include "train.h" |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
6 |
#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
|
7 |
#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
|
8 |
#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
|
9 |
#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
|
10 |
#include "functions.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 "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
|
12 |
#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
|
13 |
#include "window.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" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
15 |
#include "vehicle.h" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
16 |
#include "gfx.h" |
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" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
18 |
#include "command.h" |
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" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
20 |
#include "player.h" |
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" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
25 |
#include "date.h" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
26 |
#include "strings.h" |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
27 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
28 |
|
5273
5fde4b8c94c4
(svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents:
5215
diff
changeset
|
29 |
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
|
30 |
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
|
31 |
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
|
32 |
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
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
BUILD_VEHICLE_WIDGET_RESIZE, |
5273
5fde4b8c94c4
(svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents:
5215
diff
changeset
|
41 |
}; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
42 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
43 |
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
|
44 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
45 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 227, 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
|
46 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP}, |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
47 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 81, 215, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
48 |
{ WWT_TEXTBTN, RESIZE_LR, 14, 216, 227, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
49 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 215, 26, 121, 0x0, 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
|
50 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 216, 227, 26, 121, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST }, |
6067
e2c8bf6c4b14
(svn r8378) -Fix (r8331): [build vehicle window] extended the widget with the details with one line since some newgrf trains needs it
bjarni
parents:
6066
diff
changeset
|
51 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 227, 122, 223, 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
|
52 |
|
6067
e2c8bf6c4b14
(svn r8378) -Fix (r8331): [build vehicle window] extended the widget with the details with one line since some newgrf trains needs it
bjarni
parents:
6066
diff
changeset
|
53 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 114, 224, 235, 0x0, STR_NULL }, |
e2c8bf6c4b14
(svn r8378) -Fix (r8331): [build vehicle window] extended the widget with the details with one line since some newgrf trains needs it
bjarni
parents:
6066
diff
changeset
|
54 |
{ WWT_PUSHTXTBTN, RESIZE_RTB, 14, 115, 215, 224, 235, 0x0, STR_NULL }, |
e2c8bf6c4b14
(svn r8378) -Fix (r8331): [build vehicle window] extended the widget with the details with one line since some newgrf trains needs it
bjarni
parents:
6066
diff
changeset
|
55 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 216, 227, 224, 235, 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
|
56 |
{ WIDGETS_END}, |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
57 |
}; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
58 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
59 |
/* 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
|
60 |
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
|
61 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
62 |
switch (type) { |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
63 |
case VEH_Train: |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
64 |
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
|
65 |
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
|
66 |
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
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
break; |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
71 |
case VEH_Road: |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
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
|
76 |
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
|
77 |
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
|
78 |
break; |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
79 |
case VEH_Ship: |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
80 |
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
|
81 |
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
|
82 |
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
|
83 |
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
|
84 |
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
|
85 |
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
|
86 |
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
|
87 |
case VEH_Aircraft: |
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_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
|
89 |
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
|
90 |
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
|
91 |
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
|
92 |
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
|
93 |
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
|
94 |
break; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
95 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
96 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
97 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
98 |
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
|
99 |
|
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
|
100 |
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
|
101 |
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
|
102 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
103 |
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
|
104 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
105 |
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
|
106 |
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
|
107 |
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
|
108 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
109 |
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
|
110 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
111 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
112 |
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
|
113 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
114 |
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
|
115 |
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
|
116 |
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
|
117 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
118 |
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
|
119 |
/* 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
|
120 |
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
|
121 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
122 |
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
|
123 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
124 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
125 |
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
|
126 |
{ |
4804
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
127 |
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
|
128 |
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
|
129 |
|
4800
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 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
|
131 |
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
|
132 |
int r; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
133 |
|
4804
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
134 |
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
|
135 |
last_engine[0] = va; |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4896
diff
changeset
|
136 |
GetString(last_name[0], GetCustomEngineName(va), 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
|
137 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
138 |
|
4804
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
139 |
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
|
140 |
last_engine[1] = vb; |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4896
diff
changeset
|
141 |
GetString(last_name[1], GetCustomEngineName(vb), 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
|
142 |
} |
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
143 |
|
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
144 |
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
|
145 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
146 |
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
|
147 |
/* 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
|
148 |
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
|
149 |
} |
4804
74d2003d6f9b
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
150 |
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
|
151 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
152 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
153 |
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
|
154 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
155 |
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
|
156 |
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
|
157 |
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
|
158 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
159 |
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
|
160 |
/* 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
|
161 |
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
|
162 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
163 |
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
|
164 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
165 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
166 |
/* 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
|
167 |
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
|
168 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
169 |
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
|
170 |
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
|
171 |
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
|
172 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
173 |
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
|
174 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
175 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
176 |
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
|
177 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
182 |
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
|
183 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
184 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
185 |
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
|
186 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
187 |
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
|
188 |
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
|
189 |
|
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
|
190 |
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
|
191 |
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
|
192 |
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
|
193 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
194 |
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
|
195 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
196 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
197 |
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
|
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 |
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
|
200 |
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
|
201 |
|
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
|
202 |
int va = rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class] * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1); |
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
|
203 |
int vb = rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class] * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1); |
6030
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 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
|
205 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
206 |
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
|
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 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
209 |
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
|
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 |
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
|
212 |
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
|
213 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
214 |
/* 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
|
215 |
* 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
|
216 |
* 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
|
217 |
* 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
|
218 |
* 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
|
219 |
* Since it would be multipling with 2 in both numerator and denumerator, it will even themselves out and we skip checking for multiheaded. */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
220 |
int va = (rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class]) / max((uint16)1, rvi_a->power); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
221 |
int vb = (rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class]) / max((uint16)1, rvi_b->power); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
222 |
int r = vb - va; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
223 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
224 |
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
|
225 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
226 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
227 |
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
|
228 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
229 |
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
|
230 |
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
|
231 |
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
|
232 |
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
|
233 |
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
|
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 |
/* 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
|
236 |
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
|
237 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
238 |
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
|
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 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
241 |
/* 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
|
242 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
243 |
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
|
244 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
245 |
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
|
246 |
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
|
247 |
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
|
248 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
249 |
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
|
250 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
251 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
252 |
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
|
253 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
254 |
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
|
255 |
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
|
256 |
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
|
257 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
258 |
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
|
259 |
/* 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
|
260 |
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
|
261 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
262 |
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
|
263 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
264 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
265 |
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
|
266 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
267 |
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
|
268 |
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
|
269 |
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
|
270 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
271 |
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
|
272 |
/* 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
|
273 |
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
|
274 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
275 |
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
|
276 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
277 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
278 |
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
|
279 |
{ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
280 |
const int va = AircraftVehInfo(*(const EngineID*)a)->passenger_capacity; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
281 |
const int vb = AircraftVehInfo(*(const EngineID*)b)->passenger_capacity; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
282 |
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
|
283 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
284 |
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
|
285 |
/* 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
|
286 |
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
|
287 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
288 |
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
|
289 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
290 |
|
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
|
291 |
static EngList_SortTypeFunction * const _sorter[][9] = {{ |
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
|
292 |
/* 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
|
293 |
&EngineNumberSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
294 |
&TrainEngineCostSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
295 |
&TrainEngineSpeedSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
296 |
&TrainEnginePowerSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
297 |
&EngineIntroDateSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
298 |
&EngineNameSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
299 |
&TrainEngineRunningCostSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
300 |
&TrainEnginePowerVsRunningCostSorter, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
301 |
&EngineReliabilitySorter, |
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
|
302 |
},{ |
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
|
303 |
/* 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
|
304 |
&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
|
305 |
&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
|
306 |
&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
|
307 |
&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
|
308 |
},{ |
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
|
309 |
/* 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
|
310 |
&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
|
311 |
&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
|
312 |
&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
|
313 |
&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
|
314 |
},{ |
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
|
315 |
/* 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
|
316 |
&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
|
317 |
&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
|
318 |
&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
|
319 |
&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
|
320 |
&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
|
321 |
&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
|
322 |
&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
|
323 |
&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
|
324 |
}}; |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
325 |
|
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
|
326 |
static const StringID _sort_listing[][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
|
327 |
/* 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
|
328 |
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
|
329 |
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
|
330 |
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
|
331 |
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
|
332 |
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
|
333 |
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
|
334 |
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
|
335 |
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
|
336 |
STR_SORT_BY_RELIABILITY, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
337 |
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
|
338 |
},{ |
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
|
339 |
/* 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
|
340 |
STR_ENGINE_SORT_ENGINE_ID, |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
341 |
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
|
342 |
STR_SORT_BY_DROPDOWN_NAME, |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
343 |
STR_SORT_BY_RELIABILITY, |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
344 |
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
|
345 |
},{ |
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
|
346 |
/* 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
|
347 |
STR_ENGINE_SORT_ENGINE_ID, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
348 |
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
|
349 |
STR_SORT_BY_DROPDOWN_NAME, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
350 |
STR_SORT_BY_RELIABILITY, |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
351 |
INVALID_STRING_ID |
2775343bd5d5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
6035
diff
changeset
|
352 |
},{ |
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
|
353 |
/* Aircraft */ |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
354 |
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
|
355 |
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
|
356 |
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
|
357 |
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
|
358 |
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
|
359 |
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
|
360 |
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
|
361 |
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
|
362 |
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
|
363 |
}}; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
364 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
365 |
/* 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
|
366 |
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
|
367 |
{ |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
368 |
/* Purchase cost */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
369 |
SetDParam(0, (rvi->base_cost * _price.build_railwagon) >> 8); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
370 |
DrawString(x, y, STR_PURCHASE_INFO_COST, 0); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
371 |
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
|
372 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
373 |
/* Wagon weight - (including cargo) */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
374 |
SetDParam(0, rvi->weight); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
375 |
SetDParam(1, (_cargoc.weights[rvi->cargo_type] * rvi->capacity >> 4) + rvi->weight); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
376 |
DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, 0); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
377 |
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
|
378 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
379 |
/* Wagon speed limit, displayed if above zero */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
380 |
if (rvi->max_speed > 0 && _patches.wagon_speed_limits) { |
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
|
381 |
SetDParam(0, rvi->max_speed * 10 / 16); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
382 |
DrawString(x,y, STR_PURCHASE_INFO_SPEED, 0); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
383 |
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
|
384 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
385 |
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
|
386 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
387 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
388 |
/* Draw locomotive specific details */ |
6074 | 389 |
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
|
390 |
{ |
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
|
391 |
int multihead = (rvi->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
|
392 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
393 |
/* Purchase Cost - Engine weight */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
394 |
SetDParam(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
395 |
SetDParam(1, rvi->weight << multihead); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
396 |
DrawString(x,y, STR_PURCHASE_INFO_COST_WEIGHT, 0); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
397 |
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
|
398 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
399 |
/* Max speed - Engine power */ |
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
|
400 |
SetDParam(0, rvi->max_speed * 10 / 16); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
401 |
SetDParam(1, rvi->power << multihead); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
402 |
DrawString(x,y, STR_PURCHASE_INFO_SPEED_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
|
403 |
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
|
404 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
405 |
/* Max tractive effort - not applicable if old acceleration or maglev */ |
6074 | 406 |
if (_patches.realistic_acceleration && rvi->railtype != RAILTYPE_MAGLEV) { |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
407 |
SetDParam(0, ((rvi->weight << multihead) * 10 * rvi->tractive_effort) / 256); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
408 |
DrawString(x, y, STR_PURCHASE_INFO_MAX_TE, 0); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
409 |
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
|
410 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
411 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
412 |
/* 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
|
413 |
SetDParam(0, (rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8) << multihead); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
414 |
DrawString(x,y, STR_PURCHASE_INFO_RUNNINGCOST, 0); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
415 |
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
|
416 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
417 |
/* 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
|
418 |
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
|
419 |
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
|
420 |
SetDParam(1, rvi->pow_wag_weight); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
421 |
DrawString(x,y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT, 0); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
422 |
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
|
423 |
}; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
424 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
425 |
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
|
426 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
427 |
|
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
428 |
/* 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
|
429 |
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
|
430 |
{ |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
431 |
bool refittable = (_engine_info[engine_number].refit_mask != 0); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
432 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
433 |
/* Purchase cost - Max speed */ |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
434 |
SetDParam(0, 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
|
435 |
SetDParam(1, rvi->max_speed * 10 / 32); |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
436 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
437 |
y += 10; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
438 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
439 |
/* Running cost */ |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
440 |
SetDParam(0, rvi->running_cost * _price.roadveh_running >> 8); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
441 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
442 |
y += 10; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
443 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
444 |
/* Cargo type + capacity */ |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
445 |
SetDParam(0, rvi->cargo_type); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
446 |
SetDParam(1, rvi->capacity); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
447 |
SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
448 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
449 |
y += 10; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
450 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
451 |
return y; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
452 |
} |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
453 |
|
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
454 |
/* 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
|
455 |
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
|
456 |
{ |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
457 |
/* Purchase cost - Max speed */ |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
458 |
SetDParam(0, svi->base_cost * (_price.ship_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
|
459 |
SetDParam(1, svi->max_speed * 10 / 32); |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
460 |
DrawString(x,y, STR_PURCHASE_INFO_COST_SPEED, 0); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
461 |
y += 10; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
462 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
463 |
/* 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
|
464 |
SetDParam(0, svi->cargo_type); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
465 |
SetDParam(1, svi->capacity); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
466 |
SetDParam(2, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
467 |
DrawString(x,y, STR_PURCHASE_INFO_CAPACITY, 0); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
468 |
y += 10; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
469 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
470 |
/* Running cost */ |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
471 |
SetDParam(0, svi->running_cost * _price.ship_running >> 8); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
472 |
DrawString(x,y, STR_PURCHASE_INFO_RUNNINGCOST, 0); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
473 |
y += 10; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
474 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
475 |
return y; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
476 |
} |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
477 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
478 |
/* 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
|
479 |
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
|
480 |
{ |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
481 |
CargoID cargo; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
482 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
483 |
/* Purchase cost - Max speed */ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
484 |
SetDParam(0, avi->base_cost * (_price.aircraft_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
|
485 |
SetDParam(1, avi->max_speed * 8); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
486 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
487 |
y += 10; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
488 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
489 |
/* Cargo capacity */ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
490 |
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
|
491 |
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
|
492 |
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
|
493 |
SetDParam(1, avi->mail_capacity); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
494 |
DrawString(x, y, STR_PURCHASE_INFO_AIRCRAFT_CAPACITY, 0); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
495 |
} else { |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
496 |
/* 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
|
497 |
* 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
|
498 |
SetDParam(0, cargo); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
499 |
SetDParam(1, AircraftDefaultCargoCapacity(cargo, engine_number)); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
500 |
SetDParam(2, STR_9842_REFITTABLE); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
501 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
502 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
503 |
y += 10; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
504 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
505 |
/* Running cost */ |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
506 |
SetDParam(0, avi->running_cost * _price.aircraft_running >> 8); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
507 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
508 |
y += 10; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
509 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
510 |
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
|
511 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
512 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
513 |
/** |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
514 |
* 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
|
515 |
* @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
|
516 |
* @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
|
517 |
* @param engine_number the engine of which to draw the info of |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
518 |
*/ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
519 |
void DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID 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
|
520 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
521 |
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
|
522 |
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
|
523 |
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
|
524 |
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
|
525 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
526 |
switch (e->type) { |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
527 |
case VEH_Train: { |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
528 |
const RailVehicleInfo *rvi = RailVehInfo(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
|
529 |
|
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
|
530 |
refitable = (EngInfo(engine_number)->refit_mask != 0) && (rvi->capacity > 0); |
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
|
531 |
|
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
|
532 |
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
|
533 |
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
|
534 |
} else { |
6074 | 535 |
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
|
536 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
537 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
538 |
/* 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
|
539 |
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
|
540 |
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
|
541 |
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
|
542 |
} 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
|
543 |
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
|
544 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
545 |
SetDParam(0, rvi->cargo_type); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
546 |
SetDParam(1, (rvi->capacity * (CountArticulatedParts(engine_number) + 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
|
547 |
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
|
548 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
549 |
DrawString(x,y, STR_PURCHASE_INFO_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
|
550 |
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
|
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 |
break; |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
553 |
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
|
554 |
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
|
555 |
refitable = true; |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
556 |
break; |
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
|
557 |
case VEH_Ship: { |
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
|
558 |
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
|
559 |
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
|
560 |
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
|
561 |
} 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
|
562 |
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
|
563 |
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
|
564 |
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
|
565 |
break; |
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 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
568 |
/* Draw details, that applies to all types except rail wagons */ |
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
|
569 |
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
|
570 |
/* 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
|
571 |
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
|
572 |
SetDParam(1, e->lifelength); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
573 |
DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
574 |
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
|
575 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
576 |
/* Reliability */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
577 |
SetDParam(0, e->reliability * 100 >> 16); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
578 |
DrawString(x, y, STR_PURCHASE_INFO_RELIABILITY, 0); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
579 |
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
|
580 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
581 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
582 |
/* 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
|
583 |
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
|
584 |
if (refitable) y += ShowRefitOptionsList(x, y, w, engine_number); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
585 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
586 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
587 |
/* 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
|
588 |
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
|
589 |
{ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
590 |
EngineID eid, 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
|
591 |
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
|
592 |
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
|
593 |
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
|
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 |
bv->filter.railtype = (w->window_number == 0) ? RAILTYPE_END : GetRailType(w->window_number); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
596 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
597 |
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
|
598 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
599 |
/* Make list of all available train engines and wagons. |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
600 |
* Also check to see if the previously selected engine is still available, |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
601 |
* and if not, reset selection to INVALID_ENGINE. This could be the case |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
602 |
* when engines become obsolete and are removed */ |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
603 |
for (sel_id = INVALID_ENGINE, eid = 0; eid < NUM_TRAIN_ENGINES; eid++) { |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
604 |
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
|
605 |
|
6074 | 606 |
if (bv->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, bv->filter.railtype)) 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
|
607 |
if (!IsEngineBuildable(eid, VEH_Train, _local_player)) continue; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
608 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
609 |
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
|
610 |
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
|
611 |
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
|
612 |
} else { |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
613 |
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
|
614 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
615 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
616 |
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
|
617 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
618 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
619 |
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
|
620 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
621 |
// make engines first, and then wagons, sorted by ListPositionOfEngine() |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
622 |
_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
|
623 |
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
|
624 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
625 |
// and then sort engines |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
626 |
_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
|
627 |
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
|
628 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
629 |
// 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
|
630 |
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
|
631 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
632 |
|
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
633 |
/* 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
|
634 |
static void GenerateBuildRoadVehList(Window *w) |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
635 |
{ |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
636 |
EngineID eid, sel_id; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
637 |
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
|
638 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
639 |
EngList_RemoveAll(&bv->eng_list); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
640 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
641 |
sel_id = INVALID_ENGINE; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
642 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
643 |
for (eid = ROAD_ENGINES_INDEX; eid < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; eid++) { |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
644 |
if (!IsEngineBuildable(eid, VEH_Road, _local_player)) continue; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
645 |
EngList_Add(&bv->eng_list, eid); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
646 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
647 |
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
|
648 |
} |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
649 |
bv->sel_engine = sel_id; |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
650 |
} |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
651 |
|
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
652 |
/* 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
|
653 |
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
|
654 |
{ |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
655 |
EngineID eid, sel_id; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
656 |
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
|
657 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
658 |
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
|
659 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
660 |
sel_id = INVALID_ENGINE; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
661 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
662 |
for (eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) { |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
663 |
if (!IsEngineBuildable(eid, VEH_Ship, _local_player)) continue; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
664 |
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
|
665 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
666 |
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
|
667 |
} |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
668 |
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
|
669 |
} |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
670 |
|
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
671 |
/* 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
|
672 |
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
|
673 |
{ |
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
|
674 |
EngineID eid, sel_id; |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
675 |
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
|
676 |
|
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
677 |
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
|
678 |
|
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
|
679 |
/* 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
|
680 |
* 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
|
681 |
* 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
|
682 |
* when planes become obsolete and are removed */ |
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
|
683 |
sel_id = INVALID_ENGINE; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
684 |
for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) { |
5215
439d5ca71311
(svn r7330) -Fix (r7304): Data invalidation doesn't always happen as the local
peter1138
parents:
5201
diff
changeset
|
685 |
if (IsEngineBuildable(eid, VEH_Aircraft, _local_player)) { |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
686 |
EngList_Add(&bv->eng_list, eid); |
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
|
687 |
|
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
|
688 |
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
|
689 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
690 |
} |
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
|
691 |
|
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
|
692 |
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
|
693 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
694 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
695 |
/* 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
|
696 |
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
|
697 |
{ |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
698 |
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
|
699 |
|
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
700 |
switch (bv->vehicle_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
|
701 |
case VEH_Train: |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
702 |
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
|
703 |
return; // trains should not reach the last sorting |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
704 |
case VEH_Road: |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
705 |
GenerateBuildRoadVehList(w); |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
706 |
break; |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
707 |
case VEH_Ship: |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
708 |
GenerateBuildShipList(w); |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
709 |
break; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
710 |
case VEH_Aircraft: |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
711 |
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
|
712 |
break; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
713 |
} |
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
|
714 |
_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
|
715 |
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
|
716 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
717 |
|
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
|
718 |
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
|
719 |
{ |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
720 |
switch (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
|
721 |
case VEH_Train: DrawTrainEngine( x, y, engine, pal); 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
|
722 |
case VEH_Road: DrawRoadVehEngine( x, y, engine, pal); 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
|
723 |
case VEH_Ship: DrawShipEngine( x, y, engine, pal); 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
|
724 |
case VEH_Aircraft: DrawAircraftEngine(x, y, engine, pal); 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
|
725 |
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
|
726 |
} |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
727 |
} |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
728 |
|
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
729 |
/** 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
|
730 |
* @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
|
731 |
* @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
|
732 |
* @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
|
733 |
* @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
|
734 |
* @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
|
735 |
* @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
|
736 |
* @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
|
737 |
*/ |
6195
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6144
diff
changeset
|
738 |
void DrawEngineList(byte type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count) |
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
|
739 |
{ |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
740 |
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
|
741 |
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
|
742 |
byte y_offset = 0; |
6195
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6144
diff
changeset
|
743 |
Player *p = GetPlayer(_local_player); |
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
|
744 |
|
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
|
745 |
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
|
746 |
|
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
|
747 |
switch (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
|
748 |
case VEH_Train: |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
749 |
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
|
750 |
/* Fallthough */ |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
751 |
case VEH_Road: |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
752 |
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
|
753 |
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
|
754 |
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
|
755 |
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
|
756 |
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
|
757 |
case VEH_Ship: |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
758 |
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
|
759 |
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
|
760 |
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
|
761 |
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
|
762 |
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
|
763 |
case VEH_Aircraft: |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
764 |
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
|
765 |
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
|
766 |
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
|
767 |
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
|
768 |
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
|
769 |
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
|
770 |
} |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
771 |
|
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
772 |
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
|
773 |
const EngineID engine = eng_list[min]; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
774 |
|
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
775 |
DrawString(x + x_offset, y, GetCustomEngineName(engine), engine == selected_id ? 0xC : 0x10); |
6195
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6144
diff
changeset
|
776 |
DrawVehicleEngine(type, x, y + y_offset, engine, (show_count && p->num_engines[engine] == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_player)); |
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6144
diff
changeset
|
777 |
if (show_count) { |
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6144
diff
changeset
|
778 |
SetDParam(0, p->num_engines[engine]); |
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6144
diff
changeset
|
779 |
DrawStringRightAligned(213, y + (GetVehicleListHeight(type) == 14 ? 3 : 8), STR_TINY_BLACK, 0); |
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6144
diff
changeset
|
780 |
} |
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
|
781 |
} |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
782 |
} |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
783 |
|
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 |
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
|
785 |
{ |
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
|
786 |
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
|
787 |
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
|
788 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
789 |
SetWindowWidgetDisabledState(w, BUILD_VEHICLE_WIDGET_BUILD, w->window_number == 0); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
790 |
|
5201
db204cf84e2d
(svn r7316) -Codechange: Make train-build-gui and aircraft-build-gui (unified) look more alike.
Darkvater
parents:
5200
diff
changeset
|
791 |
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
|
792 |
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
|
793 |
DrawWindowWidgets(w); |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
794 |
|
6195
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6144
diff
changeset
|
795 |
DrawEngineList(bv->vehicle_type, 2, 27, bv->eng_list, w->vscroll.pos, max, bv->sel_engine, false); |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
796 |
|
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
|
797 |
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
|
798 |
const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL]; |
3fdc90c44643
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
6041
diff
changeset
|
799 |
DrawVehiclePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, bv->sel_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
|
800 |
} |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
801 |
|
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
|
802 |
DrawString(85, 15, _sort_listing[bv->vehicle_type][bv->sort_criteria], 0x10); |
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 |
DoDrawString(bv->descending_sort_order ? DOWNARROW : UPARROW, 69, 15, 0x10); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
804 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
805 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
806 |
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
|
807 |
{ |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
808 |
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
|
809 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
810 |
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
|
811 |
case BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING: |
5199
523e7025d979
(svn r7314) -Cleanup: const, whitespace, coding style and variable usage.
Darkvater
parents:
5198
diff
changeset
|
812 |
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
|
813 |
_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
|
814 |
bv->regenerate_list = true; |
6235
5077e6ed3788
(svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents:
6206
diff
changeset
|
815 |
w->SetDirty(); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
816 |
break; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
817 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
818 |
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
|
819 |
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
|
820 |
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
|
821 |
bv->sel_engine = (i < num_items) ? bv->eng_list[i] : INVALID_ENGINE; |
6235
5077e6ed3788
(svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents:
6206
diff
changeset
|
822 |
w->SetDirty(); |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
823 |
break; |
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
824 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
825 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
826 |
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
|
827 |
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
|
828 |
break; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
829 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
830 |
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
|
831 |
EngineID sel_eng = bv->sel_engine; |
5192 | 832 |
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
|
833 |
switch (bv->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
|
834 |
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
|
835 |
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
|
836 |
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
|
837 |
break; |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
838 |
case VEH_Road: |
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
839 |
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
|
840 |
break; |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
841 |
case VEH_Ship: |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
842 |
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
|
843 |
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
|
844 |
case VEH_Aircraft: |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
845 |
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
|
846 |
break; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
847 |
} |
5192 | 848 |
} |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
849 |
break; |
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
850 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
851 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
852 |
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
|
853 |
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
|
854 |
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
|
855 |
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
|
856 |
|
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
857 |
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
|
858 |
switch (bv->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
|
859 |
case VEH_Train: str = STR_886A_RENAME_TRAIN_VEHICLE_TYPE; break; |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
860 |
case VEH_Road: str = STR_9036_RENAME_ROAD_VEHICLE_TYPE; break; |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
861 |
case VEH_Ship: str = STR_9838_RENAME_SHIP_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
|
862 |
case VEH_Aircraft: str = STR_A039_RENAME_AIRCRAFT_TYPE; break; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
863 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
864 |
ShowQueryString(GetCustomEngineName(sel_eng), 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
|
865 |
} |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
866 |
break; |
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
867 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
868 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
869 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
870 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
871 |
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
|
872 |
{ |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
873 |
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
|
874 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
875 |
switch (e->event) { |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
876 |
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
|
877 |
bv->regenerate_list = true; |
6235
5077e6ed3788
(svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents:
6206
diff
changeset
|
878 |
w->SetDirty(); |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
879 |
break; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
880 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
881 |
case WE_DESTROY: |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
882 |
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
|
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 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
885 |
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
|
886 |
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
|
887 |
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
|
888 |
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
|
889 |
} |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
890 |
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
|
891 |
break; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
892 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
893 |
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
|
894 |
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
|
895 |
break; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
896 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
897 |
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
|
898 |
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
|
899 |
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
|
900 |
_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
|
901 |
switch (bv->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
|
902 |
case VEH_Train: str = STR_886B_CAN_T_RENAME_TRAIN_VEHICLE; break; |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
903 |
case VEH_Road: str = STR_9037_CAN_T_RENAME_ROAD_VEHICLE; break; |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
904 |
case VEH_Ship: str = STR_9839_CAN_T_RENAME_SHIP_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
|
905 |
case VEH_Aircraft: str = STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE; break; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
906 |
} |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
907 |
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
|
908 |
} |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
909 |
break; |
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
910 |
} |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
911 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
912 |
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
|
913 |
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
|
914 |
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
|
915 |
_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
|
916 |
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
|
917 |
} |
6235
5077e6ed3788
(svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents:
6206
diff
changeset
|
918 |
w->SetDirty(); |
5192 | 919 |
break; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
920 |
|
5192 | 921 |
case WE_RESIZE: |
6075
33cdb35f9af5
(svn r8390) -Codechange (r8384): Rewrote ResizeButtons()
bjarni
parents:
6074
diff
changeset
|
922 |
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
|
923 |
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
|
924 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
925 |
w->vscroll.cap += e->we.sizing.diff.y / GetVehicleListHeight(bv->vehicle_type); |
5192 | 926 |
w->widget[BUILD_VEHICLE_WIDGET_LIST].data = (w->vscroll.cap << 8) + 1; |
927 |
break; |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
928 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
929 |
} |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
930 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
931 |
static const WindowDesc _build_vehicle_desc = { |
6067
e2c8bf6c4b14
(svn r8378) -Fix (r8331): [build vehicle window] extended the widget with the details with one line since some newgrf trains needs it
bjarni
parents:
6066
diff
changeset
|
932 |
WDP_AUTO, WDP_AUTO, 228, 236, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6125
diff
changeset
|
933 |
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
|
934 |
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
|
935 |
_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
|
936 |
NewVehicleWndProc |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
937 |
}; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
938 |
|
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
939 |
void ShowBuildVehicleWindow(TileIndex tile, byte type) |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
940 |
{ |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
941 |
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
|
942 |
Window *w; |
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
943 |
|
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
944 |
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
|
945 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
946 |
DeleteWindowById(WC_BUILD_VEHICLE, 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
|
947 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
948 |
w = AllocateWindowDescFront(&_build_vehicle_desc, 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
|
949 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
950 |
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
|
951 |
|
5199
523e7025d979
(svn r7314) -Cleanup: const, whitespace, coding style and variable usage.
Darkvater
parents:
5198
diff
changeset
|
952 |
w->caption_color = (tile != 0) ? GetTileOwner(tile) : _local_player; |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
953 |
w->resize.step_height = GetVehicleListHeight(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
|
954 |
w->vscroll.cap = w->resize.step_height == 24 ? 4 : 8; |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
955 |
w->widget[BUILD_VEHICLE_WIDGET_LIST].data = (w->vscroll.cap << 8) + 1; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
956 |
|
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
957 |
bv = &WP(w, buildvehicle_d); |
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
958 |
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
|
959 |
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
|
960 |
|
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
|
961 |
bv->vehicle_type = type; |
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
|
962 |
bv->regenerate_list = false; |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
963 |
|
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
|
964 |
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
|
965 |
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
|
966 |
|
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
967 |
switch (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
|
968 |
case VEH_Train: |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
969 |
WP(w,buildvehicle_d).filter.railtype = (tile == 0) ? RAILTYPE_END : GetRailType(tile); |
6240
8d4ea2d6befc
(svn r8699) [cpp_gui] -Cleanup: removed the word Window from some Window method names as just being Winddow methods indicates that it's working on a window
bjarni
parents:
6238
diff
changeset
|
970 |
w->Resize(0, 16); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
971 |
break; |
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
6036
diff
changeset
|
972 |
case VEH_Road: |
6240
8d4ea2d6befc
(svn r8699) [cpp_gui] -Cleanup: removed the word Window from some Window method names as just being Winddow methods indicates that it's working on a window
bjarni
parents:
6238
diff
changeset
|
973 |
w->Resize(20, 16); |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
974 |
case VEH_Ship: |
6240
8d4ea2d6befc
(svn r8699) [cpp_gui] -Cleanup: removed the word Window from some Window method names as just being Winddow methods indicates that it's working on a window
bjarni
parents:
6238
diff
changeset
|
975 |
w->Resize(27, 0); |
6034
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
976 |
break; |
89a7d10fa75b
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
6033
diff
changeset
|
977 |
case VEH_Aircraft: |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
978 |
AcceptPlanes acc_planes = (tile == 0) ? ALL : GetAirport(GetStationByTile(tile)->airport_type)->acc_planes; |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
979 |
bv->filter.acc_planes = acc_planes; |
6240
8d4ea2d6befc
(svn r8699) [cpp_gui] -Cleanup: removed the word Window from some Window method names as just being Winddow methods indicates that it's working on a window
bjarni
parents:
6238
diff
changeset
|
980 |
w->Resize(12, 0); |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
981 |
break; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
982 |
} |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
983 |
SetupWindowStrings(w, type); |
6075
33cdb35f9af5
(svn r8390) -Codechange (r8384): Rewrote ResizeButtons()
bjarni
parents:
6074
diff
changeset
|
984 |
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
|
985 |
|
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
986 |
w->resize.width = w->width; |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5919
diff
changeset
|
987 |
w->resize.height = w->height; |
4800
009e3c6cea8a
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
988 |
|
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
|
989 |
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
|
990 |
/* 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
|
991 |
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
|
992 |
} |