annotate src/engine_gui.cpp @ 11635:858d735ef724 draft

(svn r16015) -Codechange: Completing the TransparencyToolbarWidgets enum.
author alberth <alberth@openttd.org>
date Fri, 10 Apr 2009 16:20:54 +0000
parents 4c9694da030f
children ebe050cf807b
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"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
17
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
18 #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
19 #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
20
9199
dbe675dc54c4 (svn r13065) -Codechange: remove the need for the news string callbacks. Patch by Cirdan.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
21 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
22 {
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
23 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
24 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
25 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
26 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
27 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
28 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
29 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
30 }
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
11428
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
33 /** Widgets used for the engine preview window */
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
34 enum EnginePreviewWidgets {
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
35 EPW_CLOSE, ///< Close button
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
36 EPW_CAPTION, ///< Title bar/caption
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
37 EPW_BACKGROUND, ///< Background
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
38 EPW_NO, ///< No button
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
39 EPW_YES, ///< Yes button
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
40 };
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
41
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
42 static const Widget _engine_preview_widgets[] = {
11428
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
43 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_LIGHT_BLUE, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // EPW_CLOSE
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
44 { WWT_CAPTION, RESIZE_NONE, COLOUR_LIGHT_BLUE, 11, 299, 0, 13, STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE, STR_018C_WINDOW_TITLE_DRAG_THIS}, // EPW_CAPTION
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
45 { WWT_PANEL, RESIZE_NONE, COLOUR_LIGHT_BLUE, 0, 299, 14, 191, 0x0, STR_NULL}, // EPW_BACKGROUND
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
46 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_LIGHT_BLUE, 85, 144, 172, 183, STR_00C9_NO, STR_NULL}, // EPW_NO
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
47 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_LIGHT_BLUE, 155, 214, 172, 183, STR_00C8_YES, STR_NULL}, // EPW_YES
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
48 { 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
49 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
50
11517
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
51 static const NWidgetPart _nested_engine_preview_widgets[] = {
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
52 NWidget(NWID_HORIZONTAL),
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
53 NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE, EPW_CLOSE),
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
54 NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE, EPW_CAPTION), SetDataTip(STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE, STR_018C_WINDOW_TITLE_DRAG_THIS),
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
55 EndContainer(),
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
56 NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, EPW_BACKGROUND),
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
57 NWidget(NWID_SPACER), SetMinimalSize(0, 158),
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
58 NWidget(NWID_HORIZONTAL), SetPIP(85, 10, 85),
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
59 NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, EPW_NO), SetMinimalSize(60, 12), SetDataTip(STR_00C9_NO, STR_NULL),
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
60 NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, EPW_YES), SetMinimalSize(60, 12), SetDataTip(STR_00C8_YES, STR_NULL),
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
61 EndContainer(),
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
62 NWidget(NWID_SPACER), SetMinimalSize(0, 8),
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
63 EndContainer(),
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
64 };
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
65
5668
3d6d9bff3dd8 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents: 5587
diff changeset
66 typedef void DrawEngineProc(int x, int y, EngineID engine, SpriteID pal);
11442
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
67 typedef void DrawEngineInfoProc(EngineID, int left, int right, int top, int bottom);
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
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6209
diff changeset
69 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
70 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
71 DrawEngineInfoProc *info_proc;
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6209
diff changeset
72 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
73
11442
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
74 static void DrawTrainEngineInfo(EngineID engine, int left, int right, int top, int bottom);
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
75 static void DrawRoadVehEngineInfo(EngineID engine, int left, int right, int top, int bottom);
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
76 static void DrawShipEngineInfo(EngineID engine, int left, int right, int top, int bottom);
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
77 static void DrawAircraftEngineInfo(EngineID engine, int left, int right, int top, int bottom);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
78
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
79 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
80 { 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
81 { 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
82 { 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
83 { 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
84 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
85
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
86 struct EnginePreviewWindow : Window {
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
87 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
88 {
9333
5236ba6c7d54 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138 <peter1138@openttd.org>
parents: 9317
diff changeset
89 this->FindWindowPlacementAndResize(desc);
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
90 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
91
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
92 virtual void OnPaint()
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
93 {
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
94 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
95
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
96 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
97 SetDParam(0, GetEngineCategoryName(engine));
11445
231379be7cf9 (svn r15803) -Codechange: use the new text drawing API for multicenter
rubidium <rubidium@openttd.org>
parents: 11442
diff changeset
98 DrawStringMultiLine(this->widget[EPW_BACKGROUND].left + 2, this->widget[EPW_BACKGROUND].right - 2, 18, 80, STR_8101_WE_HAVE_JUST_DESIGNED_A, SA_CENTER);
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
7059
88ca8902530e (svn r10324) -Codechange: reference engine names by index
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
100 SetDParam(0, engine);
11432
a20dd0000d96 (svn r15790) -Codechange: remove the *Centered part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11428
diff changeset
101 DrawString(this->widget[EPW_BACKGROUND].left + 2, this->widget[EPW_BACKGROUND].right - 2, 80, STR_ENGINE_NAME, TC_BLACK, SA_CENTER);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
102
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
103 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
104
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
105 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
106 dei->engine_proc(width >> 1, 100, engine, 0);
11445
231379be7cf9 (svn r15803) -Codechange: use the new text drawing API for multicenter
rubidium <rubidium@openttd.org>
parents: 11442
diff changeset
107 dei->info_proc(engine, this->widget[EPW_BACKGROUND].left + 26, this->widget[EPW_BACKGROUND].right - 26, 100, 170);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
108 }
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 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
111 {
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
112 switch (widget) {
11428
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
113 case EPW_YES:
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
114 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
115 /* Fallthrough */
11428
59d9d4ed4c23 (svn r15786) -Codechange: enumify the engine preview widgets (and use them)
rubidium <rubidium@openttd.org>
parents: 11408
diff changeset
116 case EPW_NO:
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
117 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
118 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
119 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
120 }
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
121 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
122
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
123 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
124 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
125 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
126 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_CONSTRUCTION,
11517
4c9694da030f (svn r15878) -Codechange: New widgets for the engine preview window.
alberth <alberth@openttd.org>
parents: 11445
diff changeset
127 _engine_preview_widgets, _nested_engine_preview_widgets, lengthof(_nested_engine_preview_widgets)
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
128 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
129
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
130
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
131 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
132 {
9302
fd3d8a77319f (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
133 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
134 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
135
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
136 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
137 {
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
138 uint total = 0;
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
139
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
140 uint16 *cap = GetCapacityOfArticulatedParts(engine, type);
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
141 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
142 total += cap[c];
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
143 }
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
144
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
145 return total;
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
146 }
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
147
11442
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
148 static void DrawTrainEngineInfo(EngineID engine, int left, int right, int top, int bottom)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
149 {
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
150 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
151
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
152 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
153 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
154 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
155 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
156
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
157 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
158
9567
32adb135dc8d (svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents: 9404
diff changeset
159 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
160 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
161 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
162 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
163 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
164 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
165 }
11442
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
166 DrawStringMultiLine(left, right, top, bottom, STR_VEHICLE_INFO_COST_WEIGHT_SPEED_POWER, SA_CENTER);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
167 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
168
11442
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
169 static void DrawAircraftEngineInfo(EngineID engine, int left, int right, int top, int bottom)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
170 {
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
171 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
172 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
173
15471cd58e0a (svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
frosch <frosch@openttd.org>
parents: 11316
diff changeset
174 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
175 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
176 SetDParam(1, e->GetDisplayMaxSpeed());
11408
17fa6dfa4cb1 (svn r15763) -Codechange/Fix: Add Engine::GetDisplayDefaultCapacity() and use it everywhere, so CB 36 is also used everywhere.
frosch <frosch@openttd.org>
parents: 11373
diff changeset
177 SetDParam(2, e->GetDisplayDefaultCapacity());
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
178 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
179 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
180
11442
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
181 DrawStringMultiLine(left, right, top, bottom, STR_A02E_COST_MAX_SPEED_CAPACITY, SA_CENTER);
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
182 } 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
183 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
184 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
185 SetDParam(2, cargo);
11408
17fa6dfa4cb1 (svn r15763) -Codechange/Fix: Add Engine::GetDisplayDefaultCapacity() and use it everywhere, so CB 36 is also used everywhere.
frosch <frosch@openttd.org>
parents: 11373
diff changeset
186 SetDParam(3, e->GetDisplayDefaultCapacity());
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
187 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
188
11442
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
189 DrawStringMultiLine(left, right, top, bottom, STR_982E_COST_MAX_SPEED_CAPACITY, SA_CENTER);
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
190 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
191 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
192
11442
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
193 static void DrawRoadVehEngineInfo(EngineID engine, int left, int right, int top, int bottom)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
194 {
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
195 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
196
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
197 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
198 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
199 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
200 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
201 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
202 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
203 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
204 } 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
205 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
206 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
207
11442
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
208 DrawStringMultiLine(left, right, top, bottom, STR_902A_COST_SPEED_RUNNING_COST, SA_CENTER);
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
210
11442
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
211 static void DrawShipEngineInfo(EngineID engine, int left, int right, int top, int bottom)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
212 {
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
213 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
214
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
215 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
216 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
217 SetDParam(2, e->GetDefaultCargoType());
11408
17fa6dfa4cb1 (svn r15763) -Codechange/Fix: Add Engine::GetDisplayDefaultCapacity() and use it everywhere, so CB 36 is also used everywhere.
frosch <frosch@openttd.org>
parents: 11373
diff changeset
218 SetDParam(3, e->GetDisplayDefaultCapacity());
10927
68230070e59b (svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
glx <glx@openttd.org>
parents: 10925
diff changeset
219 SetDParam(4, e->GetRunningCost());
11442
deb79aa0dbf2 (svn r15800) -Codechange: make the engine gui use the new multiline API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
220 DrawStringMultiLine(left, right, top, bottom, STR_982E_COST_MAX_SPEED_CAPACITY, SA_CENTER);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
221 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
222
8763
d6e363672edb (svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium <rubidium@openttd.org>
parents: 8626
diff changeset
223 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
224 {
9199
dbe675dc54c4 (svn r13065) -Codechange: remove the need for the news string callbacks. Patch by Cirdan.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
225 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
226 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
227
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
228 SetDParam(0, GetEngineCategoryName(engine));
11445
231379be7cf9 (svn r15803) -Codechange: use the new text drawing API for multicenter
rubidium <rubidium@openttd.org>
parents: 11442
diff changeset
229 DrawStringMultiLine(1, w->width - 2, 0, 56, STR_NEW_VEHICLE_NOW_AVAILABLE, SA_CENTER);
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
230
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
231 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
232
7059
88ca8902530e (svn r10324) -Codechange: reference engine names by index
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
233 SetDParam(0, engine);
11445
231379be7cf9 (svn r15803) -Codechange: use the new text drawing API for multicenter
rubidium <rubidium@openttd.org>
parents: 11442
diff changeset
234 DrawStringMultiLine(1, w->width - 2, 56, 88, STR_NEW_VEHICLE_TYPE, SA_CENTER);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
235
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
236 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
237 GfxFillRect(25, 56, w->width - 56, 112, PALETTE_TO_STRUCT_GREY, FILLRECT_RECOLOUR);
11445
231379be7cf9 (svn r15803) -Codechange: use the new text drawing API for multicenter
rubidium <rubidium@openttd.org>
parents: 11442
diff changeset
238 dei->info_proc(engine, 26, w->width - 26, 100, 170);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
239 }
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
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
241
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
242 /** 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
243 * @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
244 * @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
245 */
9403
a6c2188b725a (svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents: 9380
diff changeset
246 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
247 {
9403
a6c2188b725a (svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents: 9380
diff changeset
248 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
249 /* 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
250 * 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
251 if (size < 2) return;
9403
a6c2188b725a (svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents: 9380
diff changeset
252 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
253 }
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
254
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
255 /** 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
256 * @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
257 * @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
258 * @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
259 * @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
260 */
9403
a6c2188b725a (svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents: 9380
diff changeset
261 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
262 {
9404
9fab42eb6fbb (svn r13315) -Fix (r13314): Assert if no engines or wagons available
peter1138 <peter1138@openttd.org>
parents: 9403
diff changeset
263 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
264 assert(begin < el->Length());
a6c2188b725a (svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents: 9380
diff changeset
265 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
266 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
267 }
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
268