Files
@ r1872:f2d5f6d1aa5c
Branch filter:
Location: cpp/openttd-patchpack/source/engine_gui.c - annotation
r1872:f2d5f6d1aa5c
6.0 KiB
text/x-c
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | r0:d63b455452f6 r0:d63b455452f6 r507:b1b0a0a3c313 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r1095:c4ca8dd7cd3e r0:d63b455452f6 r460:c4c0c048eb73 r460:c4c0c048eb73 r460:c4c0c048eb73 r460:c4c0c048eb73 r460:c4c0c048eb73 r460:c4c0c048eb73 r460:c4c0c048eb73 r460:c4c0c048eb73 r460:c4c0c048eb73 r460:c4c0c048eb73 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r867:c270355a1b34 r867:c270355a1b34 r867:c270355a1b34 r867:c270355a1b34 r867:c270355a1b34 r176:7d9100f64c27 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r534:46e9db8de483 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r534:46e9db8de483 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r534:46e9db8de483 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r534:46e9db8de483 r534:46e9db8de483 r534:46e9db8de483 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r534:46e9db8de483 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r534:46e9db8de483 r534:46e9db8de483 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r534:46e9db8de483 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r534:46e9db8de483 r534:46e9db8de483 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r534:46e9db8de483 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r534:46e9db8de483 r534:46e9db8de483 r0:d63b455452f6 r0:d63b455452f6 | #include "stdafx.h"
#include "ttd.h"
#include "table/strings.h"
#include "window.h"
#include "gui.h"
#include "viewport.h"
#include "gfx.h"
#include "engine.h"
#include "command.h"
#include "news.h"
static StringID GetEngineCategoryName(byte engine)
{
if (engine < NUM_TRAIN_ENGINES) {
switch (_engines[engine].railtype) {
case 0:
return STR_8102_RAILROAD_LOCOMOTIVE;
case 1:
return STR_8106_MONORAIL_LOCOMOTIVE;
case 2:
return STR_8107_MAGLEV_LOCOMOTIVE;
}
}
if (engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES)
return STR_8103_ROAD_VEHICLE;
if (engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES)
return STR_8105_SHIP;
return STR_8104_AIRCRAFT;
}
static const Widget _engine_preview_widgets[] = {
{ WWT_TEXTBTN, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 5, 11, 299, 0, 13, STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_IMGBTN, RESIZE_NONE, 5, 0, 299, 14, 191, 0x0, STR_NULL},
{ WWT_PUSHTXTBTN, RESIZE_NONE, 5, 85, 144, 172, 183, STR_00C9_NO, STR_NULL},
{ WWT_PUSHTXTBTN, RESIZE_NONE, 5, 155, 214, 172, 183, STR_00C8_YES, STR_NULL},
{ WIDGETS_END},
};
typedef void DrawEngineProc(int x, int y, int engine, uint32 image_ormod);
typedef void DrawEngineInfoProc(int x, int y, int engine, int maxw);
typedef struct DrawEngineInfo {
DrawEngineProc *engine_proc;
DrawEngineInfoProc *info_proc;
} DrawEngineInfo;
static const DrawEngineInfo _draw_engine_list[4] = {
{DrawTrainEngine,DrawTrainEngineInfo},
{DrawRoadVehEngine,DrawRoadVehEngineInfo},
{DrawShipEngine,DrawShipEngineInfo},
{DrawAircraftEngine,DrawAircraftEngineInfo},
};
static void EnginePreviewWndProc(Window *w, WindowEvent *e)
{
byte eng;
int engine;
const DrawEngineInfo *dei;
int width;
switch(e->event) {
case WE_PAINT:
DrawWindowWidgets(w);
engine = w->window_number;
SetDParam(0, GetEngineCategoryName(engine));
DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296);
DrawStringCentered(w->width >> 1, 80, GetCustomEngineName(engine), 0x10);
eng = (byte)engine;
(dei = _draw_engine_list,eng < NUM_TRAIN_ENGINES) ||
(dei++,eng < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) ||
(dei++,eng < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) ||
(dei++, true);
width = w->width;
dei->engine_proc(width >> 1, 100, engine, 0);
dei->info_proc(engine, width >> 1, 130, width - 52);
break;
case WE_CLICK:
switch(e->click.widget) {
case 3: DeleteWindow(w); break;
case 4:
DoCommandP(0, w->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW);
DeleteWindow(w);
break;
}
break;
}
}
static const WindowDesc _engine_preview_desc = {
WDP_CENTER, WDP_CENTER, 300, 192,
WC_ENGINE_PREVIEW,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_engine_preview_widgets,
EnginePreviewWndProc
};
void ShowEnginePreviewWindow(int engine)
{
Window *w;
w = AllocateWindowDesc(&_engine_preview_desc);
w->window_number = engine;
}
void DrawNewsNewTrainAvail(Window *w)
{
int engine;
DrawNewsBorder(w);
engine = WP(w,news_d).ni->string_id;
SetDParam(0, GetEngineCategoryName(engine));
DrawStringMultiCenter(w->width >> 1, 20, STR_8859_NEW_NOW_AVAILABLE, w->width - 2);
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10);
SetDParam(0, GetCustomEngineName(engine));
DrawStringMultiCenter(w->width >> 1, 57, STR_885A, w->width - 2);
DrawTrainEngine(w->width >> 1, 88, engine, 0);
GfxFillRect(25, 56, w->width - 56, 112, 0x4323);
DrawTrainEngineInfo(engine, w->width >> 1, 129, w->width - 52);
}
StringID GetNewsStringNewTrainAvail(NewsItem *ni)
{
int engine = ni->string_id;
SetDParam(0, STR_8859_NEW_NOW_AVAILABLE);
SetDParam(1, GetEngineCategoryName(engine));
SetDParam(2, GetCustomEngineName(engine));
return STR_02B6;
}
void DrawNewsNewAircraftAvail(Window *w)
{
int engine;
DrawNewsBorder(w);
engine = WP(w,news_d).ni->string_id;
DrawStringMultiCenter(w->width >> 1, 20, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE, w->width - 2);
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10);
SetDParam(0, GetCustomEngineName(engine));
DrawStringMultiCenter(w->width >> 1, 57, STR_A02D, w->width - 2);
DrawAircraftEngine(w->width >> 1, 93, engine, 0);
GfxFillRect(25, 56, w->width - 56, 110, 0x4323);
DrawAircraftEngineInfo(engine, w->width >> 1, 131, w->width - 52);
}
StringID GetNewsStringNewAircraftAvail(NewsItem *ni)
{
int engine = ni->string_id;
SetDParam(0, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE);
SetDParam(1, GetCustomEngineName(engine));
return STR_02B6;
}
void DrawNewsNewRoadVehAvail(Window *w)
{
int engine;
DrawNewsBorder(w);
engine = WP(w,news_d).ni->string_id;
DrawStringMultiCenter(w->width >> 1, 20, STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE, w->width - 2);
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10);
SetDParam(0, GetCustomEngineName(engine));
DrawStringMultiCenter(w->width >> 1, 57, STR_9029, w->width - 2);
DrawRoadVehEngine(w->width >> 1, 88, engine, 0);
GfxFillRect(25, 56, w->width - 56, 112, 0x4323);
DrawRoadVehEngineInfo(engine, w->width >> 1, 129, w->width - 52);
}
StringID GetNewsStringNewRoadVehAvail(NewsItem *ni)
{
int engine = ni->string_id;
SetDParam(0, STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE);
SetDParam(1, GetCustomEngineName(engine));
return STR_02B6;
}
void DrawNewsNewShipAvail(Window *w)
{
int engine;
DrawNewsBorder(w);
engine = WP(w,news_d).ni->string_id;
DrawStringMultiCenter(w->width >> 1, 20, STR_982C_NEW_SHIP_NOW_AVAILABLE, w->width - 2);
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10);
SetDParam(0, GetCustomEngineName(engine));
DrawStringMultiCenter(w->width >> 1, 57, STR_982D, w->width - 2);
DrawShipEngine(w->width >> 1, 93, engine, 0);
GfxFillRect(25, 56, w->width - 56, 110, 0x4323);
DrawShipEngineInfo(engine, w->width >> 1, 131, w->width - 52);
}
StringID GetNewsStringNewShipAvail(NewsItem *ni)
{
int engine = ni->string_id;
SetDParam(0, STR_982C_NEW_SHIP_NOW_AVAILABLE);
SetDParam(1, GetCustomEngineName(engine));
return STR_02B6;
}
|