author | tron |
Sat, 30 Jul 2005 09:29:20 +0000 | |
changeset 2238 | 33361a216301 |
parent 2218 | 2132596a35c0 |
child 2436 | 7d5df545bd5d |
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" |
0 | 16 |
|
17 |
||
1095 | 18 |
static StringID GetEngineCategoryName(byte engine) |
0 | 19 |
{ |
460
7506c66ce4c3
(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
530480d14685
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1891
diff
changeset
|
21 |
switch (GetEngine(engine)->railtype) { |
460
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
22 |
case 0: |
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
23 |
return STR_8102_RAILROAD_LOCOMOTIVE; |
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
24 |
case 1: |
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
25 |
return STR_8106_MONORAIL_LOCOMOTIVE; |
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
26 |
case 2: |
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
193
diff
changeset
|
27 |
return STR_8107_MAGLEV_LOCOMOTIVE; |
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[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
534
diff
changeset
|
41 |
{ WWT_TEXTBTN, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
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}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
534
diff
changeset
|
43 |
{ WWT_IMGBTN, RESIZE_NONE, 5, 0, 299, 14, 191, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
534
diff
changeset
|
44 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 5, 85, 144, 172, 183, STR_00C9_NO, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
534
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 |
||
49 |
typedef void DrawEngineProc(int x, int y, int engine, uint32 image_ormod); |
|
50 |
typedef void DrawEngineInfoProc(int x, int y, int engine, int maxw); |
|
51 |
||
52 |
typedef struct DrawEngineInfo { |
|
53 |
DrawEngineProc *engine_proc; |
|
54 |
DrawEngineInfoProc *info_proc; |
|
55 |
} DrawEngineInfo; |
|
56 |
||
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
57 |
static void DrawTrainEngineInfo(int engine, int x, int y, int maxw); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
58 |
static void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
59 |
static void DrawShipEngineInfo(int engine, int x, int y, int maxw); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
60 |
static void DrawAircraftEngineInfo(int engine, int x, int y, int maxw); |
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 |
{ |
|
71 |
byte eng; |
|
72 |
int engine; |
|
73 |
const DrawEngineInfo *dei; |
|
74 |
int width; |
|
75 |
||
76 |
switch(e->event) { |
|
77 |
case WE_PAINT: |
|
78 |
DrawWindowWidgets(w); |
|
79 |
engine = w->window_number; |
|
80 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
81 |
SetDParam(0, GetEngineCategoryName(engine)); |
0 | 82 |
DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296); |
83 |
||
84 |
DrawStringCentered(w->width >> 1, 80, GetCustomEngineName(engine), 0x10); |
|
85 |
||
86 |
eng = (byte)engine; |
|
87 |
(dei = _draw_engine_list,eng < NUM_TRAIN_ENGINES) || |
|
88 |
(dei++,eng < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) || |
|
89 |
(dei++,eng < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) || |
|
90 |
(dei++, true); |
|
91 |
||
92 |
width = w->width; |
|
93 |
dei->engine_proc(width >> 1, 100, engine, 0); |
|
94 |
dei->info_proc(engine, width >> 1, 130, width - 52); |
|
95 |
break; |
|
96 |
||
97 |
case WE_CLICK: |
|
98 |
switch(e->click.widget) { |
|
99 |
case 3: DeleteWindow(w); break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
100 |
case 4: |
0 | 101 |
DoCommandP(0, w->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW); |
102 |
DeleteWindow(w); |
|
103 |
break; |
|
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 |
||
118 |
void ShowEnginePreviewWindow(int engine) |
|
119 |
{ |
|
120 |
Window *w; |
|
121 |
||
122 |
w = AllocateWindowDesc(&_engine_preview_desc); |
|
123 |
w->window_number = engine; |
|
124 |
} |
|
125 |
||
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
126 |
static void DrawTrainEngineInfo(int engine, int x, int y, int maxw) |
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 |
int cap; |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
130 |
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
|
131 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
132 |
SetDParam(0, (_price.build_railvehicle >> 3) * rvi->base_cost >> 5); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
133 |
SetDParam(2, rvi->max_speed * 10 >> 4); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
134 |
SetDParam(3, rvi->power << multihead); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
135 |
SetDParam(1, rvi->weight << multihead); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
136 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
137 |
SetDParam(4, rvi->running_cost_base * _price.running_rail[rvi->engclass] >> 8 << multihead); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
138 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
139 |
cap = rvi->capacity; |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
140 |
SetDParam(5, STR_8838_N_A); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
141 |
if (cap != 0) { |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
142 |
SetDParam(6, cap << multihead); |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1998
diff
changeset
|
143 |
SetDParam(5, _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
|
144 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
145 |
DrawStringMultiCenter(x, y, STR_885B_COST_WEIGHT_T_SPEED_POWER, maxw); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
146 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
147 |
|
0 | 148 |
void DrawNewsNewTrainAvail(Window *w) |
149 |
{ |
|
150 |
int engine; |
|
151 |
||
152 |
DrawNewsBorder(w); |
|
153 |
||
154 |
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
|
155 |
SetDParam(0, GetEngineCategoryName(engine)); |
0 | 156 |
DrawStringMultiCenter(w->width >> 1, 20, STR_8859_NEW_NOW_AVAILABLE, w->width - 2); |
157 |
||
158 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
159 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
160 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 161 |
DrawStringMultiCenter(w->width >> 1, 57, STR_885A, w->width - 2); |
162 |
||
163 |
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
|
164 |
GfxFillRect(25, 56, w->width - 56, 112, 0x323 | USE_COLORTABLE); |
0 | 165 |
DrawTrainEngineInfo(engine, w->width >> 1, 129, w->width - 52); |
166 |
} |
|
167 |
||
168 |
StringID GetNewsStringNewTrainAvail(NewsItem *ni) |
|
169 |
{ |
|
170 |
int engine = ni->string_id; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
171 |
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
|
172 |
SetDParam(1, GetEngineCategoryName(engine)); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
173 |
SetDParam(2, GetCustomEngineName(engine)); |
0 | 174 |
return STR_02B6; |
175 |
} |
|
176 |
||
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
177 |
static void DrawAircraftEngineInfo(int engine, int x, int y, int maxw) |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
178 |
{ |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
179 |
const AircraftVehicleInfo *avi = AircraftVehInfo(engine); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
180 |
SetDParam(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
181 |
SetDParam(1, avi->max_speed << 3); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
182 |
SetDParam(2, avi->passenger_capacity); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
183 |
SetDParam(3, avi->mail_capacity); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
184 |
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
|
185 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
186 |
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
|
187 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
188 |
|
0 | 189 |
void DrawNewsNewAircraftAvail(Window *w) |
190 |
{ |
|
191 |
int engine; |
|
192 |
||
193 |
DrawNewsBorder(w); |
|
194 |
||
195 |
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
|
196 |
|
0 | 197 |
DrawStringMultiCenter(w->width >> 1, 20, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE, w->width - 2); |
198 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
199 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
200 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 201 |
DrawStringMultiCenter(w->width >> 1, 57, STR_A02D, w->width - 2); |
202 |
||
203 |
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
|
204 |
GfxFillRect(25, 56, w->width - 56, 110, 0x323 | USE_COLORTABLE); |
0 | 205 |
DrawAircraftEngineInfo(engine, w->width >> 1, 131, w->width - 52); |
206 |
} |
|
207 |
||
208 |
StringID GetNewsStringNewAircraftAvail(NewsItem *ni) |
|
209 |
{ |
|
210 |
int engine = ni->string_id; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
211 |
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
|
212 |
SetDParam(1, GetCustomEngineName(engine)); |
0 | 213 |
return STR_02B6; |
214 |
} |
|
215 |
||
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
216 |
static void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw) |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
217 |
{ |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
218 |
const RoadVehicleInfo *rvi = RoadVehInfo(engine); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
219 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
220 |
SetDParam(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
221 |
SetDParam(1, rvi->max_speed * 10 >> 5); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
222 |
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
|
223 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
224 |
SetDParam(4, rvi->capacity); |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1998
diff
changeset
|
225 |
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
|
226 |
|
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
227 |
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
|
228 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
229 |
|
0 | 230 |
void DrawNewsNewRoadVehAvail(Window *w) |
231 |
{ |
|
232 |
int engine; |
|
233 |
||
234 |
DrawNewsBorder(w); |
|
235 |
||
236 |
engine = WP(w,news_d).ni->string_id; |
|
237 |
DrawStringMultiCenter(w->width >> 1, 20, STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE, w->width - 2); |
|
238 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
239 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
240 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 241 |
DrawStringMultiCenter(w->width >> 1, 57, STR_9029, w->width - 2); |
242 |
||
243 |
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
|
244 |
GfxFillRect(25, 56, w->width - 56, 112, 0x323 | USE_COLORTABLE); |
0 | 245 |
DrawRoadVehEngineInfo(engine, w->width >> 1, 129, w->width - 52); |
246 |
} |
|
247 |
||
248 |
StringID GetNewsStringNewRoadVehAvail(NewsItem *ni) |
|
249 |
{ |
|
250 |
int engine = ni->string_id; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
251 |
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
|
252 |
SetDParam(1, GetCustomEngineName(engine)); |
0 | 253 |
return STR_02B6; |
254 |
} |
|
255 |
||
1998
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
256 |
static void DrawShipEngineInfo(int engine, int x, int y, int maxw) |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
257 |
{ |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
258 |
const ShipVehicleInfo *svi = ShipVehInfo(engine); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
259 |
SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
260 |
SetDParam(1, svi->max_speed * 10 >> 5); |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1998
diff
changeset
|
261 |
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
|
262 |
SetDParam(3, svi->capacity); |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
263 |
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
|
264 |
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
|
265 |
} |
23c42534e2a9
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
tron
parents:
1926
diff
changeset
|
266 |
|
0 | 267 |
void DrawNewsNewShipAvail(Window *w) |
268 |
{ |
|
269 |
int engine; |
|
270 |
||
271 |
DrawNewsBorder(w); |
|
272 |
||
273 |
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
|
274 |
|
0 | 275 |
DrawStringMultiCenter(w->width >> 1, 20, STR_982C_NEW_SHIP_NOW_AVAILABLE, w->width - 2); |
276 |
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10); |
|
277 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
278 |
SetDParam(0, GetCustomEngineName(engine)); |
0 | 279 |
DrawStringMultiCenter(w->width >> 1, 57, STR_982D, w->width - 2); |
280 |
||
281 |
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
|
282 |
GfxFillRect(25, 56, w->width - 56, 110, 0x323 | USE_COLORTABLE); |
0 | 283 |
DrawShipEngineInfo(engine, w->width >> 1, 131, w->width - 52); |
284 |
} |
|
285 |
||
286 |
StringID GetNewsStringNewShipAvail(NewsItem *ni) |
|
287 |
{ |
|
288 |
int engine = ni->string_id; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
289 |
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
|
290 |
SetDParam(1, GetCustomEngineName(engine)); |
0 | 291 |
return STR_02B6; |
292 |
} |