author | truebrain |
Mon, 30 Jun 2008 21:31:23 +0000 | |
branch | noai |
changeset 11111 | 1b984dab8cec |
parent 11044 | 097ea3e7ec56 |
child 11126 | 72d4c9314c72 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9837
diff
changeset
|
3 |
/** @file engine_gui.cpp GUI to show engine related information. */ |
6451
7baba06b4b85
(svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents:
6182
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1095
diff
changeset
|
6 |
#include "openttd.h" |
0 | 7 |
#include "gui.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
8 |
#include "window_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
9 |
#include "gfx_func.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
10 |
#include "engine_func.h" |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9837
diff
changeset
|
11 |
#include "engine_base.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
12 |
#include "command_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
13 |
#include "economy_func.h" |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
14 |
#include "news_func.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2084
diff
changeset
|
15 |
#include "variables.h" |
2962
dbd168a4703a
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents:
2840
diff
changeset
|
16 |
#include "newgrf_engine.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
17 |
#include "strings_func.h" |
10776 | 18 |
#include "engine_gui.h" |
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
19 |
#include "articulated_vehicles.h" |
0 | 20 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
21 |
#include "table/strings.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
22 |
#include "table/sprites.h" |
0 | 23 |
|
10645 | 24 |
StringID GetEngineCategoryName(EngineID engine) |
0 | 25 |
{ |
6535
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
26 |
switch (GetEngine(engine)->type) { |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
27 |
default: NOT_REACHED(); |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
28 |
case VEH_ROAD: return STR_8103_ROAD_VEHICLE; |
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
29 |
case VEH_AIRCRAFT: return STR_8104_AIRCRAFT; |
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
30 |
case VEH_SHIP: return STR_8105_SHIP; |
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
31 |
case VEH_TRAIN: |
6535
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
32 |
switch (RailVehInfo(engine)->railtype) { |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
33 |
default: NOT_REACHED(); |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
34 |
case RAILTYPE_RAIL: return STR_8102_RAILROAD_LOCOMOTIVE; |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
35 |
case RAILTYPE_ELECTRIC: return STR_8102_RAILROAD_LOCOMOTIVE; |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
36 |
case RAILTYPE_MONO: return STR_8106_MONORAIL_LOCOMOTIVE; |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
37 |
case RAILTYPE_MAGLEV: return STR_8107_MAGLEV_LOCOMOTIVE; |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
38 |
} |
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
39 |
} |
0 | 40 |
} |
41 |
||
42 |
static const Widget _engine_preview_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
3477
diff
changeset
|
43 |
{ WWT_CLOSEBOX, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
534
diff
changeset
|
44 |
{ WWT_CAPTION, RESIZE_NONE, 5, 11, 299, 0, 13, STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4898
diff
changeset
|
45 |
{ WWT_PANEL, RESIZE_NONE, 5, 0, 299, 14, 191, 0x0, STR_NULL}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
3477
diff
changeset
|
46 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 5, 85, 144, 172, 183, STR_00C9_NO, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
3477
diff
changeset
|
47 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 5, 155, 214, 172, 183, STR_00C8_YES, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
48 |
{ WIDGETS_END}, |
0 | 49 |
}; |
50 |
||
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
51 |
typedef void DrawEngineProc(int x, int y, EngineID engine, SpriteID pal); |
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
52 |
typedef void DrawEngineInfoProc(EngineID, int x, int y, int maxw); |
0 | 53 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6535
diff
changeset
|
54 |
struct DrawEngineInfo { |
0 | 55 |
DrawEngineProc *engine_proc; |
56 |
DrawEngineInfoProc *info_proc; |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6535
diff
changeset
|
57 |
}; |
0 | 58 |
|
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
59 |
static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw); |
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
60 |
static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw); |
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
61 |
static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw); |
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
62 |
static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw); |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
63 |
|
0 | 64 |
static const DrawEngineInfo _draw_engine_list[4] = { |
6535
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
65 |
{ DrawTrainEngine, DrawTrainEngineInfo }, |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
66 |
{ DrawRoadVehEngine, DrawRoadVehEngineInfo }, |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
67 |
{ DrawShipEngine, DrawShipEngineInfo }, |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
68 |
{ DrawAircraftEngine, DrawAircraftEngineInfo }, |
0 | 69 |
}; |
70 |
||
10645 | 71 |
struct EnginePreviewWindow : Window { |
72 |
EnginePreviewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
|
73 |
{ |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
74 |
this->FindWindowPlacementAndResize(desc); |
10645 | 75 |
} |
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
76 |
|
10645 | 77 |
virtual void OnPaint() |
78 |
{ |
|
79 |
this->DrawWidgets(); |
|
0 | 80 |
|
10645 | 81 |
EngineID engine = this->window_number; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
82 |
SetDParam(0, GetEngineCategoryName(engine)); |
0 | 83 |
DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296); |
84 |
||
9629 | 85 |
SetDParam(0, engine); |
10645 | 86 |
DrawStringCentered(this->width >> 1, 80, STR_ENGINE_NAME, TC_BLACK); |
0 | 87 |
|
10645 | 88 |
const DrawEngineInfo *dei = &_draw_engine_list[GetEngine(engine)->type]; |
0 | 89 |
|
10645 | 90 |
int width = this->width; |
0 | 91 |
dei->engine_proc(width >> 1, 100, engine, 0); |
92 |
dei->info_proc(engine, width >> 1, 130, width - 52); |
|
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
93 |
} |
0 | 94 |
|
10645 | 95 |
virtual void OnClick(Point pt, int widget) |
96 |
{ |
|
97 |
switch (widget) { |
|
2639 | 98 |
case 4: |
10645 | 99 |
DoCommandP(0, this->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW); |
5125
60b21cf18b50
(svn r7206) -Codechange: Remove (some of) the magic needed for windows that could be invalid after
Darkvater
parents:
4938
diff
changeset
|
100 |
/* Fallthrough */ |
60b21cf18b50
(svn r7206) -Codechange: Remove (some of) the magic needed for windows that could be invalid after
Darkvater
parents:
4938
diff
changeset
|
101 |
case 3: |
10645 | 102 |
delete this; |
2639 | 103 |
break; |
0 | 104 |
} |
105 |
} |
|
10645 | 106 |
}; |
0 | 107 |
|
108 |
static const WindowDesc _engine_preview_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
109 |
WDP_CENTER, WDP_CENTER, 300, 192, 300, 192, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6119
diff
changeset
|
110 |
WC_ENGINE_PREVIEW, WC_NONE, |
0 | 111 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
112 |
_engine_preview_widgets, |
|
113 |
}; |
|
114 |
||
115 |
||
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
116 |
void ShowEnginePreviewWindow(EngineID engine) |
0 | 117 |
{ |
10645 | 118 |
AllocateWindowDescFront<EnginePreviewWindow>(&_engine_preview_desc, engine); |
0 | 119 |
} |
120 |
||
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
121 |
static uint GetTotalCapacityOfArticulatedParts(EngineID engine, VehicleType type) |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
122 |
{ |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
123 |
uint total = 0; |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
124 |
|
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
125 |
uint16 *cap = GetCapacityOfArticulatedParts(engine, type); |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
126 |
for (uint c = 0; c < NUM_CARGO; c++) { |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
127 |
total += cap[c]; |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
128 |
} |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
129 |
|
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
130 |
return total; |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
131 |
} |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
132 |
|
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
133 |
static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw) |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
134 |
{ |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
135 |
const RailVehicleInfo *rvi = RailVehInfo(engine); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9694
diff
changeset
|
136 |
int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD) ? 1 : 0; |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
137 |
|
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
138 |
SetDParam(0, (_price.build_railvehicle >> 3) * GetEngineProperty(engine, 0x17, rvi->base_cost) >> 5); |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
139 |
SetDParam(2, GetEngineProperty(engine, 0x09, rvi->max_speed) * 10 / 16); |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
140 |
SetDParam(3, GetEngineProperty(engine, 0x0B, rvi->power) << multihead); |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
141 |
SetDParam(1, GetEngineProperty(engine, 0x16, rvi->weight) << multihead); |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
142 |
|
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
143 |
SetDParam(4, GetEngineProperty(engine, 0x0D, rvi->running_cost) * GetPriceByIndex(rvi->running_cost_class) >> 8 << multihead); |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
144 |
|
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
145 |
uint capacity = GetTotalCapacityOfArticulatedParts(engine, VEH_TRAIN); |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
146 |
if (capacity != 0) { |
4896
72d7a8614580
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4634
diff
changeset
|
147 |
SetDParam(5, rvi->cargo_type); |
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
148 |
SetDParam(6, capacity << multihead); |
2549 | 149 |
} else { |
4898
68560c75ec28
(svn r6858) - Fix (r6855): Handle rail vehicles with no capacity (N/A) by setting cargo type to CT_INVALID and handling it later. STR_8838_N_A is not a valid cargo type...
peter1138
parents:
4896
diff
changeset
|
150 |
SetDParam(5, CT_INVALID); |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
151 |
} |
3401
ad8175f44c3b
(svn r4211) - Removed measuring units from the names of two strings.
peter1138
parents:
3355
diff
changeset
|
152 |
DrawStringMultiCenter(x, y, STR_VEHICLE_INFO_COST_WEIGHT_SPEED_POWER, maxw); |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
153 |
} |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
154 |
|
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
155 |
static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw) |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
156 |
{ |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
157 |
const AircraftVehicleInfo *avi = AircraftVehInfo(engine); |
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
158 |
SetDParam(0, (_price.aircraft_base >> 3) * GetEngineProperty(engine, 0x0B, avi->base_cost) >> 5); |
9476 | 159 |
SetDParam(1, avi->max_speed * 10 / 16); |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
160 |
SetDParam(2, avi->passenger_capacity); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
161 |
SetDParam(3, avi->mail_capacity); |
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
162 |
SetDParam(4, GetEngineProperty(engine, 0x0E, avi->running_cost) * _price.aircraft_running >> 8); |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
163 |
|
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
164 |
DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
165 |
} |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
166 |
|
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
167 |
static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw) |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
168 |
{ |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
169 |
const RoadVehicleInfo *rvi = RoadVehInfo(engine); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
170 |
|
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
171 |
SetDParam(0, (_price.roadveh_base >> 3) * GetEngineProperty(engine, 0x11, rvi->base_cost) >> 5); |
6182 | 172 |
SetDParam(1, rvi->max_speed * 10 / 32); |
9732 | 173 |
SetDParam(2, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) >> 8); |
4896
72d7a8614580
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4634
diff
changeset
|
174 |
SetDParam(3, rvi->cargo_type); |
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
175 |
SetDParam(4, GetTotalCapacityOfArticulatedParts(engine, VEH_ROAD)); |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
176 |
|
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
177 |
DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
178 |
} |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
179 |
|
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
180 |
static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw) |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
181 |
{ |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
182 |
const ShipVehicleInfo *svi = ShipVehInfo(engine); |
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
183 |
SetDParam(0, GetEngineProperty(engine, 0x0A, svi->base_cost) * (_price.ship_base >> 3) >> 5); |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
184 |
SetDParam(1, GetEngineProperty(engine, 0x0B, svi->max_speed) * 10 / 32); |
4896
72d7a8614580
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4634
diff
changeset
|
185 |
SetDParam(2, svi->cargo_type); |
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
186 |
SetDParam(3, GetEngineProperty(engine, 0x0D, svi->capacity)); |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10776
diff
changeset
|
187 |
SetDParam(4, GetEngineProperty(engine, 0x0F, svi->running_cost) * _price.ship_running >> 8); |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
188 |
DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
189 |
} |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
190 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
191 |
void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni) |
6535
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
192 |
{ |
10645 | 193 |
EngineID engine = ni->data_a; |
6535
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
194 |
const DrawEngineInfo *dei = &_draw_engine_list[GetEngine(engine)->type]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
195 |
|
6535
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
196 |
SetDParam(0, GetEngineCategoryName(engine)); |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
197 |
DrawStringMultiCenter(w->width >> 1, 20, STR_NEW_VEHICLE_NOW_AVAILABLE, w->width - 2); |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
198 |
|
0 | 199 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
200 |
||
9629 | 201 |
SetDParam(0, engine); |
6535
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
202 |
DrawStringMultiCenter(w->width >> 1, 57, STR_NEW_VEHICLE_TYPE, w->width - 2); |
0 | 203 |
|
6535
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
204 |
dei->engine_proc(w->width >> 1, 88, engine, 0); |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
205 |
GfxFillRect(25, 56, w->width - 56, 112, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE)); |
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6534
diff
changeset
|
206 |
dei->info_proc(engine, w->width >> 1, 129, w->width - 52); |
0 | 207 |
} |
10776 | 208 |
|
209 |
||
210 |
/** Sort all items using qsort() and given 'CompareItems' function |
|
211 |
* @param el list to be sorted |
|
212 |
* @param compare function for evaluation of the quicksort |
|
213 |
*/ |
|
214 |
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare) |
|
215 |
{ |
|
216 |
uint size = el->Length(); |
|
217 |
/* out-of-bounds access at the next line for size == 0 (even with operator[] at some systems) |
|
218 |
* generally, do not sort if there are less than 2 items */ |
|
219 |
if (size < 2) return; |
|
220 |
qsort(el->Begin(), size, sizeof(*el->Begin()), compare); // MorphOS doesn't know vector::at(int) ... |
|
221 |
} |
|
222 |
||
223 |
/** Sort selected range of items (on indices @ <begin, begin+num_items-1>) |
|
224 |
* @param el list to be sorted |
|
225 |
* @param compare function for evaluation of the quicksort |
|
226 |
* @param begin start of sorting |
|
227 |
* @param num_items count of items to be sorted |
|
228 |
*/ |
|
229 |
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items) |
|
230 |
{ |
|
231 |
if (num_items < 2) return; |
|
232 |
assert(begin < el->Length()); |
|
233 |
assert(begin + num_items <= el->Length()); |
|
234 |
qsort(el->Get(begin), num_items, sizeof(*el->Begin()), compare); |
|
235 |
} |
|
236 |