Mercurial > hg > openttd
annotate src/engine_gui.cpp @ 9567:32adb135dc8d draft
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Fri, 20 Jun 2008 07:23:00 +0000 |
parents | 9fab42eb6fbb |
children | 3d6213e95b9a |
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" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
6 #include "openttd.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
7 #include "gui.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
|
8 #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
|
9 #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
|
10 #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
|
11 #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
|
12 #include "command_func.h" |
9cc845deddfe
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents:
8114
diff
changeset
|
13 #include "economy_func.h" |
8763
d6e363672edb
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium <rubidium@openttd.org>
parents:
8626
diff
changeset
|
14 #include "news_func.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
|
15 #include "variables.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
16 #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
|
17 #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
|
18 #include "engine_gui.h" |
9567
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
19 #include "articulated_vehicles.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 |
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
|
21 #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
|
22 #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
|
23 |
9199
dbe675dc54c4
(svn r13065) -Codechange: remove the need for the news string callbacks. Patch by Cirdan.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
24 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
|
25 { |
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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 case VEH_TRAIN: |
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
|
32 switch (RailVehInfo(engine)->railtype) { |
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
|
33 default: NOT_REACHED(); |
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
|
34 case RAILTYPE_RAIL: return STR_8102_RAILROAD_LOCOMOTIVE; |
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
|
35 case RAILTYPE_ELECTRIC: return STR_8102_RAILROAD_LOCOMOTIVE; |
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
|
36 case RAILTYPE_MONO: return STR_8106_MONORAIL_LOCOMOTIVE; |
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
|
37 case RAILTYPE_MAGLEV: return STR_8107_MAGLEV_LOCOMOTIVE; |
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
|
38 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
39 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
40 } |
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 static const Widget _engine_preview_widgets[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
43 { WWT_CLOSEBOX, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
44 { WWT_CAPTION, RESIZE_NONE, 5, 11, 299, 0, 13, STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
45 { WWT_PANEL, RESIZE_NONE, 5, 0, 299, 14, 191, 0x0, STR_NULL}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
46 { WWT_PUSHTXTBTN, RESIZE_NONE, 5, 85, 144, 172, 183, STR_00C9_NO, STR_NULL}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
47 { WWT_PUSHTXTBTN, RESIZE_NONE, 5, 155, 214, 172, 183, STR_00C8_YES, STR_NULL}, |
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 |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
51 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
|
52 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
|
53 |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6209
diff
changeset
|
54 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
|
55 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
|
56 DrawEngineInfoProc *info_proc; |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6209
diff
changeset
|
57 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
58 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 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
|
63 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
64 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
|
65 { 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
|
66 { 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
|
67 { 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
|
68 { 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
|
69 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
70 |
9302
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
71 struct EnginePreviewWindow : Window { |
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
72 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
|
73 { |
9333
5236ba6c7d54
(svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138 <peter1138@openttd.org>
parents:
9317
diff
changeset
|
74 this->FindWindowPlacementAndResize(desc); |
9302
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
75 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
76 |
9302
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
77 virtual void OnPaint() |
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
78 { |
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
79 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
|
80 |
9302
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
81 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
|
82 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
|
83 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
|
84 |
7059
88ca8902530e
(svn r10324) -Codechange: reference engine names by index
peter1138 <peter1138@openttd.org>
parents:
7002
diff
changeset
|
85 SetDParam(0, engine); |
9302
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
86 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
|
87 |
9302
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
88 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
|
89 |
9302
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
90 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
|
91 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
|
92 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
|
93 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
94 |
9302
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
95 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
|
96 { |
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
97 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
|
98 case 4: |
9302
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
99 DoCommandP(0, this->window_number, 0, NULL, 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
|
100 /* Fallthrough */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
101 case 3: |
9302
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
102 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
|
103 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
104 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
105 } |
9302
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
106 }; |
5584
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 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
|
109 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
|
110 WC_ENGINE_PREVIEW, WC_NONE, |
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 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
112 _engine_preview_widgets, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
113 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
114 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
115 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
116 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
|
117 { |
9302
fd3d8a77319f
(svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
118 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
|
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 |
9567
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
121 static uint GetTotalCapacityOfArticulatedParts(EngineID engine, VehicleType type) |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
122 { |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
123 uint total = 0; |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
124 |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
125 uint16 *cap = GetCapacityOfArticulatedParts(engine, type); |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
126 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
|
127 total += cap[c]; |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
128 } |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
129 |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
130 return total; |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
131 } |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
132 |
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 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
|
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 const RailVehicleInfo *rvi = RailVehInfo(engine); |
7763
b66a3cb83e69
(svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
rubidium <rubidium@openttd.org>
parents:
7341
diff
changeset
|
136 int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD) ? 1 : 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
137 |
9567
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
138 SetDParam(0, (_price.build_railvehicle >> 3) * GetEngineProperty(engine, 0x17, rvi->base_cost) >> 5); |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
139 SetDParam(2, GetEngineProperty(engine, 0x09, rvi->max_speed) * 10 / 16); |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
140 SetDParam(3, GetEngineProperty(engine, 0x0B, rvi->power) << multihead); |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
141 SetDParam(1, GetEngineProperty(engine, 0x16, rvi->weight) << multihead); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
142 |
9567
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
143 SetDParam(4, GetEngineProperty(engine, 0x0D, rvi->running_cost) * GetPriceByIndex(rvi->running_cost_class) >> 8 << multihead); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
144 |
9567
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
145 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
|
146 if (capacity != 0) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
147 SetDParam(5, rvi->cargo_type); |
9567
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
148 SetDParam(6, capacity << multihead); |
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 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
150 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
|
151 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
152 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
|
153 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
154 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
155 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
|
156 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
157 const AircraftVehicleInfo *avi = AircraftVehInfo(engine); |
9567
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
158 SetDParam(0, (_price.aircraft_base >> 3) * GetEngineProperty(engine, 0x0B, avi->base_cost) >> 5); |
6321
8ccc64e2d6cf
(svn r9275) -Fix(r8973, FS#686): Faulty display of aircraft maximum velocity in the news item for new vehicles
celestar <celestar@openttd.org>
parents:
6259
diff
changeset
|
159 SetDParam(1, avi->max_speed * 10 / 16); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
160 SetDParam(2, avi->passenger_capacity); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
161 SetDParam(3, avi->mail_capacity); |
9567
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
162 SetDParam(4, GetEngineProperty(engine, 0x0E, avi->running_cost) * _price.aircraft_running >> 8); |
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
164 DrawStringMultiCenter(x, y, STR_A02E_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
|
165 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
166 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
167 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
|
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 const RoadVehicleInfo *rvi = RoadVehInfo(engine); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
170 |
9567
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
171 SetDParam(0, (_price.roadveh_base >> 3) * GetEngineProperty(engine, 0x11, rvi->base_cost) >> 5); |
5931
0ef2d8635ce9
(svn r8569) -Fix (r8464): revert properly
peter1138 <peter1138@openttd.org>
parents:
5893
diff
changeset
|
172 SetDParam(1, rvi->max_speed * 10 / 32); |
8626
e6ad3a9cdfcb
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138 <peter1138@openttd.org>
parents:
8622
diff
changeset
|
173 SetDParam(2, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) >> 8); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
174 SetDParam(3, rvi->cargo_type); |
9567
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
175 SetDParam(4, GetTotalCapacityOfArticulatedParts(engine, VEH_ROAD)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
176 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
177 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
|
178 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
179 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
180 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
|
181 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
182 const ShipVehicleInfo *svi = ShipVehInfo(engine); |
9567
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
183 SetDParam(0, GetEngineProperty(engine, 0x0A, svi->base_cost) * (_price.ship_base >> 3) >> 5); |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
184 SetDParam(1, GetEngineProperty(engine, 0x0B, svi->max_speed) * 10 / 32); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
185 SetDParam(2, svi->cargo_type); |
9567
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
186 SetDParam(3, GetEngineProperty(engine, 0x0D, svi->capacity)); |
32adb135dc8d
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
peter1138 <peter1138@openttd.org>
parents:
9404
diff
changeset
|
187 SetDParam(4, GetEngineProperty(engine, 0x0F, svi->running_cost) * _price.ship_running >> 8); |
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 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
|
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 |
8763
d6e363672edb
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium <rubidium@openttd.org>
parents:
8626
diff
changeset
|
191 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
|
192 { |
9199
dbe675dc54c4
(svn r13065) -Codechange: remove the need for the news string callbacks. Patch by Cirdan.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
193 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
|
194 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
|
195 |
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
|
196 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
|
197 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
|
198 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
199 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
|
200 |
7059
88ca8902530e
(svn r10324) -Codechange: reference engine names by index
peter1138 <peter1138@openttd.org>
parents:
7002
diff
changeset
|
201 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
|
202 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
|
203 |
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 dei->engine_proc(w->width >> 1, 88, engine, 0); |
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
|
205 GfxFillRect(25, 56, w->width - 56, 112, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE)); |
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 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
|
207 } |
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
|
208 |
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
|
209 |
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
|
210 /** 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
|
211 * @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
|
212 * @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
|
213 */ |
9403
a6c2188b725a
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents:
9380
diff
changeset
|
214 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
|
215 { |
9403
a6c2188b725a
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents:
9380
diff
changeset
|
216 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
|
217 /* 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
|
218 * 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
|
219 if (size < 2) return; |
9403
a6c2188b725a
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents:
9380
diff
changeset
|
220 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
|
221 } |
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 |
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 /** 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
|
224 * @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
|
225 * @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
|
226 * @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
|
227 * @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
|
228 */ |
9403
a6c2188b725a
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents:
9380
diff
changeset
|
229 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
|
230 { |
9404
9fab42eb6fbb
(svn r13315) -Fix (r13314): Assert if no engines or wagons available
peter1138 <peter1138@openttd.org>
parents:
9403
diff
changeset
|
231 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
|
232 assert(begin < el->Length()); |
a6c2188b725a
(svn r13314) -Codechange: Switch EngineList from std::vector to GUIList
peter1138 <peter1138@openttd.org>
parents:
9380
diff
changeset
|
233 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
|
234 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
|
235 } |
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 |