annotate src/engine_gui.cpp @ 11373:474ba6cc0946 draft

(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
author rubidium <rubidium@openttd.org>
date Sun, 15 Mar 2009 15:12:06 +0000
parents 15471cd58e0a
children 17fa6dfa4cb1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
9111
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 9070
diff changeset
3 /** @file engine_gui.cpp GUI to show engine related information. */
6125
46d001ebacf6 (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents: 5931
diff changeset
4
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
5 #include "stdafx.h"
8107
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
6 #include "window_gui.h"
8224
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8131
diff changeset
7 #include "gfx_func.h"
8786
e2d4956b7251 (svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
rubidium <rubidium@openttd.org>
parents: 8763
diff changeset
8 #include "engine_func.h"
9070
11b5b3f4175d (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138 <peter1138@openttd.org>
parents: 8786
diff changeset
9 #include "engine_base.h"
8116
9cc845deddfe (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents: 8114
diff changeset
10 #include "command_func.h"
10960
a4e5b5d2837c (svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents: 10927
diff changeset
11 #include "news_type.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
12 #include "newgrf_engine.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8107
diff changeset
13 #include "strings_func.h"
9380
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
14 #include "engine_gui.h"
9567
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
15 #include "articulated_vehicles.h"
10000
4b2c65748b47 (svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138 <peter1138@openttd.org>
parents: 9923
diff changeset
16 #include "rail.h"
11355
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
17 #include "aircraft.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
18
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
19 #include "table/strings.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
20 #include "table/sprites.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
21
9199
dbe675dc54c4 (svn r13065) -Codechange: remove the need for the news string callbacks. Patch by Cirdan.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
22 StringID GetEngineCategoryName(EngineID engine)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
23 {
6209
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
24 switch (GetEngine(engine)->type) {
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
25 default: NOT_REACHED();
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
26 case VEH_ROAD: return STR_8103_ROAD_VEHICLE;
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
27 case VEH_AIRCRAFT: return STR_8104_AIRCRAFT;
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
28 case VEH_SHIP: return STR_8105_SHIP;
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
29 case VEH_TRAIN:
10000
4b2c65748b47 (svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138 <peter1138@openttd.org>
parents: 9923
diff changeset
30 return GetRailTypeInfo(RailVehInfo(engine)->railtype)->strings.new_loco;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
31 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
32 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
33
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
34 static const Widget _engine_preview_widgets[] = {
9744
f7984f34c13a (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas <belugas@openttd.org>
parents: 9720
diff changeset
35 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_LIGHT_BLUE, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
f7984f34c13a (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas <belugas@openttd.org>
parents: 9720
diff changeset
36 { WWT_CAPTION, RESIZE_NONE, COLOUR_LIGHT_BLUE, 11, 299, 0, 13, STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE, STR_018C_WINDOW_TITLE_DRAG_THIS},
f7984f34c13a (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas <belugas@openttd.org>
parents: 9720
diff changeset
37 { WWT_PANEL, RESIZE_NONE, COLOUR_LIGHT_BLUE, 0, 299, 14, 191, 0x0, STR_NULL},
f7984f34c13a (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas <belugas@openttd.org>
parents: 9720
diff changeset
38 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_LIGHT_BLUE, 85, 144, 172, 183, STR_00C9_NO, STR_NULL},
f7984f34c13a (svn r13879) -Codechange: Replace numbers with Colours enum on engine, industries and group gui
belugas <belugas@openttd.org>
parents: 9720
diff changeset
39 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_LIGHT_BLUE, 155, 214, 172, 183, STR_00C8_YES, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
40 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
41 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
42
5668
3d6d9bff3dd8 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents: 5587
diff changeset
43 typedef void DrawEngineProc(int x, int y, EngineID engine, SpriteID pal);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
44 typedef void DrawEngineInfoProc(EngineID, int x, int y, int maxw);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
45
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6209
diff changeset
46 struct DrawEngineInfo {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
47 DrawEngineProc *engine_proc;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
48 DrawEngineInfoProc *info_proc;
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6209
diff changeset
49 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
50
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
51 static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
52 static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
53 static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
54 static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
55
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
56 static const DrawEngineInfo _draw_engine_list[4] = {
6209
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
57 { DrawTrainEngine, DrawTrainEngineInfo },
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
58 { DrawRoadVehEngine, DrawRoadVehEngineInfo },
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
59 { DrawShipEngine, DrawShipEngineInfo },
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
60 { DrawAircraftEngine, DrawAircraftEngineInfo },
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
61 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
62
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
63 struct EnginePreviewWindow : Window {
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
64 EnginePreviewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
65 {
9333
5236ba6c7d54 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138 <peter1138@openttd.org>
parents: 9317
diff changeset
66 this->FindWindowPlacementAndResize(desc);
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
67 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
68
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
69 virtual void OnPaint()
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
70 {
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
71 this->DrawWidgets();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
72
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
73 EngineID engine = this->window_number;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
74 SetDParam(0, GetEngineCategoryName(engine));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
75 DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
76
7059
88ca8902530e (svn r10324) -Codechange: reference engine names by index
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
77 SetDParam(0, engine);
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
78 DrawStringCentered(this->width >> 1, 80, STR_ENGINE_NAME, TC_BLACK);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
79
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
80 const DrawEngineInfo *dei = &_draw_engine_list[GetEngine(engine)->type];
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
81
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
82 int width = this->width;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
83 dei->engine_proc(width >> 1, 100, engine, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
84 dei->info_proc(engine, width >> 1, 130, width - 52);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
85 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
86
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
87 virtual void OnClick(Point pt, int widget)
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
88 {
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
89 switch (widget) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
90 case 4:
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10000
diff changeset
91 DoCommandP(0, this->window_number, 0, CMD_WANT_ENGINE_PREVIEW);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
92 /* Fallthrough */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
93 case 3:
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
94 delete this;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
95 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
96 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
97 }
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
98 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
99
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11355
diff changeset
100 static const WindowDesc _engine_preview_desc(
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
101 WDP_CENTER, WDP_CENTER, 300, 192, 300, 192,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5868
diff changeset
102 WC_ENGINE_PREVIEW, WC_NONE,
10998
a1d256bf72e0 (svn r15338) -Fix [FS#2598]: close all construction related windows whenever changing company.
rubidium <rubidium@openttd.org>
parents: 10967
diff changeset
103 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_CONSTRUCTION,
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11355
diff changeset
104 _engine_preview_widgets
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11355
diff changeset
105 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
106
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
107
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
108 void ShowEnginePreviewWindow(EngineID engine)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
109 {
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
110 AllocateWindowDescFront<EnginePreviewWindow>(&_engine_preview_desc, engine);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
111 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
112
11316
8554b6a7475a (svn r15666) -Fix [FS#2689]: sorting of engines in the purchase list didn't use the same numbers as the GUI showed, e.g. articulated parts weren't taken into accound when ordering by capacity.
rubidium <rubidium@openttd.org>
parents: 11188
diff changeset
113 uint GetTotalCapacityOfArticulatedParts(EngineID engine, VehicleType type)
9567
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
114 {
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
115 uint total = 0;
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
116
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
117 uint16 *cap = GetCapacityOfArticulatedParts(engine, type);
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
118 for (uint c = 0; c < NUM_CARGO; c++) {
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
119 total += cap[c];
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
120 }
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
121
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
122 return total;
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
123 }
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
124
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
125 static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
126 {
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
127 const Engine *e = GetEngine(engine);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
128
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
129 SetDParam(0, e->GetCost());
10967
57269a8c0b6d (svn r15306) -Codechange: Deduplicate code by adding Engine::GetDisplayMaxSpeed(), GetPower() and GetDisplayWeight(). (and using them)
frosch <frosch@openttd.org>
parents: 10960
diff changeset
130 SetDParam(2, e->GetDisplayMaxSpeed());
57269a8c0b6d (svn r15306) -Codechange: Deduplicate code by adding Engine::GetDisplayMaxSpeed(), GetPower() and GetDisplayWeight(). (and using them)
frosch <frosch@openttd.org>
parents: 10960
diff changeset
131 SetDParam(3, e->GetPower());
57269a8c0b6d (svn r15306) -Codechange: Deduplicate code by adding Engine::GetDisplayMaxSpeed(), GetPower() and GetDisplayWeight(). (and using them)
frosch <frosch@openttd.org>
parents: 10960
diff changeset
132 SetDParam(1, e->GetDisplayWeight());
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
133
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
134 SetDParam(4, e->GetRunningCost());
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
135
9567
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
136 uint capacity = GetTotalCapacityOfArticulatedParts(engine, VEH_TRAIN);
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
137 if (capacity != 0) {
11188
9e451d497d94 (svn r15541) -Revert (r15399): 'v->cargo_type' is also used in other places, which cannot accept CT_INVALID.
frosch <frosch@openttd.org>
parents: 11085
diff changeset
138 SetDParam(5, e->GetDefaultCargoType());
9720
7aa78e4bca3d (svn r13844) -Fix (r13074, r13591): Power, running cost and capacity of multiheaded engines were (too often) doubled in newspaper resp. offer window.
frosch <frosch@openttd.org>
parents: 9607
diff changeset
139 SetDParam(6, capacity);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
140 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
141 SetDParam(5, CT_INVALID);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
142 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
143 DrawStringMultiCenter(x, y, STR_VEHICLE_INFO_COST_WEIGHT_SPEED_POWER, maxw);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
144 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
145
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
146 static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
147 {
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
148 const Engine *e = GetEngine(engine);
11355
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
149 CargoID cargo = e->GetDefaultCargoType();
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
150
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
151 if (cargo == CT_INVALID || cargo == CT_PASSENGERS) {
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
152 SetDParam(0, e->GetCost());
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
153 SetDParam(1, e->GetDisplayMaxSpeed());
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
154 SetDParam(2, e->u.air.passenger_capacity);
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
155 SetDParam(3, e->u.air.mail_capacity);
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
156 SetDParam(4, e->GetRunningCost());
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
157
11355
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
158 DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw);
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
159 } else {
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
160 SetDParam(0, e->GetCost());
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
161 SetDParam(1, e->GetDisplayMaxSpeed());
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
162 SetDParam(2, cargo);
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
163 SetDParam(3, AircraftDefaultCargoCapacity(cargo, &e->u.air));
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
164 SetDParam(4, e->GetRunningCost());
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
165
11355
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
166 DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
167 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
168 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
169
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
170 static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
171 {
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
172 const Engine *e = GetEngine(engine);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
173
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
174 SetDParam(0, e->GetCost());
10967
57269a8c0b6d (svn r15306) -Codechange: Deduplicate code by adding Engine::GetDisplayMaxSpeed(), GetPower() and GetDisplayWeight(). (and using them)
frosch <frosch@openttd.org>
parents: 10960
diff changeset
175 SetDParam(1, e->GetDisplayMaxSpeed());
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
176 SetDParam(2, e->GetRunningCost());
11188
9e451d497d94 (svn r15541) -Revert (r15399): 'v->cargo_type' is also used in other places, which cannot accept CT_INVALID.
frosch <frosch@openttd.org>
parents: 11085
diff changeset
177 uint capacity = GetTotalCapacityOfArticulatedParts(engine, VEH_ROAD);
9e451d497d94 (svn r15541) -Revert (r15399): 'v->cargo_type' is also used in other places, which cannot accept CT_INVALID.
frosch <frosch@openttd.org>
parents: 11085
diff changeset
178 if (capacity != 0) {
9e451d497d94 (svn r15541) -Revert (r15399): 'v->cargo_type' is also used in other places, which cannot accept CT_INVALID.
frosch <frosch@openttd.org>
parents: 11085
diff changeset
179 SetDParam(3, e->GetDefaultCargoType());
9e451d497d94 (svn r15541) -Revert (r15399): 'v->cargo_type' is also used in other places, which cannot accept CT_INVALID.
frosch <frosch@openttd.org>
parents: 11085
diff changeset
180 SetDParam(4, capacity);
9e451d497d94 (svn r15541) -Revert (r15399): 'v->cargo_type' is also used in other places, which cannot accept CT_INVALID.
frosch <frosch@openttd.org>
parents: 11085
diff changeset
181 } else {
9e451d497d94 (svn r15541) -Revert (r15399): 'v->cargo_type' is also used in other places, which cannot accept CT_INVALID.
frosch <frosch@openttd.org>
parents: 11085
diff changeset
182 SetDParam(3, CT_INVALID);
9e451d497d94 (svn r15541) -Revert (r15399): 'v->cargo_type' is also used in other places, which cannot accept CT_INVALID.
frosch <frosch@openttd.org>
parents: 11085
diff changeset
183 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
184
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
185 DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
186 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
187
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
188 static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
189 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
190 const ShipVehicleInfo *svi = ShipVehInfo(engine);
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
191 const Engine *e = GetEngine(engine);
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
192
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
193 SetDParam(0, e->GetCost());
10967
57269a8c0b6d (svn r15306) -Codechange: Deduplicate code by adding Engine::GetDisplayMaxSpeed(), GetPower() and GetDisplayWeight(). (and using them)
frosch <frosch@openttd.org>
parents: 10960
diff changeset
194 SetDParam(1, e->GetDisplayMaxSpeed());
11188
9e451d497d94 (svn r15541) -Revert (r15399): 'v->cargo_type' is also used in other places, which cannot accept CT_INVALID.
frosch <frosch@openttd.org>
parents: 11085
diff changeset
195 SetDParam(2, e->GetDefaultCargoType());
9567
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
196 SetDParam(3, GetEngineProperty(engine, 0x0D, svi->capacity));
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
197 SetDParam(4, e->GetRunningCost());
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
198 DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
199 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
200
8763
d6e363672edb (svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium <rubidium@openttd.org>
parents: 8626
diff changeset
201 void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni)
6209
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
202 {
9199
dbe675dc54c4 (svn r13065) -Codechange: remove the need for the news string callbacks. Patch by Cirdan.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
203 EngineID engine = ni->data_a;
6209
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
204 const DrawEngineInfo *dei = &_draw_engine_list[GetEngine(engine)->type];
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
205
6209
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
206 SetDParam(0, GetEngineCategoryName(engine));
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
207 DrawStringMultiCenter(w->width >> 1, 20, STR_NEW_VEHICLE_NOW_AVAILABLE, w->width - 2);
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
208
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
209 GfxFillRect(25, 56, w->width - 25, w->height - 2, 10);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
210
7059
88ca8902530e (svn r10324) -Codechange: reference engine names by index
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
211 SetDParam(0, engine);
6209
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
212 DrawStringMultiCenter(w->width >> 1, 57, STR_NEW_VEHICLE_TYPE, w->width - 2);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
213
6209
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
214 dei->engine_proc(w->width >> 1, 88, engine, 0);
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 10998
diff changeset
215 GfxFillRect(25, 56, w->width - 56, 112, PALETTE_TO_STRUCT_GREY, FILLRECT_RECOLOUR);
6209
369df6586d87 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium <rubidium@openttd.org>
parents: 6208
diff changeset
216 dei->info_proc(engine, w->width >> 1, 129, w->width - 52);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
217 }
9380
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
218
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
219
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
220 /** Sort all items using qsort() and given 'CompareItems' function
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
221 * @param el list to be sorted
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
222 * @param compare function for evaluation of the quicksort
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
223 */
9403
a6c2188b725a (svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents: 9380
diff changeset
224 void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
9380
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
225 {
9403
a6c2188b725a (svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents: 9380
diff changeset
226 uint size = el->Length();
9380
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
227 /* out-of-bounds access at the next line for size == 0 (even with operator[] at some systems)
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
228 * generally, do not sort if there are less than 2 items */
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
229 if (size < 2) return;
9403
a6c2188b725a (svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents: 9380
diff changeset
230 qsort(el->Begin(), size, sizeof(*el->Begin()), compare); // MorphOS doesn't know vector::at(int) ...
9380
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
231 }
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
232
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
233 /** Sort selected range of items (on indices @ <begin, begin+num_items-1>)
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
234 * @param el list to be sorted
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
235 * @param compare function for evaluation of the quicksort
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
236 * @param begin start of sorting
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
237 * @param num_items count of items to be sorted
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
238 */
9403
a6c2188b725a (svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents: 9380
diff changeset
239 void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items)
9380
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
240 {
9404
9fab42eb6fbb (svn r13315) -Fix (r13314): Assert if no engines or wagons available
peter1138 <peter1138@openttd.org>
parents: 9403
diff changeset
241 if (num_items < 2) return;
9403
a6c2188b725a (svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents: 9380
diff changeset
242 assert(begin < el->Length());
a6c2188b725a (svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents: 9380
diff changeset
243 assert(begin + num_items <= el->Length());
a6c2188b725a (svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents: 9380
diff changeset
244 qsort(el->Get(begin), num_items, sizeof(*el->Begin()), compare);
9380
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
245 }
90ab27a08510 (svn r13287) -Codechange: move engine list gui code away from engine.cpp (and its headers) to engine_gui.cpp
peter1138 <peter1138@openttd.org>
parents: 9333
diff changeset
246