author | rubidium |
Wed, 17 Dec 2008 23:08:11 +0000 | |
changeset 10434 | 3659467c844c |
parent 10430 | 3125f2adebc5 |
permissions | -rw-r--r-- |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1 |
/* $Id$ */ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
2 |
|
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
9070
diff
changeset
|
3 |
/** @file build_vehicle_gui.cpp GUI for building vehicles. */ |
6123
04eb770ec17e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6091
diff
changeset
|
4 |
|
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
6 |
#include "openttd.h" |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
7 |
#include "train.h" |
5786
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
8 |
#include "roadveh.h" |
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
9 |
#include "ship.h" |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
10 |
#include "aircraft.h" |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
11 |
#include "debug.h" |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
12 |
#include "gui.h" |
6772
8672ba1bebc9
(svn r10008) -Codechange: Move a couple of functions related to articulated vehicles to a file of their own.
maedhros
parents:
6685
diff
changeset
|
13 |
#include "articulated_vehicles.h" |
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
14 |
#include "textbuf_gui.h" |
8116
8da76dcb3287
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8114
diff
changeset
|
15 |
#include "command_func.h" |
10208
72c00af5c95d
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents:
10207
diff
changeset
|
16 |
#include "company_func.h" |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
17 |
#include "airport.h" |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
18 |
#include "vehicle_gui.h" |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
19 |
#include "newgrf_engine.h" |
6091
c8827d9ae04a
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6087
diff
changeset
|
20 |
#include "cargotype.h" |
6643
f81bee57bc09
(svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
6638
diff
changeset
|
21 |
#include "group.h" |
6685
00490513d7b1
(svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents:
6643
diff
changeset
|
22 |
#include "road_map.h" |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8107
diff
changeset
|
23 |
#include "strings_func.h" |
8131
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8121
diff
changeset
|
24 |
#include "window_func.h" |
8140
0d0d8c94f84b
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8131
diff
changeset
|
25 |
#include "date_func.h" |
8144
65cec0877b78
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8140
diff
changeset
|
26 |
#include "vehicle_func.h" |
8211
29a8510dfd62
(svn r11774) -Change: do not include variables.h in a header when it is not needed.
rubidium
parents:
8148
diff
changeset
|
27 |
#include "settings_type.h" |
8224
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8222
diff
changeset
|
28 |
#include "gfx_func.h" |
8284
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
8264
diff
changeset
|
29 |
#include "widgets/dropdown_func.h" |
9164
18e971e0b44f
(svn r13027) -Codechange: use StrEmpty instead of arr[0] == '\0' and remove the need for WE_ON_EDIT_TEXT_CANCEL.
rubidium
parents:
9156
diff
changeset
|
30 |
#include "string_func.h" |
9274
42b67e65f1c2
(svn r13140) -Codechange: move the gui-list-sorting out of window_gui.h so window_gui.h only needs to be included in *_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
31 |
#include "window_gui.h" |
9380
62dabf4a5b7e
(svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138
parents:
9354
diff
changeset
|
32 |
#include "engine_gui.h" |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
33 |
|
8264
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
34 |
#include "table/sprites.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
35 |
#include "table/strings.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
36 |
|
5273
d9f707aa36a6
(svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents:
5215
diff
changeset
|
37 |
enum BuildVehicleWidgets { |
4800
5afc1bfc7a85
(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_CLOSEBOX = 0, |
5afc1bfc7a85
(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_CAPTION, |
5afc1bfc7a85
(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_SORT_ASSENDING_DESCENDING, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
41 |
BUILD_VEHICLE_WIDGET_SORT_DROPDOWN, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
42 |
BUILD_VEHICLE_WIDGET_LIST, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
43 |
BUILD_VEHICLE_WIDGET_SCROLLBAR, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
44 |
BUILD_VEHICLE_WIDGET_PANEL, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
45 |
BUILD_VEHICLE_WIDGET_BUILD, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
46 |
BUILD_VEHICLE_WIDGET_RENAME, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
47 |
BUILD_VEHICLE_WIDGET_RESIZE, |
6385
78f5307ce501
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6384
diff
changeset
|
48 |
BUILD_VEHICLE_WIDGET_END |
5273
d9f707aa36a6
(svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents:
5215
diff
changeset
|
49 |
}; |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
50 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
51 |
static const Widget _build_vehicle_widgets[] = { |
9751
9e9c726170cc
(svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas
parents:
9679
diff
changeset
|
52 |
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
9e9c726170cc
(svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas
parents:
9679
diff
changeset
|
53 |
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 239, 0, 13, 0x0, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
9e9c726170cc
(svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas
parents:
9679
diff
changeset
|
54 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP}, |
9e9c726170cc
(svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas
parents:
9679
diff
changeset
|
55 |
{ WWT_DROPDOWN, RESIZE_RIGHT, COLOUR_GREY, 81, 239, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
9e9c726170cc
(svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas
parents:
9679
diff
changeset
|
56 |
{ WWT_MATRIX, RESIZE_RB, COLOUR_GREY, 0, 227, 26, 39, 0x101, STR_NULL }, |
9e9c726170cc
(svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas
parents:
9679
diff
changeset
|
57 |
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 228, 239, 26, 39, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST }, |
9e9c726170cc
(svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas
parents:
9679
diff
changeset
|
58 |
{ WWT_PANEL, RESIZE_RTB, COLOUR_GREY, 0, 239, 40, 161, 0x0, STR_NULL }, |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
59 |
|
9751
9e9c726170cc
(svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas
parents:
9679
diff
changeset
|
60 |
{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 0, 114, 162, 173, 0x0, STR_NULL }, |
9e9c726170cc
(svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas
parents:
9679
diff
changeset
|
61 |
{ WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_GREY, 115, 227, 162, 173, 0x0, STR_NULL }, |
9e9c726170cc
(svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas
parents:
9679
diff
changeset
|
62 |
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 228, 239, 162, 173, 0x0, STR_RESIZE_BUTTON }, |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
63 |
{ WIDGETS_END}, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
64 |
}; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
65 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
66 |
static bool _internal_sort_order; // descending/ascending |
5784
a3b23f0fc794
(svn r8336) -Codechange: added function to translate vehicle types to 0,1,2... for use for index to arrays
bjarni
parents:
5783
diff
changeset
|
67 |
static byte _last_sort_criteria[] = {0, 0, 0, 0}; |
a3b23f0fc794
(svn r8336) -Codechange: added function to translate vehicle types to 0,1,2... for use for index to arrays
bjarni
parents:
5783
diff
changeset
|
68 |
static bool _last_sort_order[] = {false, false, false, false}; |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
69 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
70 |
static int CDECL EngineNumberSorter(const void *a, const void *b) |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
71 |
{ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
72 |
const EngineID va = *(const EngineID*)a; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
73 |
const EngineID vb = *(const EngineID*)b; |
9671
6f92245afcf1
(svn r13760) -Codechange: With multiple NewGRF engine sets, engine IDs may not be allocated in the order expected by GRF authors, so sort by 'list position' instead of engine ID for all vehicle types.
peter1138
parents:
9633
diff
changeset
|
74 |
int r = ListPositionOfEngine(va) - ListPositionOfEngine(vb); |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
75 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
76 |
return _internal_sort_order ? -r : r; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
77 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
78 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
79 |
static int CDECL EngineIntroDateSorter(const void *a, const void *b) |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
80 |
{ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
81 |
const int va = GetEngine(*(const EngineID*)a)->intro_date; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
82 |
const int vb = GetEngine(*(const EngineID*)b)->intro_date; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
83 |
const int r = va - vb; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
84 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
85 |
if (r == 0) { |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
86 |
/* Use EngineID to sort instead since we want consistent sorting */ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
87 |
return EngineNumberSorter(a, b); |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
88 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
89 |
return _internal_sort_order ? -r : r; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
90 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
91 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
92 |
static int CDECL EngineNameSorter(const void *a, const void *b) |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
93 |
{ |
4804
bfa7a5b5ad15
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
94 |
static EngineID last_engine[2] = { INVALID_ENGINE, INVALID_ENGINE }; |
bfa7a5b5ad15
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
95 |
static char last_name[2][64] = { "\0", "\0" }; |
bfa7a5b5ad15
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
96 |
|
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
97 |
const EngineID va = *(const EngineID*)a; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
98 |
const EngineID vb = *(const EngineID*)b; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
99 |
int r; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
100 |
|
4804
bfa7a5b5ad15
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
101 |
if (va != last_engine[0]) { |
bfa7a5b5ad15
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
102 |
last_engine[0] = va; |
7059
c6d12e3de0dc
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7009
diff
changeset
|
103 |
SetDParam(0, va); |
c6d12e3de0dc
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7009
diff
changeset
|
104 |
GetString(last_name[0], STR_ENGINE_NAME, lastof(last_name[0])); |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
105 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
106 |
|
4804
bfa7a5b5ad15
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
107 |
if (vb != last_engine[1]) { |
bfa7a5b5ad15
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
108 |
last_engine[1] = vb; |
7059
c6d12e3de0dc
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7009
diff
changeset
|
109 |
SetDParam(0, vb); |
c6d12e3de0dc
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7009
diff
changeset
|
110 |
GetString(last_name[1], STR_ENGINE_NAME, lastof(last_name[1])); |
4804
bfa7a5b5ad15
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
111 |
} |
bfa7a5b5ad15
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
112 |
|
bfa7a5b5ad15
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
113 |
r = strcmp(last_name[0], last_name[1]); // sort by name |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
114 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
115 |
if (r == 0) { |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
116 |
/* Use EngineID to sort instead since we want consistent sorting */ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
117 |
return EngineNumberSorter(a, b); |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
118 |
} |
4804
bfa7a5b5ad15
(svn r6726) -Codechange: [vehicle build window] cleaned up the name sorter (mainly by peter1138)
bjarni
parents:
4800
diff
changeset
|
119 |
return _internal_sort_order ? -r : r; |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
120 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
121 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
122 |
static int CDECL EngineReliabilitySorter(const void *a, const void *b) |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
123 |
{ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
124 |
const int va = GetEngine(*(const EngineID*)a)->reliability; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
125 |
const int vb = GetEngine(*(const EngineID*)b)->reliability; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
126 |
const int r = va - vb; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
127 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
128 |
if (r == 0) { |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
129 |
/* Use EngineID to sort instead since we want consistent sorting */ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
130 |
return EngineNumberSorter(a, b); |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
131 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
132 |
return _internal_sort_order ? -r : r; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
133 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
134 |
|
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
135 |
/* Train sorting functions */ |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
136 |
static int CDECL TrainEngineCostSorter(const void *a, const void *b) |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
137 |
{ |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
138 |
int va = RailVehInfo(*(const EngineID*)a)->cost_factor; |
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
139 |
int vb = RailVehInfo(*(const EngineID*)b)->cost_factor; |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
140 |
int r = va - vb; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
141 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
142 |
return _internal_sort_order ? -r : r; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
143 |
} |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
144 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
145 |
static int CDECL TrainEngineSpeedSorter(const void *a, const void *b) |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
146 |
{ |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
147 |
int va = RailVehInfo(*(const EngineID*)a)->max_speed; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
148 |
int vb = RailVehInfo(*(const EngineID*)b)->max_speed; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
149 |
int r = va - vb; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
150 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
151 |
return _internal_sort_order ? -r : r; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
152 |
} |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
153 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
154 |
static int CDECL TrainEnginePowerSorter(const void *a, const void *b) |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
155 |
{ |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
156 |
const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a); |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
157 |
const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b); |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
158 |
|
9208
191eb01c025a
(svn r13074) -Fix: For multiheaded engines, halve power and running cost when used instead of when loading, to allow callback values to work properly.
peter1138
parents:
9203
diff
changeset
|
159 |
int va = rvi_a->power; |
191eb01c025a
(svn r13074) -Fix: For multiheaded engines, halve power and running cost when used instead of when loading, to allow callback values to work properly.
peter1138
parents:
9203
diff
changeset
|
160 |
int vb = rvi_b->power; |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
161 |
int r = va - vb; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
162 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
163 |
return _internal_sort_order ? -r : r; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
164 |
} |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
165 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
166 |
static int CDECL TrainEngineRunningCostSorter(const void *a, const void *b) |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
167 |
{ |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
168 |
const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a); |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
169 |
const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b); |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
170 |
|
10071
6d96899c38db
(svn r14239) -Fix [FS#2267]: The engine-purchase-list-sorter doubled running-cost and halfed capacity of double-headed engines.
frosch
parents:
10000
diff
changeset
|
171 |
Money va = rvi_a->running_cost * GetPriceByIndex(rvi_a->running_cost_class); |
6d96899c38db
(svn r14239) -Fix [FS#2267]: The engine-purchase-list-sorter doubled running-cost and halfed capacity of double-headed engines.
frosch
parents:
10000
diff
changeset
|
172 |
Money vb = rvi_b->running_cost * GetPriceByIndex(rvi_b->running_cost_class); |
6990
136a08baf0ed
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
6787
diff
changeset
|
173 |
int r = ClampToI32(va - vb); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
174 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
175 |
return _internal_sort_order ? -r : r; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
176 |
} |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
177 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
178 |
static int CDECL TrainEnginePowerVsRunningCostSorter(const void *a, const void *b) |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
179 |
{ |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
180 |
const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a); |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
181 |
const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b); |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
182 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
183 |
/* Here we are using a few tricks to get the right sort. |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
184 |
* We want power/running cost, but since we usually got higher running cost than power and we store the result in an int, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
185 |
* we will actually calculate cunning cost/power (to make it more than 1). |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
186 |
* Because of this, the return value have to be reversed as well and we return b - a instead of a - b. |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
187 |
* Another thing is that both power and running costs should be doubled for multiheaded engines. |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
188 |
* Since it would be multipling with 2 in both numerator and denumerator, it will even themselves out and we skip checking for multiheaded. */ |
8626
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
189 |
Money va = (rvi_a->running_cost * GetPriceByIndex(rvi_a->running_cost_class)) / max(1U, (uint)rvi_a->power); |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
190 |
Money vb = (rvi_b->running_cost * GetPriceByIndex(rvi_b->running_cost_class)) / max(1U, (uint)rvi_b->power); |
6990
136a08baf0ed
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
6787
diff
changeset
|
191 |
int r = ClampToI32(vb - va); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
192 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
193 |
return _internal_sort_order ? -r : r; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
194 |
} |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
195 |
|
6786
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
196 |
static int CDECL TrainEngineCapacitySorter(const void *a, const void *b) |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
197 |
{ |
10071
6d96899c38db
(svn r14239) -Fix [FS#2267]: The engine-purchase-list-sorter doubled running-cost and halfed capacity of double-headed engines.
frosch
parents:
10000
diff
changeset
|
198 |
const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a); |
6d96899c38db
(svn r14239) -Fix [FS#2267]: The engine-purchase-list-sorter doubled running-cost and halfed capacity of double-headed engines.
frosch
parents:
10000
diff
changeset
|
199 |
const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b); |
6d96899c38db
(svn r14239) -Fix [FS#2267]: The engine-purchase-list-sorter doubled running-cost and halfed capacity of double-headed engines.
frosch
parents:
10000
diff
changeset
|
200 |
|
6d96899c38db
(svn r14239) -Fix [FS#2267]: The engine-purchase-list-sorter doubled running-cost and halfed capacity of double-headed engines.
frosch
parents:
10000
diff
changeset
|
201 |
int va = rvi_a->capacity * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1); |
6d96899c38db
(svn r14239) -Fix [FS#2267]: The engine-purchase-list-sorter doubled running-cost and halfed capacity of double-headed engines.
frosch
parents:
10000
diff
changeset
|
202 |
int vb = rvi_b->capacity * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1); |
6786
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
203 |
int r = va - vb; |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
204 |
|
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
205 |
if (r == 0) { |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
206 |
/* Use EngineID to sort instead since we want consistent sorting */ |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
207 |
return EngineNumberSorter(a, b); |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
208 |
} |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
209 |
return _internal_sort_order ? -r : r; |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
210 |
} |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
211 |
|
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
212 |
static int CDECL TrainEnginesThenWagonsSorter(const void *a, const void *b) |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
213 |
{ |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
214 |
EngineID va = *(const EngineID*)a; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
215 |
EngineID vb = *(const EngineID*)b; |
5871
a98c86408de4
(svn r8460) -Fix (r8455): the build train window put locomotives and wagons in appeantly random order
bjarni
parents:
5868
diff
changeset
|
216 |
int val_a = (RailVehInfo(va)->railveh_type == RAILVEH_WAGON ? 1 : 0); |
a98c86408de4
(svn r8460) -Fix (r8455): the build train window put locomotives and wagons in appeantly random order
bjarni
parents:
5868
diff
changeset
|
217 |
int val_b = (RailVehInfo(vb)->railveh_type == RAILVEH_WAGON ? 1 : 0); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
218 |
int r = val_a - val_b; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
219 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
220 |
/* Use EngineID to sort instead since we want consistent sorting */ |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
221 |
if (r == 0) return EngineNumberSorter(a, b); |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
222 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
223 |
return _internal_sort_order ? -r : r; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
224 |
} |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
225 |
|
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
226 |
/* Road vehicle sorting functions */ |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
227 |
static int CDECL RoadVehEngineCostSorter(const void *a, const void *b) |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
228 |
{ |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
229 |
int va = RoadVehInfo(*(const EngineID*)a)->cost_factor; |
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
230 |
int vb = RoadVehInfo(*(const EngineID*)b)->cost_factor; |
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
231 |
int r = va - vb; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
232 |
|
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
233 |
return _internal_sort_order ? -r : r; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
234 |
} |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
235 |
|
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
236 |
static int CDECL RoadVehEngineSpeedSorter(const void *a, const void *b) |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
237 |
{ |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
238 |
int va = RoadVehInfo(*(const EngineID*)a)->max_speed; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
239 |
int vb = RoadVehInfo(*(const EngineID*)b)->max_speed; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
240 |
int r = va - vb; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
241 |
|
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
242 |
return _internal_sort_order ? -r : r; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
243 |
} |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
244 |
|
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
245 |
static int CDECL RoadVehEngineRunningCostSorter(const void *a, const void *b) |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
246 |
{ |
8626
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
247 |
const RoadVehicleInfo *rvi_a = RoadVehInfo(*(const EngineID*)a); |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
248 |
const RoadVehicleInfo *rvi_b = RoadVehInfo(*(const EngineID*)b); |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
249 |
|
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
250 |
Money va = rvi_a->running_cost * GetPriceByIndex(rvi_a->running_cost_class); |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
251 |
Money vb = rvi_b->running_cost * GetPriceByIndex(rvi_b->running_cost_class); |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
252 |
int r = ClampToI32(va - vb); |
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
253 |
|
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
254 |
if (r == 0) { |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
255 |
/* Use EngineID to sort instead since we want consistent sorting */ |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
256 |
return EngineNumberSorter(a, b); |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
257 |
} |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
258 |
return _internal_sort_order ? -r : r; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
259 |
} |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
260 |
|
6786
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
261 |
static int CDECL RoadVehEngineCapacitySorter(const void *a, const void *b) |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
262 |
{ |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
263 |
int va = RoadVehInfo(*(const EngineID*)a)->capacity; |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
264 |
int vb = RoadVehInfo(*(const EngineID*)b)->capacity; |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
265 |
int r = va - vb; |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
266 |
|
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
267 |
if (r == 0) { |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
268 |
/* Use EngineID to sort instead since we want consistent sorting */ |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
269 |
return EngineNumberSorter(a, b); |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
270 |
} |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
271 |
return _internal_sort_order ? -r : r; |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
272 |
} |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
273 |
|
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
274 |
/* Road vehicle sorting functions */ |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
275 |
static int CDECL ShipEngineCostSorter(const void *a, const void *b) |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
276 |
{ |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
277 |
int va = ShipVehInfo(*(const EngineID*)a)->cost_factor; |
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
278 |
int vb = ShipVehInfo(*(const EngineID*)b)->cost_factor; |
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
279 |
int r = va - vb; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
280 |
|
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
281 |
return _internal_sort_order ? -r : r; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
282 |
} |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
283 |
|
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
284 |
static int CDECL ShipEngineSpeedSorter(const void *a, const void *b) |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
285 |
{ |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
286 |
int va = ShipVehInfo(*(const EngineID*)a)->max_speed; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
287 |
int vb = ShipVehInfo(*(const EngineID*)b)->max_speed; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
288 |
int r = va - vb; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
289 |
|
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
290 |
return _internal_sort_order ? -r : r; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
291 |
} |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
292 |
|
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
293 |
static int CDECL ShipEngineRunningCostSorter(const void *a, const void *b) |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
294 |
{ |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
295 |
const int va = ShipVehInfo(*(const EngineID*)a)->running_cost; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
296 |
const int vb = ShipVehInfo(*(const EngineID*)b)->running_cost; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
297 |
const int r = va - vb; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
298 |
|
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
299 |
if (r == 0) { |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
300 |
/* Use EngineID to sort instead since we want consistent sorting */ |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
301 |
return EngineNumberSorter(a, b); |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
302 |
} |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
303 |
return _internal_sort_order ? -r : r; |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
304 |
} |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
305 |
|
6786
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
306 |
static int CDECL ShipEngineCapacitySorter(const void *a, const void *b) |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
307 |
{ |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
308 |
int va = ShipVehInfo(*(const EngineID*)a)->capacity; |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
309 |
int vb = ShipVehInfo(*(const EngineID*)b)->capacity; |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
310 |
int r = va - vb; |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
311 |
|
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
312 |
if (r == 0) { |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
313 |
/* Use EngineID to sort instead since we want consistent sorting */ |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
314 |
return EngineNumberSorter(a, b); |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
315 |
} |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
316 |
return _internal_sort_order ? -r : r; |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
317 |
} |
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
318 |
|
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
319 |
/* Aircraft sorting functions */ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
320 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
321 |
static int CDECL AircraftEngineCostSorter(const void *a, const void *b) |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
322 |
{ |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
323 |
const int va = AircraftVehInfo(*(const EngineID*)a)->cost_factor; |
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
324 |
const int vb = AircraftVehInfo(*(const EngineID*)b)->cost_factor; |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
325 |
int r = va - vb; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
326 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
327 |
return _internal_sort_order ? -r : r; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
328 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
329 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
330 |
static int CDECL AircraftEngineSpeedSorter(const void *a, const void *b) |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
331 |
{ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
332 |
const int va = AircraftVehInfo(*(const EngineID*)a)->max_speed; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
333 |
const int vb = AircraftVehInfo(*(const EngineID*)b)->max_speed; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
334 |
const int r = va - vb; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
335 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
336 |
if (r == 0) { |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
337 |
/* Use EngineID to sort instead since we want consistent sorting */ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
338 |
return EngineNumberSorter(a, b); |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
339 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
340 |
return _internal_sort_order ? -r : r; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
341 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
342 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
343 |
static int CDECL AircraftEngineRunningCostSorter(const void *a, const void *b) |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
344 |
{ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
345 |
const int va = AircraftVehInfo(*(const EngineID*)a)->running_cost; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
346 |
const int vb = AircraftVehInfo(*(const EngineID*)b)->running_cost; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
347 |
const int r = va - vb; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
348 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
349 |
if (r == 0) { |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
350 |
/* Use EngineID to sort instead since we want consistent sorting */ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
351 |
return EngineNumberSorter(a, b); |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
352 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
353 |
return _internal_sort_order ? -r : r; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
354 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
355 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
356 |
static int CDECL AircraftEngineCargoSorter(const void *a, const void *b) |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
357 |
{ |
6787
47f6921e8c4c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
6786
diff
changeset
|
358 |
int va = AircraftVehInfo(*(const EngineID*)a)->passenger_capacity; |
47f6921e8c4c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
6786
diff
changeset
|
359 |
int vb = AircraftVehInfo(*(const EngineID*)b)->passenger_capacity; |
47f6921e8c4c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
6786
diff
changeset
|
360 |
int r = va - vb; |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
361 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
362 |
if (r == 0) { |
6787
47f6921e8c4c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
6786
diff
changeset
|
363 |
/* The planes has the same passenger capacity. Check mail capacity instead */ |
47f6921e8c4c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
6786
diff
changeset
|
364 |
va = AircraftVehInfo(*(const EngineID*)a)->mail_capacity; |
47f6921e8c4c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
6786
diff
changeset
|
365 |
vb = AircraftVehInfo(*(const EngineID*)b)->mail_capacity; |
47f6921e8c4c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
6786
diff
changeset
|
366 |
r = va - vb; |
47f6921e8c4c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
6786
diff
changeset
|
367 |
|
47f6921e8c4c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
6786
diff
changeset
|
368 |
if (r == 0) { |
47f6921e8c4c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
6786
diff
changeset
|
369 |
/* Use EngineID to sort instead since we want consistent sorting */ |
47f6921e8c4c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
6786
diff
changeset
|
370 |
return EngineNumberSorter(a, b); |
47f6921e8c4c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
bjarni
parents:
6786
diff
changeset
|
371 |
} |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
372 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
373 |
return _internal_sort_order ? -r : r; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
374 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
375 |
|
6786
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
376 |
static EngList_SortTypeFunction * const _sorter[][10] = {{ |
5790
d4a732968bda
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
5787
diff
changeset
|
377 |
/* Trains */ |
9671
6f92245afcf1
(svn r13760) -Codechange: With multiple NewGRF engine sets, engine IDs may not be allocated in the order expected by GRF authors, so sort by 'list position' instead of engine ID for all vehicle types.
peter1138
parents:
9633
diff
changeset
|
378 |
&EngineNumberSorter, |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
379 |
&TrainEngineCostSorter, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
380 |
&TrainEngineSpeedSorter, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
381 |
&TrainEnginePowerSorter, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
382 |
&EngineIntroDateSorter, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
383 |
&EngineNameSorter, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
384 |
&TrainEngineRunningCostSorter, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
385 |
&TrainEnginePowerVsRunningCostSorter, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
386 |
&EngineReliabilitySorter, |
6786
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
387 |
&TrainEngineCapacitySorter, |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6386
diff
changeset
|
388 |
}, { |
5790
d4a732968bda
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
5787
diff
changeset
|
389 |
/* Road vehicles */ |
5785
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
390 |
&EngineNumberSorter, |
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
391 |
&RoadVehEngineCostSorter, |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
392 |
&RoadVehEngineSpeedSorter, |
5785
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
393 |
&EngineIntroDateSorter, |
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
394 |
&EngineNameSorter, |
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
395 |
&RoadVehEngineRunningCostSorter, |
5785
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
396 |
&EngineReliabilitySorter, |
6786
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
397 |
&RoadVehEngineCapacitySorter, |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6386
diff
changeset
|
398 |
}, { |
5790
d4a732968bda
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
5787
diff
changeset
|
399 |
/* Ships */ |
5785
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
400 |
&EngineNumberSorter, |
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
401 |
&ShipEngineCostSorter, |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
402 |
&ShipEngineSpeedSorter, |
5785
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
403 |
&EngineIntroDateSorter, |
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
404 |
&EngineNameSorter, |
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
405 |
&ShipEngineRunningCostSorter, |
5785
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
406 |
&EngineReliabilitySorter, |
6786
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
407 |
&ShipEngineCapacitySorter, |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6386
diff
changeset
|
408 |
}, { |
5790
d4a732968bda
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
5787
diff
changeset
|
409 |
/* Aircraft */ |
5785
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
410 |
&EngineNumberSorter, |
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
411 |
&AircraftEngineCostSorter, |
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
412 |
&AircraftEngineSpeedSorter, |
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
413 |
&EngineIntroDateSorter, |
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
414 |
&EngineNameSorter, |
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
415 |
&AircraftEngineRunningCostSorter, |
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
416 |
&EngineReliabilitySorter, |
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
417 |
&AircraftEngineCargoSorter, |
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
418 |
}}; |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
419 |
|
6786
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
420 |
static const StringID _sort_listing[][11] = {{ |
5790
d4a732968bda
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
5787
diff
changeset
|
421 |
/* Trains */ |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
422 |
STR_ENGINE_SORT_ENGINE_ID, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
423 |
STR_ENGINE_SORT_COST, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
424 |
STR_SORT_BY_MAX_SPEED, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
425 |
STR_ENGINE_SORT_POWER, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
426 |
STR_ENGINE_SORT_INTRO_DATE, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
427 |
STR_SORT_BY_DROPDOWN_NAME, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
428 |
STR_ENGINE_SORT_RUNNING_COST, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
429 |
STR_ENGINE_SORT_POWER_VS_RUNNING_COST, |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
430 |
STR_SORT_BY_RELIABILITY, |
6786
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
431 |
STR_ENGINE_SORT_CARGO_CAPACITY, |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
432 |
INVALID_STRING_ID |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6386
diff
changeset
|
433 |
}, { |
5790
d4a732968bda
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
5787
diff
changeset
|
434 |
/* Road vehicles */ |
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
435 |
STR_ENGINE_SORT_ENGINE_ID, |
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
436 |
STR_ENGINE_SORT_COST, |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
437 |
STR_SORT_BY_MAX_SPEED, |
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
438 |
STR_ENGINE_SORT_INTRO_DATE, |
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
439 |
STR_SORT_BY_DROPDOWN_NAME, |
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
440 |
STR_ENGINE_SORT_RUNNING_COST, |
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
441 |
STR_SORT_BY_RELIABILITY, |
6786
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
442 |
STR_ENGINE_SORT_CARGO_CAPACITY, |
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
443 |
INVALID_STRING_ID |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6386
diff
changeset
|
444 |
}, { |
5790
d4a732968bda
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
5787
diff
changeset
|
445 |
/* Ships */ |
5785
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
446 |
STR_ENGINE_SORT_ENGINE_ID, |
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
447 |
STR_ENGINE_SORT_COST, |
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
448 |
STR_SORT_BY_MAX_SPEED, |
5785
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
449 |
STR_ENGINE_SORT_INTRO_DATE, |
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
450 |
STR_SORT_BY_DROPDOWN_NAME, |
8148
0e857887bbfa
(svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows
bjarni
parents:
8144
diff
changeset
|
451 |
STR_ENGINE_SORT_RUNNING_COST, |
5785
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
452 |
STR_SORT_BY_RELIABILITY, |
6786
f938f80a255f
(svn r10024) -Feature: [build windows] trains, road vehicles and ships can now be sorted by cargo capacity (planes already had this option)
bjarni
parents:
6772
diff
changeset
|
453 |
STR_ENGINE_SORT_CARGO_CAPACITY, |
5785
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
454 |
INVALID_STRING_ID |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6386
diff
changeset
|
455 |
}, { |
5790
d4a732968bda
(svn r8343) -Cleanup: [build vehicle windows] added a few comments and removed two switch-cases, that we can do without
bjarni
parents:
5787
diff
changeset
|
456 |
/* Aircraft */ |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
457 |
STR_ENGINE_SORT_ENGINE_ID, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
458 |
STR_ENGINE_SORT_COST, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
459 |
STR_SORT_BY_MAX_SPEED, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
460 |
STR_ENGINE_SORT_INTRO_DATE, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
461 |
STR_SORT_BY_DROPDOWN_NAME, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
462 |
STR_ENGINE_SORT_RUNNING_COST, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
463 |
STR_SORT_BY_RELIABILITY, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
464 |
STR_ENGINE_SORT_CARGO_CAPACITY, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
465 |
INVALID_STRING_ID |
5785
5205f8b7fef5
(svn r8337) -Cleanup: removed some more switch-cases in build_vehicle_gui.cpp and added arrays + VehTypeToIndex() instead
bjarni
parents:
5784
diff
changeset
|
466 |
}}; |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
467 |
|
8559
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
468 |
static int DrawCargoCapacityInfo(int x, int y, EngineID engine, VehicleType type, bool refittable) |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
469 |
{ |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
470 |
uint16 *cap = GetCapacityOfArticulatedParts(engine, type); |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
471 |
|
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
472 |
for (uint c = 0; c < NUM_CARGO; c++) { |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
473 |
if (cap[c] == 0) continue; |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
474 |
|
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
475 |
SetDParam(0, c); |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
476 |
SetDParam(1, cap[c]); |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
477 |
SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY); |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
478 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING); |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
479 |
y += 10; |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
480 |
|
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
481 |
/* Only show as refittable once */ |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
482 |
refittable = false; |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
483 |
} |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
484 |
|
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
485 |
return y; |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
486 |
} |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
487 |
|
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
488 |
/* Draw rail wagon specific details */ |
5817
0bd3e66ece83
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
5816
diff
changeset
|
489 |
static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi) |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
490 |
{ |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
491 |
/* Purchase cost */ |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
492 |
SetDParam(0, (GetEngineProperty(engine_number, 0x17, rvi->cost_factor) * _price.build_railwagon) >> 8); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
493 |
DrawString(x, y, STR_PURCHASE_INFO_COST, TC_FROMSTRING); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
494 |
y += 10; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
495 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
496 |
/* Wagon weight - (including cargo) */ |
6595
5239d6e72066
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
6592
diff
changeset
|
497 |
uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight); |
5239d6e72066
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
6592
diff
changeset
|
498 |
SetDParam(0, weight); |
6608
dc0b009642a4
(svn r9828) -Codechange: [NewGRF] Add support for changing cargo capacity with callback 36. This is set on construction for ships and roadvehicles, and whenever carriages are attached for trains.
peter1138
parents:
6595
diff
changeset
|
499 |
SetDParam(1, (GetCargo(rvi->cargo_type)->weight * GetEngineProperty(engine_number, 0x14, rvi->capacity) >> 4) + weight); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
500 |
DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, TC_FROMSTRING); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
501 |
y += 10; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
502 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
503 |
/* Wagon speed limit, displayed if above zero */ |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9403
diff
changeset
|
504 |
if (_settings_game.vehicle.wagon_speed_limits) { |
6595
5239d6e72066
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
6592
diff
changeset
|
505 |
uint max_speed = GetEngineProperty(engine_number, 0x09, rvi->max_speed); |
5239d6e72066
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
6592
diff
changeset
|
506 |
if (max_speed > 0) { |
5239d6e72066
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
6592
diff
changeset
|
507 |
SetDParam(0, max_speed * 10 / 16); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
508 |
DrawString(x, y, STR_PURCHASE_INFO_SPEED, TC_FROMSTRING); |
6595
5239d6e72066
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
6592
diff
changeset
|
509 |
y += 10; |
5239d6e72066
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
6592
diff
changeset
|
510 |
} |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
511 |
} |
8626
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
512 |
|
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
513 |
/* Running cost */ |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
514 |
if (rvi->running_cost_class != 0xFF) { |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
515 |
SetDParam(0, GetEngineProperty(engine_number, 0x0D, rvi->running_cost) * GetPriceByIndex(rvi->running_cost_class) >> 8); |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
516 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING); |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
517 |
y += 10; |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
518 |
} |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
519 |
|
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
520 |
return y; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
521 |
} |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
522 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
523 |
/* Draw locomotive specific details */ |
5823 | 524 |
static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi) |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
525 |
{ |
5868
94430141c189
(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:
5824
diff
changeset
|
526 |
int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0); |
6595
5239d6e72066
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
6592
diff
changeset
|
527 |
uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
528 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
529 |
/* Purchase Cost - Engine weight */ |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
530 |
SetDParam(0, GetEngineProperty(engine_number, 0x17, rvi->cost_factor) * (_price.build_railvehicle >> 3) >> 5); |
6595
5239d6e72066
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
6592
diff
changeset
|
531 |
SetDParam(1, weight << multihead); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
532 |
DrawString(x, y, STR_PURCHASE_INFO_COST_WEIGHT, TC_FROMSTRING); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
533 |
y += 10; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
534 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
535 |
/* Max speed - Engine power */ |
6595
5239d6e72066
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
6592
diff
changeset
|
536 |
SetDParam(0, GetEngineProperty(engine_number, 0x09, rvi->max_speed) * 10 / 16); |
9208
191eb01c025a
(svn r13074) -Fix: For multiheaded engines, halve power and running cost when used instead of when loading, to allow callback values to work properly.
peter1138
parents:
9203
diff
changeset
|
537 |
SetDParam(1, GetEngineProperty(engine_number, 0x0B, rvi->power)); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
538 |
DrawString(x, y, STR_PURCHASE_INFO_SPEED_POWER, TC_FROMSTRING); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
539 |
y += 10; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
540 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
541 |
/* Max tractive effort - not applicable if old acceleration or maglev */ |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9403
diff
changeset
|
542 |
if (_settings_game.vehicle.realistic_acceleration && rvi->railtype != RAILTYPE_MAGLEV) { |
6595
5239d6e72066
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
6592
diff
changeset
|
543 |
SetDParam(0, ((weight << multihead) * 10 * GetEngineProperty(engine_number, 0x1F, rvi->tractive_effort)) / 256); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
544 |
DrawString(x, y, STR_PURCHASE_INFO_MAX_TE, TC_FROMSTRING); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
545 |
y += 10; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
546 |
} |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
547 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
548 |
/* Running cost */ |
8626
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
549 |
if (rvi->running_cost_class != 0xFF) { |
9208
191eb01c025a
(svn r13074) -Fix: For multiheaded engines, halve power and running cost when used instead of when loading, to allow callback values to work properly.
peter1138
parents:
9203
diff
changeset
|
550 |
SetDParam(0, GetEngineProperty(engine_number, 0x0D, rvi->running_cost) * GetPriceByIndex(rvi->running_cost_class) >> 8); |
8626
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
551 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING); |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
552 |
y += 10; |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
553 |
} |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
554 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
555 |
/* Powered wagons power - Powered wagons extra weight */ |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
556 |
if (rvi->pow_wag_power != 0) { |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
557 |
SetDParam(0, rvi->pow_wag_power); |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
558 |
SetDParam(1, rvi->pow_wag_weight); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
559 |
DrawString(x, y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT, TC_FROMSTRING); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
560 |
y += 10; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
561 |
}; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
562 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
563 |
return y; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
564 |
} |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
565 |
|
5786
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
566 |
/* Draw road vehicle specific details */ |
5817
0bd3e66ece83
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
5816
diff
changeset
|
567 |
static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const RoadVehicleInfo *rvi) |
5786
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
568 |
{ |
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
569 |
/* Purchase cost - Max speed */ |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
570 |
SetDParam(0, GetEngineProperty(engine_number, 0x11, rvi->cost_factor) * (_price.roadveh_base >> 3) >> 5); |
5874
2db89a640b7a
(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:
5871
diff
changeset
|
571 |
SetDParam(1, rvi->max_speed * 10 / 32); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
572 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING); |
5786
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
573 |
y += 10; |
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
574 |
|
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
575 |
/* Running cost */ |
8626
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
576 |
SetDParam(0, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) >> 8); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
577 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING); |
5786
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
578 |
y += 10; |
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
579 |
|
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
580 |
/* Cargo type + capacity */ |
10430
3125f2adebc5
(svn r14683) -Change: only say a engine/vehicle is refittable when it can be refitted to at least two cargo type or when it has subcargos.
rubidium
parents:
10208
diff
changeset
|
581 |
return DrawCargoCapacityInfo(x, y, engine_number, VEH_ROAD, IsEngineRefittable(engine_number)); |
5786
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
582 |
} |
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
583 |
|
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
584 |
/* Draw ship specific details */ |
5817
0bd3e66ece83
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
5816
diff
changeset
|
585 |
static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi) |
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
586 |
{ |
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
587 |
/* Purchase cost - Max speed */ |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
588 |
SetDParam(0, GetEngineProperty(engine_number, 0x0A, svi->cost_factor) * (_price.ship_base >> 3) >> 5); |
6595
5239d6e72066
(svn r9809) -Codechange: [NewGRF] Add callback 36 properties to purchase lists and add running cost changing for ships.
peter1138
parents:
6592
diff
changeset
|
589 |
SetDParam(1, GetEngineProperty(engine_number, 0x0B, svi->max_speed) * 10 / 32); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
590 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING); |
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
591 |
y += 10; |
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
592 |
|
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
593 |
/* Cargo type + capacity */ |
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
594 |
SetDParam(0, svi->cargo_type); |
6608
dc0b009642a4
(svn r9828) -Codechange: [NewGRF] Add support for changing cargo capacity with callback 36. This is set on construction for ships and roadvehicles, and whenever carriages are attached for trains.
peter1138
parents:
6595
diff
changeset
|
595 |
SetDParam(1, GetEngineProperty(engine_number, 0x0D, svi->capacity)); |
10430
3125f2adebc5
(svn r14683) -Change: only say a engine/vehicle is refittable when it can be refitted to at least two cargo type or when it has subcargos.
rubidium
parents:
10208
diff
changeset
|
596 |
SetDParam(2, IsEngineRefittable(engine_number) ? STR_9842_REFITTABLE : STR_EMPTY); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
597 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING); |
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
598 |
y += 10; |
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
599 |
|
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
600 |
/* Running cost */ |
7002
1bf6a62b0fcb
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
6991
diff
changeset
|
601 |
SetDParam(0, GetEngineProperty(engine_number, 0x0F, svi->running_cost) * _price.ship_running >> 8); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
602 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING); |
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
603 |
y += 10; |
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
604 |
|
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
605 |
return y; |
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
606 |
} |
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
607 |
|
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
608 |
/* Draw aircraft specific details */ |
5817
0bd3e66ece83
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
5816
diff
changeset
|
609 |
static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const AircraftVehicleInfo *avi) |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
610 |
{ |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
611 |
CargoID cargo; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
612 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
613 |
/* Purchase cost - Max speed */ |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9913
diff
changeset
|
614 |
SetDParam(0, GetEngineProperty(engine_number, 0x0B, avi->cost_factor) * (_price.aircraft_base >> 3) >> 5); |
6193
6f20de9e4f1b
(svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar
parents:
6123
diff
changeset
|
615 |
SetDParam(1, avi->max_speed * 10 / 16); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
616 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING); |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
617 |
y += 10; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
618 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
619 |
/* Cargo capacity */ |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
620 |
cargo = FindFirstRefittableCargo(engine_number); |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
621 |
if (cargo == CT_INVALID || cargo == CT_PASSENGERS) { |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
622 |
SetDParam(0, avi->passenger_capacity); |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
623 |
SetDParam(1, avi->mail_capacity); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
624 |
DrawString(x, y, STR_PURCHASE_INFO_AIRCRAFT_CAPACITY, TC_FROMSTRING); |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
625 |
} else { |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
626 |
/* Note, if the default capacity is selected by the refit capacity |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
627 |
* callback, then the capacity shown is likely to be incorrect. */ |
4896
f86350aaaaa5
(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
|
628 |
SetDParam(0, cargo); |
6087 | 629 |
SetDParam(1, AircraftDefaultCargoCapacity(cargo, avi)); |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
630 |
SetDParam(2, STR_9842_REFITTABLE); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
631 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING); |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
632 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
633 |
y += 10; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
634 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
635 |
/* Running cost */ |
7002
1bf6a62b0fcb
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
6991
diff
changeset
|
636 |
SetDParam(0, GetEngineProperty(engine_number, 0x0E, avi->running_cost) * _price.aircraft_running >> 8); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
637 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING); |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
638 |
y += 10; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
639 |
|
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
640 |
return y; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
641 |
} |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
642 |
|
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
643 |
/** |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
644 |
* Draw the purchase info details of a vehicle at a given location. |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
645 |
* @param x,y location where to draw the info |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
646 |
* @param w how wide are the text allowed to be (size of widget/window to Draw in) |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
647 |
* @param engine_number the engine of which to draw the info of |
6385
78f5307ce501
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6384
diff
changeset
|
648 |
* @return y after drawing all the text |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
649 |
*/ |
6385
78f5307ce501
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6384
diff
changeset
|
650 |
int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number) |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
651 |
{ |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
652 |
const Engine *e = GetEngine(engine_number); |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
653 |
YearMonthDay ymd; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
654 |
ConvertDateToYMD(e->intro_date, &ymd); |
10430
3125f2adebc5
(svn r14683) -Change: only say a engine/vehicle is refittable when it can be refitted to at least two cargo type or when it has subcargos.
rubidium
parents:
10208
diff
changeset
|
655 |
bool refittable = IsEngineRefittable(engine_number); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
656 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
657 |
switch (e->type) { |
6638
09c5d7bf69a5
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents:
6608
diff
changeset
|
658 |
default: NOT_REACHED(); |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6237
diff
changeset
|
659 |
case VEH_TRAIN: { |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
660 |
const RailVehicleInfo *rvi = RailVehInfo(engine_number); |
10430
3125f2adebc5
(svn r14683) -Change: only say a engine/vehicle is refittable when it can be refitted to at least two cargo type or when it has subcargos.
rubidium
parents:
10208
diff
changeset
|
661 |
refittable &= GetEngineProperty(engine_number, 0x14, rvi->capacity) > 0; |
5819
77fa0b7a6065
(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:
5817
diff
changeset
|
662 |
|
5868
94430141c189
(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:
5824
diff
changeset
|
663 |
if (rvi->railveh_type == RAILVEH_WAGON) { |
5817
0bd3e66ece83
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
5816
diff
changeset
|
664 |
y = DrawRailWagonPurchaseInfo(x, y, engine_number, rvi); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
665 |
} else { |
5823 | 666 |
y = DrawRailEnginePurchaseInfo(x, y, engine_number, rvi); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
667 |
} |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
668 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
669 |
/* Cargo type + capacity, or N/A */ |
10430
3125f2adebc5
(svn r14683) -Change: only say a engine/vehicle is refittable when it can be refitted to at least two cargo type or when it has subcargos.
rubidium
parents:
10208
diff
changeset
|
670 |
int new_y = DrawCargoCapacityInfo(x, y, engine_number, VEH_TRAIN, refittable); |
8559
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
671 |
|
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
672 |
if (new_y == y) { |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
673 |
SetDParam(0, CT_INVALID); |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
674 |
SetDParam(2, STR_EMPTY); |
8559
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
675 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING); |
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
676 |
y += 10; |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
677 |
} else { |
8559
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
678 |
y = new_y; |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
679 |
} |
8559
e51166aff0b2
(svn r12137) -Fix [FS#1769]: Show cargo capacity for articulated vehicles correctly in the purchase list. Multiple cargo types can also now been shown.
peter1138
parents:
8479
diff
changeset
|
680 |
break; |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
681 |
} |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6237
diff
changeset
|
682 |
case VEH_ROAD: |
5817
0bd3e66ece83
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
5816
diff
changeset
|
683 |
y = DrawRoadVehPurchaseInfo(x, y, engine_number, RoadVehInfo(engine_number)); |
5786
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
684 |
break; |
10430
3125f2adebc5
(svn r14683) -Change: only say a engine/vehicle is refittable when it can be refitted to at least two cargo type or when it has subcargos.
rubidium
parents:
10208
diff
changeset
|
685 |
case VEH_SHIP: |
3125f2adebc5
(svn r14683) -Change: only say a engine/vehicle is refittable when it can be refitted to at least two cargo type or when it has subcargos.
rubidium
parents:
10208
diff
changeset
|
686 |
y = DrawShipPurchaseInfo(x, y, engine_number, ShipVehInfo(engine_number)); |
3125f2adebc5
(svn r14683) -Change: only say a engine/vehicle is refittable when it can be refitted to at least two cargo type or when it has subcargos.
rubidium
parents:
10208
diff
changeset
|
687 |
break; |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6237
diff
changeset
|
688 |
case VEH_AIRCRAFT: |
5817
0bd3e66ece83
(svn r8379) -Cleanup: [build vehicle window] removed overloading with DrawVehiclePurchaseInfo() and renamed them into type specific names
bjarni
parents:
5816
diff
changeset
|
689 |
y = DrawAircraftPurchaseInfo(x, y, engine_number, AircraftVehInfo(engine_number)); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
690 |
break; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
691 |
} |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
692 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
693 |
/* Draw details, that applies to all types except rail wagons */ |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6237
diff
changeset
|
694 |
if (e->type != VEH_TRAIN || RailVehInfo(engine_number)->railveh_type != RAILVEH_WAGON) { |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
695 |
/* Design date - Life length */ |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
696 |
SetDParam(0, ymd.year); |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
697 |
SetDParam(1, e->lifelength); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
698 |
DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, TC_FROMSTRING); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
699 |
y += 10; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
700 |
|
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
701 |
/* Reliability */ |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
702 |
SetDParam(0, e->reliability * 100 >> 16); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7763
diff
changeset
|
703 |
DrawString(x, y, STR_PURCHASE_INFO_RELIABILITY, TC_FROMSTRING); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
704 |
y += 10; |
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
705 |
} |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
706 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
707 |
/* Additional text from NewGRF */ |
4930
708801d486c6
(svn r6910) - Codechange: Supply width of area when drawing purchase info instead of using hardcoded values. (mart3p)
peter1138
parents:
4912
diff
changeset
|
708 |
y += ShowAdditionalText(x, y, w, engine_number); |
10430
3125f2adebc5
(svn r14683) -Change: only say a engine/vehicle is refittable when it can be refitted to at least two cargo type or when it has subcargos.
rubidium
parents:
10208
diff
changeset
|
709 |
if (refittable) y += ShowRefitOptionsList(x, y, w, engine_number); |
6385
78f5307ce501
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6384
diff
changeset
|
710 |
|
78f5307ce501
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6384
diff
changeset
|
711 |
return y; |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
712 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
713 |
|
8479
05ee5ae44a55
(svn r12054) -Cleanup: Use VehicleType instead of byte for vehicle types...
peter1138
parents:
8418
diff
changeset
|
714 |
static void DrawVehicleEngine(VehicleType type, int x, int y, EngineID engine, SpriteID pal) |
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
715 |
{ |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
716 |
switch (type) { |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6237
diff
changeset
|
717 |
case VEH_TRAIN: DrawTrainEngine( x, y, engine, pal); break; |
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6237
diff
changeset
|
718 |
case VEH_ROAD: DrawRoadVehEngine( x, y, engine, pal); break; |
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6237
diff
changeset
|
719 |
case VEH_SHIP: DrawShipEngine( x, y, engine, pal); break; |
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6237
diff
changeset
|
720 |
case VEH_AIRCRAFT: DrawAircraftEngine(x, y, engine, pal); break; |
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
721 |
default: NOT_REACHED(); |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
722 |
} |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
723 |
} |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
724 |
|
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
725 |
/** Engine drawing loop |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
726 |
* @param type Type of vehicle (VEH_*) |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
727 |
* @param x,y Where should the list start |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
728 |
* @param eng_list What engines to draw |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
729 |
* @param min where to start in the list |
5802
e770857f092f
(svn r8364) -Codechange (r8362): added an assert to catch conditions where a request wants to draw more vehicles than the list contains
bjarni
parents:
5800
diff
changeset
|
730 |
* @param max where in the list to end |
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
731 |
* @param selected_id what engine to highlight as selected, if any |
9027
b28d0b8809ad
(svn r12843) -Feature [FS#1945]: The autoreplace window is now resizable in both directions
bjarni
parents:
8962
diff
changeset
|
732 |
* @param count_location Offset to print the engine count (used by autoreplace). 0 means it's off |
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
733 |
*/ |
9679
9a09ba6c56cf
(svn r13784) -Codechange: Truncate vehicle names in purchase list to width of window.
peter1138
parents:
9671
diff
changeset
|
734 |
void DrawEngineList(VehicleType type, int x, int r, int y, const GUIEngineList *eng_list, uint16 min, uint16 max, EngineID selected_id, int count_location, GroupID selected_group) |
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
735 |
{ |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
736 |
byte step_size = GetVehicleListHeight(type); |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
737 |
byte x_offset = 0; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
738 |
byte y_offset = 0; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
739 |
|
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
740 |
assert(max <= eng_list->Length()); |
5802
e770857f092f
(svn r8364) -Codechange (r8362): added an assert to catch conditions where a request wants to draw more vehicles than the list contains
bjarni
parents:
5800
diff
changeset
|
741 |
|
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
742 |
switch (type) { |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6237
diff
changeset
|
743 |
case VEH_TRAIN: |
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
744 |
x++; // train and road vehicles use the same offset, except trains are one more pixel to the right |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
745 |
/* Fallthough */ |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6237
diff
changeset
|
746 |
case VEH_ROAD: |
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
747 |
x += 26; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
748 |
x_offset = 30; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
749 |
y += 2; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
750 |
y_offset = 4; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
751 |
break; |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6237
diff
changeset
|
752 |
case VEH_SHIP: |
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
753 |
x += 35; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
754 |
x_offset = 40; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
755 |
y += 7; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
756 |
y_offset = 3; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
757 |
break; |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6237
diff
changeset
|
758 |
case VEH_AIRCRAFT: |
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
759 |
x += 27; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
760 |
x_offset = 33; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
761 |
y += 7; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
762 |
y_offset = 3; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
763 |
break; |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
764 |
default: NOT_REACHED(); |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
765 |
} |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
766 |
|
9679
9a09ba6c56cf
(svn r13784) -Codechange: Truncate vehicle names in purchase list to width of window.
peter1138
parents:
9671
diff
changeset
|
767 |
uint maxw = r - x - x_offset; |
9a09ba6c56cf
(svn r13784) -Codechange: Truncate vehicle names in purchase list to width of window.
peter1138
parents:
9671
diff
changeset
|
768 |
|
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
769 |
for (; min < max; min++, y += step_size) { |
9395
003c5b8d2931
(svn r13306) -Fix (r8362): Pass engine list by pointer instead of making a copy of it.
peter1138
parents:
9380
diff
changeset
|
770 |
const EngineID engine = (*eng_list)[min]; |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10148
diff
changeset
|
771 |
/* Note: num_engines is only used in the autoreplace GUI, so it is correct to use _local_company here. */ |
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10148
diff
changeset
|
772 |
const uint num_engines = GetGroupNumEngines(_local_company, selected_group, engine); |
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
773 |
|
7059
c6d12e3de0dc
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7009
diff
changeset
|
774 |
SetDParam(0, engine); |
9679
9a09ba6c56cf
(svn r13784) -Codechange: Truncate vehicle names in purchase list to width of window.
peter1138
parents:
9671
diff
changeset
|
775 |
DrawStringTruncated(x + x_offset, y, STR_ENGINE_NAME, engine == selected_id ? TC_WHITE : TC_BLACK, maxw); |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10148
diff
changeset
|
776 |
DrawVehicleEngine(type, x, y + y_offset, engine, (count_location != 0 && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_company)); |
9027
b28d0b8809ad
(svn r12843) -Feature [FS#1945]: The autoreplace window is now resizable in both directions
bjarni
parents:
8962
diff
changeset
|
777 |
if (count_location != 0) { |
6643
f81bee57bc09
(svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
6638
diff
changeset
|
778 |
SetDParam(0, num_engines); |
9027
b28d0b8809ad
(svn r12843) -Feature [FS#1945]: The autoreplace window is now resizable in both directions
bjarni
parents:
8962
diff
changeset
|
779 |
DrawStringRightAligned(count_location, y + (GetVehicleListHeight(type) == 14 ? 3 : 8), STR_TINY_BLACK, TC_FROMSTRING); |
5944
6d059cc8662b
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
5893
diff
changeset
|
780 |
} |
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
781 |
} |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
782 |
} |
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
783 |
|
8338
598af8119b97
(svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
peter1138
parents:
8284
diff
changeset
|
784 |
|
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
785 |
struct BuildVehicleWindow : Window { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
786 |
VehicleType vehicle_type; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
787 |
union { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
788 |
RailTypeByte railtype; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
789 |
AirportFTAClass::Flags flags; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
790 |
RoadTypes roadtypes; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
791 |
} filter; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
792 |
bool descending_sort_order; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
793 |
byte sort_criteria; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
794 |
bool regenerate_list; |
9633
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
795 |
bool listview_mode; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
796 |
EngineID sel_engine; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
797 |
EngineID rename_engine; |
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
798 |
GUIEngineList eng_list; |
5786
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5785
diff
changeset
|
799 |
|
9203
082fbf0500c4
(svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
rubidium
parents:
9202
diff
changeset
|
800 |
BuildVehicleWindow(const WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc, tile == 0 ? (int)type : tile) |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
801 |
{ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
802 |
this->vehicle_type = type; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
803 |
int vlh = GetVehicleListHeight(this->vehicle_type); |
6385
78f5307ce501
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
maedhros
parents:
6384
diff
changeset
|
804 |
|
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
805 |
ResizeWindow(this, 0, vlh - 14); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
806 |
this->resize.step_height = vlh; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
807 |
this->vscroll.cap = 1; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
808 |
this->widget[BUILD_VEHICLE_WIDGET_LIST].data = 0x101; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
809 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
810 |
this->resize.width = this->width; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
811 |
this->resize.height = this->height; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
812 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10148
diff
changeset
|
813 |
this->caption_color = (tile != 0) ? GetTileOwner(tile) : _local_company; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
814 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
815 |
this->sel_engine = INVALID_ENGINE; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
816 |
this->regenerate_list = false; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
817 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
818 |
this->sort_criteria = _last_sort_criteria[type]; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
819 |
this->descending_sort_order = _last_sort_order[type]; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
820 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
821 |
switch (type) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
822 |
default: NOT_REACHED(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
823 |
case VEH_TRAIN: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
824 |
this->filter.railtype = (tile == 0) ? RAILTYPE_END : GetRailType(tile); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
825 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
826 |
case VEH_ROAD: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
827 |
this->filter.roadtypes = (tile == 0) ? ROADTYPES_ALL : GetRoadTypes(tile); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
828 |
case VEH_SHIP: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
829 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
830 |
case VEH_AIRCRAFT: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
831 |
this->filter.flags = |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
832 |
tile == 0 ? AirportFTAClass::ALL : GetStationByTile(tile)->Airport()->flags; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
833 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
834 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
835 |
this->SetupWindowStrings(type); |
9633
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
836 |
|
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
837 |
this->listview_mode = (this->window_number <= VEH_END); |
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
838 |
/* If we are just viewing the list of vehicles, we do not need the Build button. |
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
839 |
* So we just hide it, and enlarge the Rename buton by the now vacant place. */ |
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
840 |
if (this->listview_mode) { |
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
841 |
this->HideWidget(BUILD_VEHICLE_WIDGET_BUILD); |
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
842 |
this->widget[BUILD_VEHICLE_WIDGET_RENAME].left = this->widget[BUILD_VEHICLE_WIDGET_BUILD].left; |
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
843 |
} else { |
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
844 |
/* Both are visible, adjust the size of each */ |
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
845 |
ResizeButtons(this, BUILD_VEHICLE_WIDGET_BUILD, BUILD_VEHICLE_WIDGET_RENAME); |
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
846 |
} |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
847 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
848 |
this->GenerateBuildList(); // generate the list, since we need it in the next line |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
849 |
/* Select the first engine in the list as default when opening the window */ |
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
850 |
if (this->eng_list.Length() > 0) this->sel_engine = this->eng_list[0]; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
851 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
852 |
this->FindWindowPlacementAndResize(desc); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
853 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
854 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
855 |
/* Setup widget strings to fit the different types of vehicles */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
856 |
void SetupWindowStrings(VehicleType type) |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
857 |
{ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
858 |
switch (type) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
859 |
default: NOT_REACHED(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
860 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
861 |
case VEH_TRAIN: |
9633
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
862 |
this->widget[BUILD_VEHICLE_WIDGET_CAPTION].data = this->listview_mode ? STR_AVAILABLE_TRAINS : STR_JUST_STRING; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
863 |
this->widget[BUILD_VEHICLE_WIDGET_LIST].tooltips = STR_8843_TRAIN_VEHICLE_SELECTION; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
864 |
this->widget[BUILD_VEHICLE_WIDGET_BUILD].data = STR_881F_BUILD_VEHICLE; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
865 |
this->widget[BUILD_VEHICLE_WIDGET_BUILD].tooltips = STR_8844_BUILD_THE_HIGHLIGHTED_TRAIN; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
866 |
this->widget[BUILD_VEHICLE_WIDGET_RENAME].data = STR_8820_RENAME; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
867 |
this->widget[BUILD_VEHICLE_WIDGET_RENAME].tooltips = STR_8845_RENAME_TRAIN_VEHICLE_TYPE; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
868 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
869 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
870 |
case VEH_ROAD: |
9633
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
871 |
this->widget[BUILD_VEHICLE_WIDGET_CAPTION].data = this->listview_mode ? STR_AVAILABLE_ROAD_VEHICLES : STR_9006_NEW_ROAD_VEHICLES; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
872 |
this->widget[BUILD_VEHICLE_WIDGET_LIST].tooltips = STR_9026_ROAD_VEHICLE_SELECTION; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
873 |
this->widget[BUILD_VEHICLE_WIDGET_BUILD].data = STR_9007_BUILD_VEHICLE; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
874 |
this->widget[BUILD_VEHICLE_WIDGET_BUILD].tooltips = STR_9027_BUILD_THE_HIGHLIGHTED_ROAD; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
875 |
this->widget[BUILD_VEHICLE_WIDGET_RENAME].data = STR_9034_RENAME; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
876 |
this->widget[BUILD_VEHICLE_WIDGET_RENAME].tooltips = STR_9035_RENAME_ROAD_VEHICLE_TYPE; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
877 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
878 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
879 |
case VEH_SHIP: |
9633
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
880 |
this->widget[BUILD_VEHICLE_WIDGET_CAPTION].data = this->listview_mode ? STR_AVAILABLE_SHIPS : STR_9808_NEW_SHIPS; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
881 |
this->widget[BUILD_VEHICLE_WIDGET_LIST].tooltips = STR_9825_SHIP_SELECTION_LIST_CLICK; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
882 |
this->widget[BUILD_VEHICLE_WIDGET_BUILD].data = STR_9809_BUILD_SHIP; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
883 |
this->widget[BUILD_VEHICLE_WIDGET_BUILD].tooltips = STR_9826_BUILD_THE_HIGHLIGHTED_SHIP; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
884 |
this->widget[BUILD_VEHICLE_WIDGET_RENAME].data = STR_9836_RENAME; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
885 |
this->widget[BUILD_VEHICLE_WIDGET_RENAME].tooltips = STR_9837_RENAME_SHIP_TYPE; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
886 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
887 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
888 |
case VEH_AIRCRAFT: |
9633
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
889 |
this->widget[BUILD_VEHICLE_WIDGET_CAPTION].data = this->listview_mode ? STR_AVAILABLE_AIRCRAFT : STR_A005_NEW_AIRCRAFT; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
890 |
this->widget[BUILD_VEHICLE_WIDGET_LIST].tooltips = STR_A025_AIRCRAFT_SELECTION_LIST; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
891 |
this->widget[BUILD_VEHICLE_WIDGET_BUILD].data = STR_A006_BUILD_AIRCRAFT; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
892 |
this->widget[BUILD_VEHICLE_WIDGET_BUILD].tooltips = STR_A026_BUILD_THE_HIGHLIGHTED_AIRCRAFT; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
893 |
this->widget[BUILD_VEHICLE_WIDGET_RENAME].data = STR_A037_RENAME; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
894 |
this->widget[BUILD_VEHICLE_WIDGET_RENAME].tooltips = STR_A038_RENAME_AIRCRAFT_TYPE; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
895 |
break; |
8418
afae92fe35f1
(svn r11988) -Codechange: Add a generic way of changing a widget's size and adjust the widgets around it to suit.
peter1138
parents:
8389
diff
changeset
|
896 |
} |
5800
672266389034
(svn r8362) -Codechange: [vehicle build window] moved the engine drawing loop to a function of it's own
bjarni
parents:
5790
diff
changeset
|
897 |
} |
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5782
diff
changeset
|
898 |
|
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
899 |
/* Figure out what train EngineIDs to put in the list */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
900 |
void GenerateBuildTrainList() |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
901 |
{ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
902 |
EngineID sel_id = INVALID_ENGINE; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
903 |
int num_engines = 0; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
904 |
int num_wagons = 0; |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
905 |
|
9633
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
906 |
this->filter.railtype = (this->listview_mode) ? RAILTYPE_END : GetRailType(this->window_number); |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
907 |
|
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
908 |
this->eng_list.Clear(); |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
909 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
910 |
/* Make list of all available train engines and wagons. |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
911 |
* Also check to see if the previously selected engine is still available, |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
912 |
* and if not, reset selection to INVALID_ENGINE. This could be the case |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
913 |
* when engines become obsolete and are removed */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
914 |
const Engine *e; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
915 |
FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
916 |
EngineID eid = e->index; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
917 |
const RailVehicleInfo *rvi = &e->u.rail; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
918 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
919 |
if (this->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, this->filter.railtype)) continue; |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10148
diff
changeset
|
920 |
if (!IsEngineBuildable(eid, VEH_TRAIN, _local_company)) continue; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
921 |
|
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
922 |
*this->eng_list.Append() = eid; |
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
923 |
|
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
924 |
if (rvi->railveh_type != RAILVEH_WAGON) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
925 |
num_engines++; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
926 |
} else { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
927 |
num_wagons++; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
928 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
929 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
930 |
if (eid == this->sel_engine) sel_id = eid; |
5187
12dc9dfa6af6
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
931 |
} |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
932 |
|
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
933 |
this->sel_engine = sel_id; |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
934 |
|
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
935 |
/* make engines first, and then wagons, sorted by ListPositionOfEngine() */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
936 |
_internal_sort_order = false; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
937 |
EngList_Sort(&this->eng_list, TrainEnginesThenWagonsSorter); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
938 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
939 |
/* and then sort engines */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
940 |
_internal_sort_order = this->descending_sort_order; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
941 |
EngList_SortPartial(&this->eng_list, _sorter[0][this->sort_criteria], 0, num_engines); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
942 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
943 |
/* and finally sort wagons */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
944 |
EngList_SortPartial(&this->eng_list, _sorter[0][this->sort_criteria], num_engines, num_wagons); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
945 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
946 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
947 |
/* Figure out what road vehicle EngineIDs to put in the list */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
948 |
void GenerateBuildRoadVehList() |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
949 |
{ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
950 |
EngineID sel_id = INVALID_ENGINE; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
951 |
|
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
952 |
this->eng_list.Clear(); |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
953 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
954 |
const Engine *e; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
955 |
FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
956 |
EngineID eid = e->index; |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10148
diff
changeset
|
957 |
if (!IsEngineBuildable(eid, VEH_ROAD, _local_company)) continue; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
958 |
if (!HasBit(this->filter.roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue; |
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
959 |
*this->eng_list.Append() = eid; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
960 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
961 |
if (eid == this->sel_engine) sel_id = eid; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
962 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
963 |
this->sel_engine = sel_id; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
964 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
965 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
966 |
/* Figure out what ship EngineIDs to put in the list */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
967 |
void GenerateBuildShipList() |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
968 |
{ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
969 |
EngineID sel_id = INVALID_ENGINE; |
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
970 |
this->eng_list.Clear(); |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
971 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
972 |
const Engine *e; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
973 |
FOR_ALL_ENGINES_OF_TYPE(e, VEH_SHIP) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
974 |
EngineID eid = e->index; |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10148
diff
changeset
|
975 |
if (!IsEngineBuildable(eid, VEH_SHIP, _local_company)) continue; |
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
976 |
*this->eng_list.Append() = eid; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
977 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
978 |
if (eid == this->sel_engine) sel_id = eid; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
979 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
980 |
this->sel_engine = sel_id; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
981 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
982 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
983 |
/* Figure out what aircraft EngineIDs to put in the list */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
984 |
void GenerateBuildAircraftList() |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
985 |
{ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
986 |
EngineID sel_id = INVALID_ENGINE; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
987 |
|
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
988 |
this->eng_list.Clear(); |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
989 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
990 |
/* Make list of all available planes. |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
991 |
* Also check to see if the previously selected plane is still available, |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
992 |
* and if not, reset selection to INVALID_ENGINE. This could be the case |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
993 |
* when planes become obsolete and are removed */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
994 |
const Engine *e; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
995 |
FOR_ALL_ENGINES_OF_TYPE(e, VEH_AIRCRAFT) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
996 |
EngineID eid = e->index; |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10148
diff
changeset
|
997 |
if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_company)) continue; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
998 |
/* First VEH_END window_numbers are fake to allow a window open for all different types at once */ |
9633
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
999 |
if (!this->listview_mode && !CanAircraftUseStation(eid, this->window_number)) continue; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1000 |
|
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
1001 |
*this->eng_list.Append() = eid; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1002 |
if (eid == this->sel_engine) sel_id = eid; |
5187
12dc9dfa6af6
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1003 |
} |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1004 |
|
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1005 |
this->sel_engine = sel_id; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1006 |
} |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
1007 |
|
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1008 |
/* Generate the list of vehicles */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1009 |
void GenerateBuildList() |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1010 |
{ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1011 |
switch (this->vehicle_type) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1012 |
default: NOT_REACHED(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1013 |
case VEH_TRAIN: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1014 |
this->GenerateBuildTrainList(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1015 |
return; // trains should not reach the last sorting |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1016 |
case VEH_ROAD: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1017 |
this->GenerateBuildRoadVehList(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1018 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1019 |
case VEH_SHIP: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1020 |
this->GenerateBuildShipList(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1021 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1022 |
case VEH_AIRCRAFT: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1023 |
this->GenerateBuildAircraftList(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1024 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1025 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1026 |
_internal_sort_order = this->descending_sort_order; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1027 |
EngList_Sort(&this->eng_list, _sorter[this->vehicle_type][this->sort_criteria]); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1028 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1029 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1030 |
void OnClick(Point pt, int widget) |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1031 |
{ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1032 |
switch (widget) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1033 |
case BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1034 |
this->descending_sort_order ^= true; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1035 |
_last_sort_order[this->vehicle_type] = this->descending_sort_order; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1036 |
this->regenerate_list = true; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1037 |
this->SetDirty(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1038 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1039 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1040 |
case BUILD_VEHICLE_WIDGET_LIST: { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1041 |
uint i = (pt.y - this->widget[BUILD_VEHICLE_WIDGET_LIST].top) / GetVehicleListHeight(this->vehicle_type) + this->vscroll.pos; |
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
1042 |
size_t num_items = this->eng_list.Length(); |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1043 |
this->sel_engine = (i < num_items) ? this->eng_list[i] : INVALID_ENGINE; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1044 |
this->SetDirty(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1045 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1046 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1047 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1048 |
case BUILD_VEHICLE_WIDGET_SORT_DROPDOWN: // Select sorting criteria dropdown menu |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1049 |
ShowDropDownMenu(this, _sort_listing[this->vehicle_type], this->sort_criteria, BUILD_VEHICLE_WIDGET_SORT_DROPDOWN, 0, 0); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1050 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1051 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1052 |
case BUILD_VEHICLE_WIDGET_BUILD: { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1053 |
EngineID sel_eng = this->sel_engine; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1054 |
if (sel_eng != INVALID_ENGINE) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1055 |
switch (this->vehicle_type) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1056 |
default: NOT_REACHED(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1057 |
case VEH_TRAIN: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1058 |
DoCommandP(this->window_number, sel_eng, 0, (RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildLoco, |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1059 |
CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE)); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1060 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1061 |
case VEH_ROAD: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1062 |
DoCommandP(this->window_number, sel_eng, 0, CcBuildRoadVeh, CMD_BUILD_ROAD_VEH | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE)); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1063 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1064 |
case VEH_SHIP: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1065 |
DoCommandP(this->window_number, sel_eng, 0, CcBuildShip, CMD_BUILD_SHIP | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP)); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1066 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1067 |
case VEH_AIRCRAFT: |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1068 |
DoCommandP(this->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1069 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1070 |
} |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
1071 |
} |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1072 |
break; |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1073 |
} |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1074 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1075 |
case BUILD_VEHICLE_WIDGET_RENAME: { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1076 |
EngineID sel_eng = this->sel_engine; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1077 |
if (sel_eng != INVALID_ENGINE) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1078 |
StringID str = STR_NULL; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1079 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1080 |
this->rename_engine = sel_eng; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1081 |
switch (this->vehicle_type) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1082 |
default: NOT_REACHED(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1083 |
case VEH_TRAIN: str = STR_886A_RENAME_TRAIN_VEHICLE_TYPE; break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1084 |
case VEH_ROAD: str = STR_9036_RENAME_ROAD_VEHICLE_TYPE; break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1085 |
case VEH_SHIP: str = STR_9838_RENAME_SHIP_TYPE; break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1086 |
case VEH_AIRCRAFT: str = STR_A039_RENAME_AIRCRAFT_TYPE; break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1087 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1088 |
SetDParam(0, sel_eng); |
10148
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
1089 |
ShowQueryString(STR_ENGINE_NAME, str, MAX_LENGTH_ENGINE_NAME_BYTES, MAX_LENGTH_ENGINE_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT); |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1090 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1091 |
break; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1092 |
} |
5187
12dc9dfa6af6
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1093 |
} |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1094 |
} |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1095 |
|
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1096 |
virtual void OnInvalidateData(int data) |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1097 |
{ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1098 |
this->regenerate_list = true; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1099 |
} |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1100 |
|
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1101 |
virtual void OnPaint() |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1102 |
{ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1103 |
if (this->regenerate_list) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1104 |
this->regenerate_list = false; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1105 |
this->GenerateBuildList(); |
5187
12dc9dfa6af6
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5070
diff
changeset
|
1106 |
} |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1107 |
|
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
1108 |
uint max = min(this->vscroll.pos + this->vscroll.cap, this->eng_list.Length()); |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1109 |
|
9403
8cfca59c11f1
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138
parents:
9395
diff
changeset
|
1110 |
SetVScrollCount(this, this->eng_list.Length()); |
10000
57463dc267a0
(svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138
parents:
9923
diff
changeset
|
1111 |
if (this->vehicle_type == VEH_TRAIN) { |
57463dc267a0
(svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138
parents:
9923
diff
changeset
|
1112 |
if (this->filter.railtype == RAILTYPE_END) { |
57463dc267a0
(svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138
parents:
9923
diff
changeset
|
1113 |
SetDParam(0, STR_ALL_AVAIL_RAIL_VEHICLES); |
57463dc267a0
(svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138
parents:
9923
diff
changeset
|
1114 |
} else { |
57463dc267a0
(svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138
parents:
9923
diff
changeset
|
1115 |
const RailtypeInfo *rti = GetRailTypeInfo(this->filter.railtype); |
57463dc267a0
(svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138
parents:
9923
diff
changeset
|
1116 |
SetDParam(0, rti->strings.build_caption); |
57463dc267a0
(svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138
parents:
9923
diff
changeset
|
1117 |
} |
57463dc267a0
(svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138
parents:
9923
diff
changeset
|
1118 |
} |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1119 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1120 |
/* Set text of sort by dropdown */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1121 |
this->widget[BUILD_VEHICLE_WIDGET_SORT_DROPDOWN].data = _sort_listing[this->vehicle_type][this->sort_criteria]; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1122 |
|
9273
35e0224ea8f1
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
9208
diff
changeset
|
1123 |
this->DrawWidgets(); |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1124 |
|
9679
9a09ba6c56cf
(svn r13784) -Codechange: Truncate vehicle names in purchase list to width of window.
peter1138
parents:
9671
diff
changeset
|
1125 |
DrawEngineList(this->vehicle_type, this->widget[BUILD_VEHICLE_WIDGET_LIST].left + 2, this->widget[BUILD_VEHICLE_WIDGET_LIST].right, this->widget[BUILD_VEHICLE_WIDGET_LIST].top + 1, &this->eng_list, this->vscroll.pos, max, this->sel_engine, 0, DEFAULT_GROUP); |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1126 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1127 |
if (this->sel_engine != INVALID_ENGINE) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1128 |
const Widget *wi = &this->widget[BUILD_VEHICLE_WIDGET_PANEL]; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1129 |
int text_end = DrawVehiclePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, this->sel_engine); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1130 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1131 |
if (text_end > wi->bottom) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1132 |
this->SetDirty(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1133 |
ResizeWindowForWidget(this, BUILD_VEHICLE_WIDGET_PANEL, 0, text_end - wi->bottom); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1134 |
this->SetDirty(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1135 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1136 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1137 |
|
9273
35e0224ea8f1
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
9208
diff
changeset
|
1138 |
this->DrawSortButtonState(BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING, this->descending_sort_order ? SBS_DOWN : SBS_UP); |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1139 |
} |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1140 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1141 |
virtual void OnDoubleClick(Point pt, int widget) |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1142 |
{ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1143 |
if (widget == BUILD_VEHICLE_WIDGET_LIST) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1144 |
/* When double clicking, we want to buy a vehicle */ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1145 |
this->OnClick(pt, BUILD_VEHICLE_WIDGET_BUILD); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1146 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1147 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1148 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1149 |
virtual void OnQueryTextFinished(char *str) |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1150 |
{ |
10148
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
1151 |
if (str == NULL) return; |
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
1152 |
|
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
1153 |
StringID err_str = STR_NULL; |
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
1154 |
_cmd_text = str; |
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
1155 |
switch (this->vehicle_type) { |
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
1156 |
default: NOT_REACHED(); |
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
1157 |
case VEH_TRAIN: err_str = STR_886B_CAN_T_RENAME_TRAIN_VEHICLE; break; |
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
1158 |
case VEH_ROAD: err_str = STR_9037_CAN_T_RENAME_ROAD_VEHICLE; break; |
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
1159 |
case VEH_SHIP: err_str = STR_9839_CAN_T_RENAME_SHIP_TYPE; break; |
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
1160 |
case VEH_AIRCRAFT: err_str = STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE; break; |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1161 |
} |
10148
ad8e8a65f6a2
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents:
10145
diff
changeset
|
1162 |
DoCommandP(0, this->rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(err_str)); |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1163 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1164 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1165 |
virtual void OnDropdownSelect(int widget, int index) |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1166 |
{ |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1167 |
if (this->sort_criteria != index) { |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1168 |
this->sort_criteria = index; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1169 |
_last_sort_criteria[this->vehicle_type] = this->sort_criteria; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1170 |
this->regenerate_list = true; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1171 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1172 |
this->SetDirty(); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1173 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1174 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1175 |
virtual void OnResize(Point new_size, Point delta) |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1176 |
{ |
9633
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
1177 |
if (delta.x != 0 && !this->listview_mode) { |
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
1178 |
ResizeButtons(this, BUILD_VEHICLE_WIDGET_BUILD, BUILD_VEHICLE_WIDGET_RENAME); |
8919ac19fc82
(svn r13696) -Fix[GUI]: The Build button of the vehicle list is now hidden, instead of just disabled. It will be only visible when called from the Depot Building Window.
belugas
parents:
9631
diff
changeset
|
1179 |
} |
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1180 |
if (delta.y == 0) return; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1181 |
|
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1182 |
this->vscroll.cap += delta.y / (int)GetVehicleListHeight(this->vehicle_type); |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1183 |
this->widget[BUILD_VEHICLE_WIDGET_LIST].data = (this->vscroll.cap << 8) + 1; |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1184 |
} |
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1185 |
}; |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1186 |
|
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1187 |
static const WindowDesc _build_vehicle_desc = { |
7368
92dd846cf2c5
(svn r10731) -Codechange: allow smaller initial "build <vehicle type>" windows.
rubidium
parents:
7341
diff
changeset
|
1188 |
WDP_AUTO, WDP_AUTO, 240, 174, 240, 256, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5874
diff
changeset
|
1189 |
WC_BUILD_VEHICLE, WC_NONE, |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1190 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1191 |
_build_vehicle_widgets, |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1192 |
}; |
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1193 |
|
6638
09c5d7bf69a5
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents:
6608
diff
changeset
|
1194 |
void ShowBuildVehicleWindow(TileIndex tile, VehicleType type) |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1195 |
{ |
7246
9ac33793ac75
(svn r10546) -Fix [FS#1026]: you can now have both Available Train as Available Ship window open
truelight
parents:
7059
diff
changeset
|
1196 |
/* We want to be able to open both Available Train as Available Ships, |
9ac33793ac75
(svn r10546) -Fix [FS#1026]: you can now have both Available Train as Available Ship window open
truelight
parents:
7059
diff
changeset
|
1197 |
* so if tile == 0 (Available XXX Window), use 'type' as unique number. |
9ac33793ac75
(svn r10546) -Fix [FS#1026]: you can now have both Available Train as Available Ship window open
truelight
parents:
7059
diff
changeset
|
1198 |
* As it always is a low value, it won't collide with any real tile |
9ac33793ac75
(svn r10546) -Fix [FS#1026]: you can now have both Available Train as Available Ship window open
truelight
parents:
7059
diff
changeset
|
1199 |
* number. */ |
9ac33793ac75
(svn r10546) -Fix [FS#1026]: you can now have both Available Train as Available Ship window open
truelight
parents:
7059
diff
changeset
|
1200 |
uint num = (tile == 0) ? (int)type : tile; |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1201 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10148
diff
changeset
|
1202 |
assert(IsCompanyBuildableVehicleType(type)); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
1203 |
|
7246
9ac33793ac75
(svn r10546) -Fix [FS#1026]: you can now have both Available Train as Available Ship window open
truelight
parents:
7059
diff
changeset
|
1204 |
DeleteWindowById(WC_BUILD_VEHICLE, num); |
5779
a694ce1457bb
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5668
diff
changeset
|
1205 |
|
9202
a29a19e1aea9
(svn r13068) -Codechange: make a class of the BuildVehicleWindow.
rubidium
parents:
9164
diff
changeset
|
1206 |
new BuildVehicleWindow(&_build_vehicle_desc, tile, type); |
4800
5afc1bfc7a85
(svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents:
diff
changeset
|
1207 |
} |