author | Darkvater |
Mon, 30 Jan 2006 14:03:34 +0000 | |
changeset 2929 | f54492d3dea8 |
parent 2840 | d68a605b2087 |
child 2962 | dbd168a4703a |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1095
diff
changeset
|
4 |
#include "openttd.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
460
diff
changeset
|
5 |
#include "table/strings.h" |
2218
abd47ef7d902
(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
637ec3c361f5
(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
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2084
diff
changeset
|
15 |
#include "variables.h" |
0 | 16 |
|
17 |
||
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
|
18 |
static StringID GetEngineCategoryName(EngineID engine) |
0 | 19 |
{ |
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
20 |
if (engine < NUM_TRAIN_ENGINES) { |
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1891
diff
changeset
|
21 |
switch (GetEngine(engine)->railtype) { |
2519
67a2d670c17e
(svn r3048) Replace 0/1/2 by RAILTYPE_RAIL/MONO/MAGLEV where appropriate
tron
parents:
2477
diff
changeset
|
22 |
case RAILTYPE_RAIL: return STR_8102_RAILROAD_LOCOMOTIVE; |
67a2d670c17e
(svn r3048) Replace 0/1/2 by RAILTYPE_RAIL/MONO/MAGLEV where appropriate
tron
parents:
2477
diff
changeset
|
23 |
case RAILTYPE_MONO: return STR_8106_MONORAIL_LOCOMOTIVE; |
67a2d670c17e
(svn r3048) Replace 0/1/2 by RAILTYPE_RAIL/MONO/MAGLEV where appropriate
tron
parents:
2477
diff
changeset
|
24 |
case RAILTYPE_MAGLEV: return STR_8107_MAGLEV_LOCOMOTIVE; |
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
25 |
} |
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
26 |
} |
0 | 27 |
|
28 |
if (engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) |
|
29 |
return STR_8103_ROAD_VEHICLE; |
|
30 |
||
31 |
if (engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) |
|
32 |
return STR_8105_SHIP; |
|
33 |
||
34 |
return STR_8104_AIRCRAFT; |
|
35 |
} |
|
36 |
||
37 |
static const Widget _engine_preview_widgets[] = { |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
38 |
{ 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
|
39 |
{ WWT_CAPTION, RESIZE_NONE, 5, 11, 299, 0, 13, STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
534
diff
changeset
|
40 |
{ WWT_IMGBTN, RESIZE_NONE, 5, 0, 299, 14, 191, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
534
diff
changeset
|
41 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 5, 85, 144, 172, 183, STR_00C9_NO, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
534
diff
changeset
|
42 |
{ 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
|
43 |
{ WIDGETS_END}, |
0 | 44 |
}; |
45 |
||
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
|
46 |
typedef void DrawEngineProc(int x, int y, EngineID engine, uint32 image_ormod); |
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
47 |
typedef void DrawEngineInfoProc(EngineID, int x, int y, int maxw); |
0 | 48 |
|
49 |
typedef struct DrawEngineInfo { |
|
50 |
DrawEngineProc *engine_proc; |
|
51 |
DrawEngineInfoProc *info_proc; |
|
52 |
} DrawEngineInfo; |
|
53 |
||
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
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
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
|
58 |
|
0 | 59 |
static const DrawEngineInfo _draw_engine_list[4] = { |
60 |
{DrawTrainEngine,DrawTrainEngineInfo}, |
|
61 |
{DrawRoadVehEngine,DrawRoadVehEngineInfo}, |
|
62 |
{DrawShipEngine,DrawShipEngineInfo}, |
|
63 |
{DrawAircraftEngine,DrawAircraftEngineInfo}, |
|
64 |
}; |
|
65 |
||
66 |
static void EnginePreviewWndProc(Window *w, WindowEvent *e) |
|
67 |
{ |
|
2639 | 68 |
switch (e->event) { |
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
|
69 |
case WE_PAINT: { |
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
70 |
EngineID engine = w->window_number; |
2639 | 71 |
const DrawEngineInfo* dei; |
72 |
int width; |
|
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
|
73 |
|
0 | 74 |
DrawWindowWidgets(w); |
75 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
76 |
SetDParam(0, GetEngineCategoryName(engine)); |
0 | 77 |
DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296); |
78 |
||
79 |
DrawStringCentered(w->width >> 1, 80, GetCustomEngineName(engine), 0x10); |
|
80 |
||
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
|
81 |
(dei = _draw_engine_list,engine < NUM_TRAIN_ENGINES) || |
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2436
diff
changeset
|
82 |
(dei++,engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) || |
d454d5152386
(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++,engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) || |
0 | 84 |
(dei++, true); |
85 |
||
86 |
width = w->width; |
|
87 |
dei->engine_proc(width >> 1, 100, engine, 0); |
|
88 |
dei->info_proc(engine, width >> 1, 130, width - 52); |
|
89 |
break; |
|
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
|
90 |
} |
0 | 91 |
|
92 |
case WE_CLICK: |
|
2639 | 93 |
switch (e->click.widget) { |
94 |
case 3: |
|
95 |
DeleteWindow(w); |
|
96 |
break; |
|
97 |
||
98 |
case 4: |
|
99 |
DoCommandP(0, w->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW); |
|
100 |
DeleteWindow(w); |
|
101 |
break; |
|
0 | 102 |
} |
103 |
break; |
|
104 |
} |
|
105 |
} |
|
106 |
||
107 |
static const WindowDesc _engine_preview_desc = { |
|
108 |
WDP_CENTER, WDP_CENTER, 300, 192, |
|
109 |
WC_ENGINE_PREVIEW,0, |
|
110 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
111 |
_engine_preview_widgets, |
|
112 |
EnginePreviewWndProc |
|
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 |
{ |
118 |
Window *w; |
|
119 |
||
120 |
w = AllocateWindowDesc(&_engine_preview_desc); |
|
121 |
w->window_number = engine; |
|
122 |
} |
|
123 |
||
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
|
124 |
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
|
125 |
{ |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
126 |
const RailVehicleInfo *rvi = RailVehInfo(engine); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
127 |
uint multihead = (rvi->flags & RVI_MULTIHEAD) ? 1 : 0; |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
128 |
|
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
129 |
SetDParam(0, (_price.build_railvehicle >> 3) * rvi->base_cost >> 5); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
130 |
SetDParam(2, rvi->max_speed * 10 >> 4); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
131 |
SetDParam(3, rvi->power << multihead); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
132 |
SetDParam(1, rvi->weight << multihead); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
133 |
|
2840
d68a605b2087
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2725
diff
changeset
|
134 |
SetDParam(4, rvi->running_cost_base * _price.running_rail[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
|
135 |
|
2549 | 136 |
if (rvi->capacity != 0) { |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1998
diff
changeset
|
137 |
SetDParam(5, _cargoc.names_long[rvi->cargo_type]); |
2549 | 138 |
SetDParam(6, rvi->capacity << multihead); |
139 |
} else { |
|
140 |
SetDParam(5, STR_8838_N_A); |
|
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
141 |
} |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
142 |
DrawStringMultiCenter(x, y, STR_885B_COST_WEIGHT_T_SPEED_POWER, maxw); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
143 |
} |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
144 |
|
0 | 145 |
void DrawNewsNewTrainAvail(Window *w) |
146 |
{ |
|
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
|
147 |
EngineID engine; |
0 | 148 |
|
149 |
DrawNewsBorder(w); |
|
150 |
||
151 |
engine = WP(w,news_d).ni->string_id; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
152 |
SetDParam(0, GetEngineCategoryName(engine)); |
0 | 153 |
DrawStringMultiCenter(w->width >> 1, 20, STR_8859_NEW_NOW_AVAILABLE, w->width - 2); |
154 |
||
155 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
156 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
157 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 158 |
DrawStringMultiCenter(w->width >> 1, 57, STR_885A, w->width - 2); |
159 |
||
160 |
DrawTrainEngine(w->width >> 1, 88, engine, 0); |
|
2218
abd47ef7d902
(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
|
161 |
GfxFillRect(25, 56, w->width - 56, 112, 0x323 | USE_COLORTABLE); |
0 | 162 |
DrawTrainEngineInfo(engine, w->width >> 1, 129, w->width - 52); |
163 |
} |
|
164 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2218
diff
changeset
|
165 |
StringID GetNewsStringNewTrainAvail(const NewsItem *ni) |
0 | 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 |
EngineID engine = ni->string_id; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
168 |
SetDParam(0, STR_8859_NEW_NOW_AVAILABLE); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
169 |
SetDParam(1, GetEngineCategoryName(engine)); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
170 |
SetDParam(2, GetCustomEngineName(engine)); |
0 | 171 |
return STR_02B6; |
172 |
} |
|
173 |
||
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
|
174 |
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
|
175 |
{ |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
176 |
const AircraftVehicleInfo *avi = AircraftVehInfo(engine); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
177 |
SetDParam(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
178 |
SetDParam(1, avi->max_speed << 3); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
179 |
SetDParam(2, avi->passenger_capacity); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
180 |
SetDParam(3, avi->mail_capacity); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
181 |
SetDParam(4, avi->running_cost * _price.aircraft_running >> 8); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
182 |
|
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
183 |
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
|
184 |
} |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
185 |
|
0 | 186 |
void DrawNewsNewAircraftAvail(Window *w) |
187 |
{ |
|
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
|
188 |
EngineID engine; |
0 | 189 |
|
190 |
DrawNewsBorder(w); |
|
191 |
||
192 |
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
|
193 |
|
0 | 194 |
DrawStringMultiCenter(w->width >> 1, 20, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE, w->width - 2); |
195 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
196 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
197 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 198 |
DrawStringMultiCenter(w->width >> 1, 57, STR_A02D, w->width - 2); |
199 |
||
200 |
DrawAircraftEngine(w->width >> 1, 93, engine, 0); |
|
2218
abd47ef7d902
(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
|
201 |
GfxFillRect(25, 56, w->width - 56, 110, 0x323 | USE_COLORTABLE); |
0 | 202 |
DrawAircraftEngineInfo(engine, w->width >> 1, 131, w->width - 52); |
203 |
} |
|
204 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2218
diff
changeset
|
205 |
StringID GetNewsStringNewAircraftAvail(const NewsItem *ni) |
0 | 206 |
{ |
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
|
207 |
EngineID engine = ni->string_id; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
208 |
SetDParam(0, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
209 |
SetDParam(1, GetCustomEngineName(engine)); |
0 | 210 |
return STR_02B6; |
211 |
} |
|
212 |
||
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
|
213 |
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
|
214 |
{ |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
215 |
const RoadVehicleInfo *rvi = RoadVehInfo(engine); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
216 |
|
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
217 |
SetDParam(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
218 |
SetDParam(1, rvi->max_speed * 10 >> 5); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
219 |
SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
220 |
|
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
221 |
SetDParam(4, rvi->capacity); |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1998
diff
changeset
|
222 |
SetDParam(3, _cargoc.names_long[rvi->cargo_type]); |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
223 |
|
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
224 |
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
|
225 |
} |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
226 |
|
0 | 227 |
void DrawNewsNewRoadVehAvail(Window *w) |
228 |
{ |
|
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
|
229 |
EngineID engine; |
0 | 230 |
|
231 |
DrawNewsBorder(w); |
|
232 |
||
233 |
engine = WP(w,news_d).ni->string_id; |
|
234 |
DrawStringMultiCenter(w->width >> 1, 20, STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE, w->width - 2); |
|
235 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
236 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
237 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 238 |
DrawStringMultiCenter(w->width >> 1, 57, STR_9029, w->width - 2); |
239 |
||
240 |
DrawRoadVehEngine(w->width >> 1, 88, engine, 0); |
|
2218
abd47ef7d902
(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
|
241 |
GfxFillRect(25, 56, w->width - 56, 112, 0x323 | USE_COLORTABLE); |
0 | 242 |
DrawRoadVehEngineInfo(engine, w->width >> 1, 129, w->width - 52); |
243 |
} |
|
244 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2218
diff
changeset
|
245 |
StringID GetNewsStringNewRoadVehAvail(const NewsItem *ni) |
0 | 246 |
{ |
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
|
247 |
EngineID engine = ni->string_id; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
248 |
SetDParam(0, STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
249 |
SetDParam(1, GetCustomEngineName(engine)); |
0 | 250 |
return STR_02B6; |
251 |
} |
|
252 |
||
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
|
253 |
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
|
254 |
{ |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
255 |
const ShipVehicleInfo *svi = ShipVehInfo(engine); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
256 |
SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
257 |
SetDParam(1, svi->max_speed * 10 >> 5); |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1998
diff
changeset
|
258 |
SetDParam(2, _cargoc.names_long[svi->cargo_type]); |
1998
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
259 |
SetDParam(3, svi->capacity); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
260 |
SetDParam(4, svi->running_cost * _price.ship_running >> 8); |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
261 |
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
|
262 |
} |
849933cfa8de
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
263 |
|
0 | 264 |
void DrawNewsNewShipAvail(Window *w) |
265 |
{ |
|
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
|
266 |
EngineID engine; |
0 | 267 |
|
268 |
DrawNewsBorder(w); |
|
269 |
||
270 |
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
|
271 |
|
0 | 272 |
DrawStringMultiCenter(w->width >> 1, 20, STR_982C_NEW_SHIP_NOW_AVAILABLE, w->width - 2); |
273 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
274 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
275 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 276 |
DrawStringMultiCenter(w->width >> 1, 57, STR_982D, w->width - 2); |
277 |
||
278 |
DrawShipEngine(w->width >> 1, 93, engine, 0); |
|
2218
abd47ef7d902
(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
|
279 |
GfxFillRect(25, 56, w->width - 56, 110, 0x323 | USE_COLORTABLE); |
0 | 280 |
DrawShipEngineInfo(engine, w->width >> 1, 131, w->width - 52); |
281 |
} |
|
282 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2218
diff
changeset
|
283 |
StringID GetNewsStringNewShipAvail(const NewsItem *ni) |
0 | 284 |
{ |
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
|
285 |
EngineID engine = ni->string_id; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
286 |
SetDParam(0, STR_982C_NEW_SHIP_NOW_AVAILABLE); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
287 |
SetDParam(1, GetCustomEngineName(engine)); |
0 | 288 |
return STR_02B6; |
289 |
} |