author | glx |
Sun, 08 Oct 2006 19:31:01 +0000 | |
changeset 4777 | bab9aa91c186 |
parent 4634 | 07699ac2bf37 |
child 4896 | f86350aaaaa5 |
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) { |
1926
530480d14685
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1891
diff
changeset
|
22 |
switch (GetEngine(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; |
460
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
27 |
} |
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
28 |
} |
0 | 29 |
|
30 |
if (engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) |
|
31 |
return STR_8103_ROAD_VEHICLE; |
|
32 |
||
33 |
if (engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) |
|
34 |
return STR_8105_SHIP; |
|
35 |
||
36 |
return STR_8104_AIRCRAFT; |
|
37 |
} |
|
38 |
||
39 |
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
|
40 |
{ 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
|
41 |
{ WWT_CAPTION, RESIZE_NONE, 5, 11, 299, 0, 13, STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
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
|
42 |
{ WWT_IMGBTN, RESIZE_NONE, 5, 0, 299, 14, 191, 0x0, 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
|
43 |
{ 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
|
44 |
{ 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
|
45 |
{ WIDGETS_END}, |
0 | 46 |
}; |
47 |
||
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
|
48 |
typedef void DrawEngineProc(int x, int y, EngineID engine, uint32 image_ormod); |
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
49 |
typedef void DrawEngineInfoProc(EngineID, int x, int y, int maxw); |
0 | 50 |
|
51 |
typedef struct DrawEngineInfo { |
|
52 |
DrawEngineProc *engine_proc; |
|
53 |
DrawEngineInfoProc *info_proc; |
|
54 |
} DrawEngineInfo; |
|
55 |
||
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
|
56 |
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
|
57 |
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
|
58 |
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
|
59 |
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
|
60 |
|
0 | 61 |
static const DrawEngineInfo _draw_engine_list[4] = { |
62 |
{DrawTrainEngine,DrawTrainEngineInfo}, |
|
63 |
{DrawRoadVehEngine,DrawRoadVehEngineInfo}, |
|
64 |
{DrawShipEngine,DrawShipEngineInfo}, |
|
65 |
{DrawAircraftEngine,DrawAircraftEngineInfo}, |
|
66 |
}; |
|
67 |
||
68 |
static void EnginePreviewWndProc(Window *w, WindowEvent *e) |
|
69 |
{ |
|
2639 | 70 |
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
|
71 |
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
|
72 |
EngineID engine = w->window_number; |
2639 | 73 |
const DrawEngineInfo* dei; |
74 |
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
|
75 |
|
0 | 76 |
DrawWindowWidgets(w); |
77 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
78 |
SetDParam(0, GetEngineCategoryName(engine)); |
0 | 79 |
DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296); |
80 |
||
81 |
DrawStringCentered(w->width >> 1, 80, GetCustomEngineName(engine), 0x10); |
|
82 |
||
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
|
83 |
(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
|
84 |
(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
|
85 |
(dei++,engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) || |
0 | 86 |
(dei++, true); |
87 |
||
88 |
width = w->width; |
|
89 |
dei->engine_proc(width >> 1, 100, engine, 0); |
|
90 |
dei->info_proc(engine, width >> 1, 130, width - 52); |
|
91 |
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
|
92 |
} |
0 | 93 |
|
94 |
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
|
95 |
switch (e->we.click.widget) { |
2639 | 96 |
case 3: |
97 |
DeleteWindow(w); |
|
98 |
break; |
|
99 |
||
100 |
case 4: |
|
101 |
DoCommandP(0, w->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW); |
|
102 |
DeleteWindow(w); |
|
103 |
break; |
|
0 | 104 |
} |
105 |
break; |
|
106 |
} |
|
107 |
} |
|
108 |
||
109 |
static const WindowDesc _engine_preview_desc = { |
|
110 |
WDP_CENTER, WDP_CENTER, 300, 192, |
|
111 |
WC_ENGINE_PREVIEW,0, |
|
112 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
113 |
_engine_preview_widgets, |
|
114 |
EnginePreviewWndProc |
|
115 |
}; |
|
116 |
||
117 |
||
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
|
118 |
void ShowEnginePreviewWindow(EngineID engine) |
0 | 119 |
{ |
120 |
Window *w; |
|
121 |
||
122 |
w = AllocateWindowDesc(&_engine_preview_desc); |
|
123 |
w->window_number = engine; |
|
124 |
} |
|
125 |
||
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
|
126 |
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
|
127 |
{ |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
128 |
const RailVehicleInfo *rvi = RailVehInfo(engine); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
129 |
uint multihead = (rvi->flags & RVI_MULTIHEAD) ? 1 : 0; |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
130 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
131 |
SetDParam(0, (_price.build_railvehicle >> 3) * rvi->base_cost >> 5); |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
132 |
SetDParam(2, rvi->max_speed); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
133 |
SetDParam(3, rvi->power << multihead); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
134 |
SetDParam(1, rvi->weight << multihead); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
135 |
|
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
|
136 |
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
|
137 |
|
2549 | 138 |
if (rvi->capacity != 0) { |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1998
diff
changeset
|
139 |
SetDParam(5, _cargoc.names_long[rvi->cargo_type]); |
2549 | 140 |
SetDParam(6, rvi->capacity << multihead); |
141 |
} else { |
|
142 |
SetDParam(5, STR_8838_N_A); |
|
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
143 |
} |
3401
3eb83140e401
(svn r4211) - Removed measuring units from the names of two strings.
peter1138
parents:
3355
diff
changeset
|
144 |
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
|
145 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
146 |
|
0 | 147 |
void DrawNewsNewTrainAvail(Window *w) |
148 |
{ |
|
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
|
149 |
EngineID engine; |
0 | 150 |
|
151 |
DrawNewsBorder(w); |
|
152 |
||
153 |
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
|
154 |
SetDParam(0, GetEngineCategoryName(engine)); |
0 | 155 |
DrawStringMultiCenter(w->width >> 1, 20, STR_8859_NEW_NOW_AVAILABLE, w->width - 2); |
156 |
||
157 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
158 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
159 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 160 |
DrawStringMultiCenter(w->width >> 1, 57, STR_885A, w->width - 2); |
161 |
||
162 |
DrawTrainEngine(w->width >> 1, 88, engine, 0); |
|
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
|
163 |
GfxFillRect(25, 56, w->width - 56, 112, 0x323 | USE_COLORTABLE); |
0 | 164 |
DrawTrainEngineInfo(engine, w->width >> 1, 129, w->width - 52); |
165 |
} |
|
166 |
||
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
|
167 |
StringID GetNewsStringNewTrainAvail(const NewsItem *ni) |
0 | 168 |
{ |
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
|
169 |
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
|
170 |
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
|
171 |
SetDParam(1, GetEngineCategoryName(engine)); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
172 |
SetDParam(2, GetCustomEngineName(engine)); |
0 | 173 |
return STR_02B6; |
174 |
} |
|
175 |
||
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
|
176 |
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
|
177 |
{ |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
178 |
const AircraftVehicleInfo *avi = AircraftVehInfo(engine); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
179 |
SetDParam(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5); |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
180 |
SetDParam(1, avi->max_speed * 128 / 10); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
181 |
SetDParam(2, avi->passenger_capacity); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
182 |
SetDParam(3, avi->mail_capacity); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
183 |
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
|
184 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
185 |
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
|
186 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
187 |
|
0 | 188 |
void DrawNewsNewAircraftAvail(Window *w) |
189 |
{ |
|
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
|
190 |
EngineID engine; |
0 | 191 |
|
192 |
DrawNewsBorder(w); |
|
193 |
||
194 |
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
|
195 |
|
0 | 196 |
DrawStringMultiCenter(w->width >> 1, 20, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE, w->width - 2); |
197 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
198 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
199 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 200 |
DrawStringMultiCenter(w->width >> 1, 57, STR_A02D, w->width - 2); |
201 |
||
202 |
DrawAircraftEngine(w->width >> 1, 93, engine, 0); |
|
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
|
203 |
GfxFillRect(25, 56, w->width - 56, 110, 0x323 | USE_COLORTABLE); |
0 | 204 |
DrawAircraftEngineInfo(engine, w->width >> 1, 131, w->width - 52); |
205 |
} |
|
206 |
||
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
|
207 |
StringID GetNewsStringNewAircraftAvail(const NewsItem *ni) |
0 | 208 |
{ |
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
|
209 |
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
|
210 |
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
|
211 |
SetDParam(1, GetCustomEngineName(engine)); |
0 | 212 |
return STR_02B6; |
213 |
} |
|
214 |
||
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
|
215 |
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
|
216 |
{ |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
217 |
const RoadVehicleInfo *rvi = RoadVehInfo(engine); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
218 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
219 |
SetDParam(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5); |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
220 |
SetDParam(1, rvi->max_speed / 2); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
221 |
SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8); |
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 |
SetDParam(4, rvi->capacity); |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1998
diff
changeset
|
224 |
SetDParam(3, _cargoc.names_long[rvi->cargo_type]); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
225 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
226 |
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
|
227 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
228 |
|
0 | 229 |
void DrawNewsNewRoadVehAvail(Window *w) |
230 |
{ |
|
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
|
231 |
EngineID engine; |
0 | 232 |
|
233 |
DrawNewsBorder(w); |
|
234 |
||
235 |
engine = WP(w,news_d).ni->string_id; |
|
236 |
DrawStringMultiCenter(w->width >> 1, 20, STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE, w->width - 2); |
|
237 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
238 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
239 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 240 |
DrawStringMultiCenter(w->width >> 1, 57, STR_9029, w->width - 2); |
241 |
||
242 |
DrawRoadVehEngine(w->width >> 1, 88, engine, 0); |
|
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
|
243 |
GfxFillRect(25, 56, w->width - 56, 112, 0x323 | USE_COLORTABLE); |
0 | 244 |
DrawRoadVehEngineInfo(engine, w->width >> 1, 129, w->width - 52); |
245 |
} |
|
246 |
||
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
|
247 |
StringID GetNewsStringNewRoadVehAvail(const NewsItem *ni) |
0 | 248 |
{ |
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
|
249 |
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
|
250 |
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
|
251 |
SetDParam(1, GetCustomEngineName(engine)); |
0 | 252 |
return STR_02B6; |
253 |
} |
|
254 |
||
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
|
255 |
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
|
256 |
{ |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
257 |
const ShipVehicleInfo *svi = ShipVehInfo(engine); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
258 |
SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5); |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
259 |
SetDParam(1, svi->max_speed / 2); |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1998
diff
changeset
|
260 |
SetDParam(2, _cargoc.names_long[svi->cargo_type]); |
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
261 |
SetDParam(3, svi->capacity); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
262 |
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
|
263 |
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
|
264 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
265 |
|
0 | 266 |
void DrawNewsNewShipAvail(Window *w) |
267 |
{ |
|
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
|
268 |
EngineID engine; |
0 | 269 |
|
270 |
DrawNewsBorder(w); |
|
271 |
||
272 |
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
|
273 |
|
0 | 274 |
DrawStringMultiCenter(w->width >> 1, 20, STR_982C_NEW_SHIP_NOW_AVAILABLE, w->width - 2); |
275 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
276 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
277 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 278 |
DrawStringMultiCenter(w->width >> 1, 57, STR_982D, w->width - 2); |
279 |
||
280 |
DrawShipEngine(w->width >> 1, 93, engine, 0); |
|
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
|
281 |
GfxFillRect(25, 56, w->width - 56, 110, 0x323 | USE_COLORTABLE); |
0 | 282 |
DrawShipEngineInfo(engine, w->width >> 1, 131, w->width - 52); |
283 |
} |
|
284 |
||
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
|
285 |
StringID GetNewsStringNewShipAvail(const NewsItem *ni) |
0 | 286 |
{ |
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
|
287 |
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
|
288 |
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
|
289 |
SetDParam(1, GetCustomEngineName(engine)); |
0 | 290 |
return STR_02B6; |
291 |
} |