author | peter1138 |
Sun, 04 Feb 2007 05:53:09 +0000 | |
changeset 5931 | 7bf22bf056e2 |
parent 5893 | 7e431a4abebb |
child 6125 | a6fff965707c |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1095
diff
changeset
|
4 |
#include "openttd.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
460
diff
changeset
|
5 |
#include "table/strings.h" |
2218
2132596a35c0
(svn r2736) -Codechange: De-mystified GfxDrawFillRect a bit, and used enums from table/sprites.h. You can now change the number of bits used for sprites and switches in the SpriteSetup enum and the rest should work automagically. Can be used to increase the number of active sprites to 2^19 in case there are no colortables (recolor sprites) in any newgrf. We should possibly move the the colortables to an own list, but how to detect them in a newgrf.
celestar
parents:
2186
diff
changeset
|
6 |
#include "table/sprites.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
7 |
#include "functions.h" |
0 | 8 |
#include "window.h" |
9 |
#include "gui.h" |
|
10 |
#include "viewport.h" |
|
11 |
#include "gfx.h" |
|
12 |
#include "engine.h" |
|
13 |
#include "command.h" |
|
14 |
#include "news.h" |
|
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2084
diff
changeset
|
15 |
#include "variables.h" |
2962
f0a49b646c48
(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" |
0 | 17 |
|
18 |
||
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
19 |
static StringID GetEngineCategoryName(EngineID engine) |
0 | 20 |
{ |
460
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
21 |
if (engine < NUM_TRAIN_ENGINES) { |
5823 | 22 |
switch (RailVehInfo(engine)->railtype) { |
3355
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
2962
diff
changeset
|
23 |
case RAILTYPE_RAIL: return STR_8102_RAILROAD_LOCOMOTIVE; |
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
2962
diff
changeset
|
24 |
case RAILTYPE_ELECTRIC: return STR_8102_RAILROAD_LOCOMOTIVE; |
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
2962
diff
changeset
|
25 |
case RAILTYPE_MONO: return STR_8106_MONORAIL_LOCOMOTIVE; |
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
2962
diff
changeset
|
26 |
case RAILTYPE_MAGLEV: return STR_8107_MAGLEV_LOCOMOTIVE; |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
27 |
default: NOT_REACHED(); |
460
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
28 |
} |
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
29 |
} |
0 | 30 |
|
31 |
if (engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) |
|
32 |
return STR_8103_ROAD_VEHICLE; |
|
33 |
||
34 |
if (engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) |
|
35 |
return STR_8105_SHIP; |
|
36 |
||
37 |
return STR_8104_AIRCRAFT; |
|
38 |
} |
|
39 |
||
40 |
static const Widget _engine_preview_widgets[] = { |
|
4344
7e123fec5b0b
(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
|
41 |
{ WWT_CLOSEBOX, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
534
diff
changeset
|
42 |
{ WWT_CAPTION, RESIZE_NONE, 5, 11, 299, 0, 13, STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4898
diff
changeset
|
43 |
{ WWT_PANEL, RESIZE_NONE, 5, 0, 299, 14, 191, 0x0, STR_NULL}, |
4344
7e123fec5b0b
(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
|
44 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 5, 85, 144, 172, 183, STR_00C9_NO, STR_NULL}, |
7e123fec5b0b
(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
|
45 |
{ 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
|
46 |
{ WIDGETS_END}, |
0 | 47 |
}; |
48 |
||
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
49 |
typedef void DrawEngineProc(int x, int y, EngineID engine, SpriteID pal); |
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
50 |
typedef void DrawEngineInfoProc(EngineID, int x, int y, int maxw); |
0 | 51 |
|
52 |
typedef struct DrawEngineInfo { |
|
53 |
DrawEngineProc *engine_proc; |
|
54 |
DrawEngineInfoProc *info_proc; |
|
55 |
} DrawEngineInfo; |
|
56 |
||
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
57 |
static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw); |
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
58 |
static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw); |
225b2916fe2a
(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 DrawShipEngineInfo(EngineID engine, int x, int y, int maxw); |
225b2916fe2a
(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 DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
61 |
|
0 | 62 |
static const DrawEngineInfo _draw_engine_list[4] = { |
63 |
{DrawTrainEngine,DrawTrainEngineInfo}, |
|
64 |
{DrawRoadVehEngine,DrawRoadVehEngineInfo}, |
|
65 |
{DrawShipEngine,DrawShipEngineInfo}, |
|
66 |
{DrawAircraftEngine,DrawAircraftEngineInfo}, |
|
67 |
}; |
|
68 |
||
69 |
static void EnginePreviewWndProc(Window *w, WindowEvent *e) |
|
70 |
{ |
|
2639 | 71 |
switch (e->event) { |
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
72 |
case WE_PAINT: { |
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
73 |
EngineID engine = w->window_number; |
2639 | 74 |
const DrawEngineInfo* dei; |
75 |
int width; |
|
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
76 |
|
0 | 77 |
DrawWindowWidgets(w); |
78 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
79 |
SetDParam(0, GetEngineCategoryName(engine)); |
0 | 80 |
DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296); |
81 |
||
82 |
DrawStringCentered(w->width >> 1, 80, GetCustomEngineName(engine), 0x10); |
|
83 |
||
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
84 |
(dei = _draw_engine_list,engine < NUM_TRAIN_ENGINES) || |
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
85 |
(dei++,engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) || |
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
86 |
(dei++,engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) || |
0 | 87 |
(dei++, true); |
88 |
||
89 |
width = w->width; |
|
90 |
dei->engine_proc(width >> 1, 100, engine, 0); |
|
91 |
dei->info_proc(engine, width >> 1, 130, width - 52); |
|
92 |
break; |
|
2477
225b2916fe2a
(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 |
|
95 |
case WE_CLICK: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4344
diff
changeset
|
96 |
switch (e->we.click.widget) { |
2639 | 97 |
case 4: |
98 |
DoCommandP(0, w->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW); |
|
5125
d1331d6dbdcb
(svn r7206) -Codechange: Remove (some of) the magic needed for windows that could be invalid after
Darkvater
parents:
4938
diff
changeset
|
99 |
/* Fallthrough */ |
d1331d6dbdcb
(svn r7206) -Codechange: Remove (some of) the magic needed for windows that could be invalid after
Darkvater
parents:
4938
diff
changeset
|
100 |
case 3: |
2639 | 101 |
DeleteWindow(w); |
102 |
break; |
|
0 | 103 |
} |
104 |
break; |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
static const WindowDesc _engine_preview_desc = { |
|
109 |
WDP_CENTER, WDP_CENTER, 300, 192, |
|
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5868
diff
changeset
|
110 |
WC_ENGINE_PREVIEW, WC_NONE, |
0 | 111 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
112 |
_engine_preview_widgets, |
|
113 |
EnginePreviewWndProc |
|
114 |
}; |
|
115 |
||
116 |
||
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
117 |
void ShowEnginePreviewWindow(EngineID engine) |
0 | 118 |
{ |
5137
54425dc8b5b3
(svn r7219) -Fix: Several warnings by gcc introduced in r7206 which MSVC found not of a problem. Thanks Tron
Darkvater
parents:
5125
diff
changeset
|
119 |
AllocateWindowDescFront(&_engine_preview_desc, engine); |
0 | 120 |
} |
121 |
||
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
122 |
static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw) |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
123 |
{ |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
124 |
const RailVehicleInfo *rvi = RailVehInfo(engine); |
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:
5823
diff
changeset
|
125 |
uint multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD) ? 1 : 0; |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
126 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
127 |
SetDParam(0, (_price.build_railvehicle >> 3) * rvi->base_cost >> 5); |
5931 | 128 |
SetDParam(2, rvi->max_speed * 10 / 16); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
129 |
SetDParam(3, rvi->power << multihead); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
130 |
SetDParam(1, rvi->weight << multihead); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
131 |
|
2840
9038b4ab8c9a
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2725
diff
changeset
|
132 |
SetDParam(4, rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8 << multihead); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
133 |
|
2549 | 134 |
if (rvi->capacity != 0) { |
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:
4634
diff
changeset
|
135 |
SetDParam(5, rvi->cargo_type); |
2549 | 136 |
SetDParam(6, rvi->capacity << multihead); |
137 |
} else { |
|
4898
e3962fe14ef8
(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
|
138 |
SetDParam(5, CT_INVALID); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
139 |
} |
3401
3eb83140e401
(svn r4211) - Removed measuring units from the names of two strings.
peter1138
parents:
3355
diff
changeset
|
140 |
DrawStringMultiCenter(x, y, STR_VEHICLE_INFO_COST_WEIGHT_SPEED_POWER, maxw); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
141 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
142 |
|
0 | 143 |
void DrawNewsNewTrainAvail(Window *w) |
144 |
{ |
|
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
145 |
EngineID engine; |
0 | 146 |
|
147 |
DrawNewsBorder(w); |
|
148 |
||
149 |
engine = WP(w,news_d).ni->string_id; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
150 |
SetDParam(0, GetEngineCategoryName(engine)); |
0 | 151 |
DrawStringMultiCenter(w->width >> 1, 20, STR_8859_NEW_NOW_AVAILABLE, w->width - 2); |
152 |
||
153 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
154 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
155 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 156 |
DrawStringMultiCenter(w->width >> 1, 57, STR_885A, w->width - 2); |
157 |
||
158 |
DrawTrainEngine(w->width >> 1, 88, engine, 0); |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
159 |
GfxFillRect(25, 56, w->width - 56, 112, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE)); |
0 | 160 |
DrawTrainEngineInfo(engine, w->width >> 1, 129, w->width - 52); |
161 |
} |
|
162 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2218
diff
changeset
|
163 |
StringID GetNewsStringNewTrainAvail(const NewsItem *ni) |
0 | 164 |
{ |
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
165 |
EngineID engine = ni->string_id; |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
166 |
SetDParam(0, STR_8859_NEW_NOW_AVAILABLE); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
167 |
SetDParam(1, GetEngineCategoryName(engine)); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
168 |
SetDParam(2, GetCustomEngineName(engine)); |
0 | 169 |
return STR_02B6; |
170 |
} |
|
171 |
||
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
172 |
static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw) |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
173 |
{ |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
174 |
const AircraftVehicleInfo *avi = AircraftVehInfo(engine); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
175 |
SetDParam(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5); |
5931 | 176 |
SetDParam(1, avi->max_speed * 8); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
177 |
SetDParam(2, avi->passenger_capacity); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
178 |
SetDParam(3, avi->mail_capacity); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
179 |
SetDParam(4, avi->running_cost * _price.aircraft_running >> 8); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
180 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
181 |
DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
182 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
183 |
|
0 | 184 |
void DrawNewsNewAircraftAvail(Window *w) |
185 |
{ |
|
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
186 |
EngineID engine; |
0 | 187 |
|
188 |
DrawNewsBorder(w); |
|
189 |
||
190 |
engine = WP(w,news_d).ni->string_id; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
191 |
|
0 | 192 |
DrawStringMultiCenter(w->width >> 1, 20, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE, w->width - 2); |
193 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
194 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
195 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 196 |
DrawStringMultiCenter(w->width >> 1, 57, STR_A02D, w->width - 2); |
197 |
||
198 |
DrawAircraftEngine(w->width >> 1, 93, engine, 0); |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
199 |
GfxFillRect(25, 56, w->width - 56, 110, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE)); |
0 | 200 |
DrawAircraftEngineInfo(engine, w->width >> 1, 131, w->width - 52); |
201 |
} |
|
202 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2218
diff
changeset
|
203 |
StringID GetNewsStringNewAircraftAvail(const NewsItem *ni) |
0 | 204 |
{ |
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
205 |
EngineID engine = ni->string_id; |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
206 |
SetDParam(0, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
207 |
SetDParam(1, GetCustomEngineName(engine)); |
0 | 208 |
return STR_02B6; |
209 |
} |
|
210 |
||
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
211 |
static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw) |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
212 |
{ |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
213 |
const RoadVehicleInfo *rvi = RoadVehInfo(engine); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
214 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
215 |
SetDParam(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5); |
5931 | 216 |
SetDParam(1, rvi->max_speed * 10 / 32); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
217 |
SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8); |
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:
4634
diff
changeset
|
218 |
SetDParam(3, rvi->cargo_type); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
219 |
SetDParam(4, rvi->capacity); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
220 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
221 |
DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
222 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
223 |
|
0 | 224 |
void DrawNewsNewRoadVehAvail(Window *w) |
225 |
{ |
|
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
226 |
EngineID engine; |
0 | 227 |
|
228 |
DrawNewsBorder(w); |
|
229 |
||
230 |
engine = WP(w,news_d).ni->string_id; |
|
231 |
DrawStringMultiCenter(w->width >> 1, 20, STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE, w->width - 2); |
|
232 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
233 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
234 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 235 |
DrawStringMultiCenter(w->width >> 1, 57, STR_9029, w->width - 2); |
236 |
||
237 |
DrawRoadVehEngine(w->width >> 1, 88, engine, 0); |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
238 |
GfxFillRect(25, 56, w->width - 56, 112, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE)); |
0 | 239 |
DrawRoadVehEngineInfo(engine, w->width >> 1, 129, w->width - 52); |
240 |
} |
|
241 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2218
diff
changeset
|
242 |
StringID GetNewsStringNewRoadVehAvail(const NewsItem *ni) |
0 | 243 |
{ |
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
244 |
EngineID engine = ni->string_id; |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
245 |
SetDParam(0, STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
246 |
SetDParam(1, GetCustomEngineName(engine)); |
0 | 247 |
return STR_02B6; |
248 |
} |
|
249 |
||
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
250 |
static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw) |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
251 |
{ |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
252 |
const ShipVehicleInfo *svi = ShipVehInfo(engine); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
253 |
SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5); |
5931 | 254 |
SetDParam(1, svi->max_speed * 10 / 32); |
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:
4634
diff
changeset
|
255 |
SetDParam(2, svi->cargo_type); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
256 |
SetDParam(3, svi->capacity); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
257 |
SetDParam(4, svi->running_cost * _price.ship_running >> 8); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
258 |
DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
259 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
260 |
|
0 | 261 |
void DrawNewsNewShipAvail(Window *w) |
262 |
{ |
|
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
263 |
EngineID engine; |
0 | 264 |
|
265 |
DrawNewsBorder(w); |
|
266 |
||
267 |
engine = WP(w,news_d).ni->string_id; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
268 |
|
0 | 269 |
DrawStringMultiCenter(w->width >> 1, 20, STR_982C_NEW_SHIP_NOW_AVAILABLE, w->width - 2); |
270 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
271 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
272 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 273 |
DrawStringMultiCenter(w->width >> 1, 57, STR_982D, w->width - 2); |
274 |
||
275 |
DrawShipEngine(w->width >> 1, 93, engine, 0); |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
276 |
GfxFillRect(25, 56, w->width - 56, 110, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE)); |
0 | 277 |
DrawShipEngineInfo(engine, w->width >> 1, 131, w->width - 52); |
278 |
} |
|
279 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2218
diff
changeset
|
280 |
StringID GetNewsStringNewShipAvail(const NewsItem *ni) |
0 | 281 |
{ |
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
282 |
EngineID engine = ni->string_id; |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
283 |
SetDParam(0, STR_982C_NEW_SHIP_NOW_AVAILABLE); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
284 |
SetDParam(1, GetCustomEngineName(engine)); |
0 | 285 |
return STR_02B6; |
286 |
} |