Mercurial > hg > openttd
annotate src/graph_gui.cpp @ 18650:7e084b7495c6 draft
(svn r23497) -Add: Advanced display setting to control the linewidth in graphs. (ChillCore)
author | frosch <frosch@openttd.org> |
---|---|
date | Sun, 11 Dec 2011 15:55:31 +0000 (2011-12-11) |
parents | 980c099600c8 |
children | 5604c42fa1ce |
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 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12671
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12671
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12671
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12671
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12671
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12671
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12671
diff
changeset
|
9 |
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:
8409
diff
changeset
|
10 /** @file graph_gui.cpp GUI that shows performance graphs. */ |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6091
diff
changeset
|
11 |
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 "stdafx.h" |
14505
69522d847103
(svn r19076) -Codechange: Move graph functions to their own header.
terkhen <terkhen@openttd.org>
parents:
14409
diff
changeset
|
13 #include "graph_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
|
14 #include "window_gui.h" |
10208
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
15 #include "company_base.h" |
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
16 #include "company_gui.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
|
17 #include "economy_func.h" |
6091
17ebeb5a2c37
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138 <peter1138@openttd.org>
parents:
5946
diff
changeset
|
18 #include "cargotype.h" |
8114
2d6af5d7a142
(svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
8107
diff
changeset
|
19 #include "strings_func.h" |
8131
e300ac8001ae
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents:
8130
diff
changeset
|
20 #include "window_func.h" |
8140
fb8a05d579da
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents:
8131
diff
changeset
|
21 #include "date_func.h" |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8179
diff
changeset
|
22 #include "gfx_func.h" |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
23 #include "sortlist_type.h" |
14258
a899d4e5ee1a
(svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
rubidium <rubidium@openttd.org>
parents:
14214
diff
changeset
|
24 #include "core/geometry_func.hpp" |
15103
bd4b62132aed
(svn r19729) -Fix [FS#3793]: The company value graph crashed the game when displaying companies with a huge amount of money.
terkhen <terkhen@openttd.org>
parents:
15053
diff
changeset
|
25 #include "math.h" |
16302
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
26 #include "currency.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
|
27 |
8264
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
28 #include "table/strings.h" |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
29 #include "table/sprites.h" |
8264
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
30 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
31 /* Bitmasks of company and cargo indices that shouldn't be drawn. */ |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
32 static uint _legend_excluded_companies; |
5806
4f5e2ea123e8
(svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros <maedhros@openttd.org>
parents:
5805
diff
changeset
|
33 static uint _legend_excluded_cargo; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
34 |
5805
b7c3a94ff74e
(svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros <maedhros@openttd.org>
parents:
5804
diff
changeset
|
35 /* Apparently these don't play well with enums. */ |
8409
7c5e4180e2b1
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
rubidium <rubidium@openttd.org>
parents:
8264
diff
changeset
|
36 static const OverflowSafeInt64 INVALID_DATAPOINT(INT64_MAX); // Value used for a datapoint that shouldn't be drawn. |
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:
7520
diff
changeset
|
37 static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the previous point was drawn. |
5805
b7c3a94ff74e
(svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros <maedhros@openttd.org>
parents:
5804
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 /* GRAPH LEGEND */ |
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 |
11623
7f91f3d79f90
(svn r16003) -Codechange: Replaced magic widget number constant with enumerated value in graph legend window.
alberth <alberth@openttd.org>
parents:
11622
diff
changeset
|
43 /** Widget numbers of the graph legend window. */ |
7f91f3d79f90
(svn r16003) -Codechange: Replaced magic widget number constant with enumerated value in graph legend window.
alberth <alberth@openttd.org>
parents:
11622
diff
changeset
|
44 enum GraphLegendWidgetNumbers { |
7f91f3d79f90
(svn r16003) -Codechange: Replaced magic widget number constant with enumerated value in graph legend window.
alberth <alberth@openttd.org>
parents:
11622
diff
changeset
|
45 GLW_BACKGROUND, |
7f91f3d79f90
(svn r16003) -Codechange: Replaced magic widget number constant with enumerated value in graph legend window.
alberth <alberth@openttd.org>
parents:
11622
diff
changeset
|
46 |
7f91f3d79f90
(svn r16003) -Codechange: Replaced magic widget number constant with enumerated value in graph legend window.
alberth <alberth@openttd.org>
parents:
11622
diff
changeset
|
47 GLW_FIRST_COMPANY, |
11749
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
48 GLW_LAST_COMPANY = GLW_FIRST_COMPANY + MAX_COMPANIES - 1, |
11623
7f91f3d79f90
(svn r16003) -Codechange: Replaced magic widget number constant with enumerated value in graph legend window.
alberth <alberth@openttd.org>
parents:
11622
diff
changeset
|
49 }; |
7f91f3d79f90
(svn r16003) -Codechange: Replaced magic widget number constant with enumerated value in graph legend window.
alberth <alberth@openttd.org>
parents:
11622
diff
changeset
|
50 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
51 struct GraphLegendWindow : Window { |
12608
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
52 GraphLegendWindow(const WindowDesc *desc, WindowNumber window_number) : Window() |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
53 { |
12608
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
54 this->InitNested(desc, window_number); |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
55 |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
56 for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
57 if (!HasBit(_legend_excluded_companies, c)) this->LowerWidget(c + GLW_FIRST_COMPANY); |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
58 |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
59 this->OnInvalidateData(c); |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
60 } |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
61 } |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
62 |
12608
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
63 virtual void DrawWidget(const Rect &r, int widget) const |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
64 { |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
65 if (!IsInsideMM(widget, GLW_FIRST_COMPANY, MAX_COMPANIES + GLW_FIRST_COMPANY)) return; |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
66 |
12608
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
67 CompanyID cid = (CompanyID)(widget - GLW_FIRST_COMPANY); |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
68 |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
69 if (!Company::IsValidID(cid)) return; |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
70 |
16441
86fd9bcc9d2f
(svn r21157) -Codechange: remove information about the text direction out of the language "list"
rubidium <rubidium@openttd.org>
parents:
16302
diff
changeset
|
71 bool rtl = _current_text_dir == TD_RTL; |
13643
a790e57124b2
(svn r18167) -Change: make the graph legend, cargo payment graph and company league windows RTL aware
rubidium <rubidium@openttd.org>
parents:
13636
diff
changeset
|
72 |
18196
276c30308311
(svn r23025) -Codechange: Support resized company colour icon in company key window.
peter1138 <peter1138@openttd.org>
parents:
18053
diff
changeset
|
73 Dimension d = GetSpriteSize(SPR_COMPANY_ICON); |
276c30308311
(svn r23025) -Codechange: Support resized company colour icon in company key window.
peter1138 <peter1138@openttd.org>
parents:
18053
diff
changeset
|
74 DrawCompanyIcon(cid, rtl ? r.right - d.width - 2 : r.left + 2, r.top + (r.bottom - r.top - d.height) / 2); |
12608
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
75 |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
76 SetDParam(0, cid); |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
77 SetDParam(1, cid); |
18196
276c30308311
(svn r23025) -Codechange: Support resized company colour icon in company key window.
peter1138 <peter1138@openttd.org>
parents:
18053
diff
changeset
|
78 DrawString(r.left + (rtl ? (uint)WD_FRAMERECT_LEFT : (d.width + 4)), r.right - (rtl ? (d.width + 4) : (uint)WD_FRAMERECT_RIGHT), r.top + (r.bottom - r.top + 1 - FONT_HEIGHT_NORMAL) / 2, STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE); |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
79 } |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
80 |
14409
1eaefde497fd
(svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents:
14258
diff
changeset
|
81 virtual void OnClick(Point pt, int widget, int click_count) |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
82 { |
11623
7f91f3d79f90
(svn r16003) -Codechange: Replaced magic widget number constant with enumerated value in graph legend window.
alberth <alberth@openttd.org>
parents:
11622
diff
changeset
|
83 if (!IsInsideMM(widget, GLW_FIRST_COMPANY, MAX_COMPANIES + GLW_FIRST_COMPANY)) return; |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
84 |
11623
7f91f3d79f90
(svn r16003) -Codechange: Replaced magic widget number constant with enumerated value in graph legend window.
alberth <alberth@openttd.org>
parents:
11622
diff
changeset
|
85 ToggleBit(_legend_excluded_companies, widget - GLW_FIRST_COMPANY); |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
86 this->ToggleWidgetLoweredState(widget); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
87 this->SetDirty(); |
14966
c2e2c495370e
(svn r19574) -Fix: graphs were not properly updated when going toggling keys (i.e. companies)
rubidium <rubidium@openttd.org>
parents:
14965
diff
changeset
|
88 InvalidateWindowData(WC_INCOME_GRAPH, 0); |
c2e2c495370e
(svn r19574) -Fix: graphs were not properly updated when going toggling keys (i.e. companies)
rubidium <rubidium@openttd.org>
parents:
14965
diff
changeset
|
89 InvalidateWindowData(WC_OPERATING_PROFIT, 0); |
c2e2c495370e
(svn r19574) -Fix: graphs were not properly updated when going toggling keys (i.e. companies)
rubidium <rubidium@openttd.org>
parents:
14965
diff
changeset
|
90 InvalidateWindowData(WC_DELIVERED_CARGO, 0); |
c2e2c495370e
(svn r19574) -Fix: graphs were not properly updated when going toggling keys (i.e. companies)
rubidium <rubidium@openttd.org>
parents:
14965
diff
changeset
|
91 InvalidateWindowData(WC_PERFORMANCE_HISTORY, 0); |
c2e2c495370e
(svn r19574) -Fix: graphs were not properly updated when going toggling keys (i.e. companies)
rubidium <rubidium@openttd.org>
parents:
14965
diff
changeset
|
92 InvalidateWindowData(WC_COMPANY_VALUE, 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
|
93 } |
12608
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
94 |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
95 /** |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
96 * Some data on this window has become invalid. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
97 * @param data Information about the changed data. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
98 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
99 */ |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
100 virtual void OnInvalidateData(int data = 0, bool gui_scope = true) |
12608
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
101 { |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
102 if (!gui_scope) return; |
12608
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
103 if (Company::IsValidID(data)) return; |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
104 |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
105 SetBit(_legend_excluded_companies, data); |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
106 this->RaiseWidget(data + GLW_FIRST_COMPANY); |
e260c3e0576e
(svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents:
12598
diff
changeset
|
107 } |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
108 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
109 |
12403
0024ba6bb40e
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents:
12079
diff
changeset
|
110 /** |
0024ba6bb40e
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents:
12079
diff
changeset
|
111 * Construct a vertical list of buttons, one for each company. |
0024ba6bb40e
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents:
12079
diff
changeset
|
112 * @param biggest_index Storage for collecting the biggest index used in the returned tree. |
0024ba6bb40e
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents:
12079
diff
changeset
|
113 * @return Panel with company buttons. |
13954
79b889a3a0cd
(svn r18490) -Doc: Fixed syntax of a few doxygen pre and post coditions.
alberth <alberth@openttd.org>
parents:
13916
diff
changeset
|
114 * @post \c *biggest_index contains the largest used index in the tree. |
12403
0024ba6bb40e
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents:
12079
diff
changeset
|
115 */ |
0024ba6bb40e
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents:
12079
diff
changeset
|
116 static NWidgetBase *MakeNWidgetCompanyLines(int *biggest_index) |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
117 { |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
118 NWidgetVertical *vert = new NWidgetVertical(); |
18196
276c30308311
(svn r23025) -Codechange: Support resized company colour icon in company key window.
peter1138 <peter1138@openttd.org>
parents:
18053
diff
changeset
|
119 uint line_height = max<uint>(GetSpriteSize(SPR_COMPANY_ICON).height, FONT_HEIGHT_NORMAL) + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
120 |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
121 for (int widnum = GLW_FIRST_COMPANY; widnum <= GLW_LAST_COMPANY; widnum++) { |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
122 NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum); |
18196
276c30308311
(svn r23025) -Codechange: Support resized company colour icon in company key window.
peter1138 <peter1138@openttd.org>
parents:
18053
diff
changeset
|
123 panel->SetMinimalSize(246, line_height); |
13725
a1342a520bb0
(svn r18250) -Codechange: make the graph legend big font aware
rubidium <rubidium@openttd.org>
parents:
13705
diff
changeset
|
124 panel->SetFill(1, 0); |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12615
diff
changeset
|
125 panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP); |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
126 vert->Add(panel); |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
127 } |
12403
0024ba6bb40e
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents:
12079
diff
changeset
|
128 *biggest_index = GLW_LAST_COMPANY; |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
129 return vert; |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
130 } |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
131 |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
132 static const NWidgetPart _nested_graph_legend_widgets[] = { |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
133 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
134 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
135 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_KEY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), |
14045
68fabdc82f5b
(svn r18588) -Feature [FS#2943]: Add shading and unshading of windows.
alberth <alberth@openttd.org>
parents:
13954
diff
changeset
|
136 NWidget(WWT_SHADEBOX, COLOUR_GREY), |
13916
32bb7763b24a
(svn r18447) -Change: make some more windows (e.g. graphs, company view) stickyable
rubidium <rubidium@openttd.org>
parents:
13798
diff
changeset
|
137 NWidget(WWT_STICKYBOX, COLOUR_GREY), |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
138 EndContainer(), |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
139 NWidget(WWT_PANEL, COLOUR_GREY, GLW_BACKGROUND), |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
140 NWidget(NWID_SPACER), SetMinimalSize(0, 2), |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
141 NWidget(NWID_HORIZONTAL), |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
142 NWidget(NWID_SPACER), SetMinimalSize(2, 0), |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
143 NWidgetFunction(MakeNWidgetCompanyLines), |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
144 NWidget(NWID_SPACER), SetMinimalSize(2, 0), |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
145 EndContainer(), |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
146 EndContainer(), |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
147 }; |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
148 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
149 static const WindowDesc _graph_legend_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
150 WDP_AUTO, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
151 WC_GRAPH_LEGEND, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13739
diff
changeset
|
152 0, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13556
diff
changeset
|
153 _nested_graph_legend_widgets, lengthof(_nested_graph_legend_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
154 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
155 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
156 static void ShowGraphLegend() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
157 { |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
158 AllocateWindowDescFront<GraphLegendWindow>(&_graph_legend_desc, 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
|
159 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
160 |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
161 /** Contains the interval of a graph's data. */ |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
162 struct ValuesInterval { |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
163 OverflowSafeInt64 highest; ///< Highest value of this interval. Must be zero or greater. |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
164 OverflowSafeInt64 lowest; ///< Lowest value of this interval. Must be zero or less. |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
165 }; |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
166 |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
167 /******************/ |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
168 /* BASE OF GRAPHS */ |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
169 /*****************/ |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
170 |
12079
0f1b20a70f70
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
alberth <alberth@openttd.org>
parents:
11949
diff
changeset
|
171 /** Widget numbers of a base graph window. */ |
0f1b20a70f70
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
alberth <alberth@openttd.org>
parents:
11949
diff
changeset
|
172 enum CompanyValueWidgets { |
0f1b20a70f70
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
alberth <alberth@openttd.org>
parents:
11949
diff
changeset
|
173 BGW_KEY_BUTTON, |
0f1b20a70f70
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
alberth <alberth@openttd.org>
parents:
11949
diff
changeset
|
174 BGW_BACKGROUND, |
15045
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
175 BGW_GRAPH, |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
176 BGW_RESIZE, |
12079
0f1b20a70f70
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
alberth <alberth@openttd.org>
parents:
11949
diff
changeset
|
177 }; |
0f1b20a70f70
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
alberth <alberth@openttd.org>
parents:
11949
diff
changeset
|
178 |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
179 struct BaseGraphWindow : Window { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
180 protected: |
15183
43a5d37b45c4
(svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
rubidium <rubidium@openttd.org>
parents:
15103
diff
changeset
|
181 static const int GRAPH_MAX_DATASETS = 32; |
17657
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
182 static const int GRAPH_AXIS_LINE_COLOUR = PC_BLACK; |
15183
43a5d37b45c4
(svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
rubidium <rubidium@openttd.org>
parents:
15103
diff
changeset
|
183 static const int GRAPH_NUM_MONTHS = 24; ///< Number of months displayed in the graph. |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
184 |
15183
43a5d37b45c4
(svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
rubidium <rubidium@openttd.org>
parents:
15103
diff
changeset
|
185 static const int MIN_GRAPH_NUM_LINES_Y = 9; ///< Minimal number of horizontal lines to draw. |
43a5d37b45c4
(svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
rubidium <rubidium@openttd.org>
parents:
15103
diff
changeset
|
186 static const int MIN_GRID_PIXEL_SIZE = 20; ///< Minimum distance between graph lines. |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
187 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
188 uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed. |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
189 byte num_dataset; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
190 byte num_on_x_axis; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
191 byte num_vert_lines; |
9865
5aa8480f318a
(svn r14011) -Codechange: not required to define an enum which was just the representation of another.
belugas <belugas@openttd.org>
parents:
9850
diff
changeset
|
192 static const TextColour graph_axis_label_colour = TC_BLACK; ///< colour of the graph axis label. |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
193 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
194 /* The starting month and year that values are plotted against. If month is |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
195 * 0xFF, use x_values_start and x_values_increment below instead. */ |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
196 byte month; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
197 Year year; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
198 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
199 /* These values are used if the graph is being plotted against values |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
200 * rather than the dates specified by month and year. */ |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
201 uint16 x_values_start; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
202 uint16 x_values_increment; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
203 |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
204 int graph_widget; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
205 StringID format_str_y_axis; |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11080
diff
changeset
|
206 byte colours[GRAPH_MAX_DATASETS]; |
12615
5f44b757d251
(svn r17058) -Codechange: magic numbers removal.
belugas <belugas@openttd.org>
parents:
12610
diff
changeset
|
207 OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][GRAPH_NUM_MONTHS]; ///< Stored costs for the last #GRAPH_NUM_MONTHS months |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
208 |
14940
f042e7eb7d0e
(svn r19543) -Feature [FS#3726]: Scale the vertical axis of graphs depending on the graph's highest value.
terkhen <terkhen@openttd.org>
parents:
14939
diff
changeset
|
209 /** |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
210 * Get the interval that contains the graph's data. Excluded data is ignored to show smaller values in |
14947
cf7635945b3b
(svn r19550) -Fix (r19543): Scale graphs without taking into account excluded data.
terkhen <terkhen@openttd.org>
parents:
14940
diff
changeset
|
211 * better detail when disabling higher ones. |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
212 * @param num_hori_lines Number of horizontal lines to be drawn. |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
213 * @return Highest and lowest values of the graph (ignoring disabled data). |
14940
f042e7eb7d0e
(svn r19543) -Feature [FS#3726]: Scale the vertical axis of graphs depending on the graph's highest value.
terkhen <terkhen@openttd.org>
parents:
14939
diff
changeset
|
214 */ |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
215 ValuesInterval GetValuesInterval(int num_hori_lines) const |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
216 { |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
217 ValuesInterval current_interval; |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
218 current_interval.highest = INT64_MIN; |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
219 current_interval.lowest = INT64_MAX; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
220 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
221 for (int i = 0; i < this->num_dataset; i++) { |
14947
cf7635945b3b
(svn r19550) -Fix (r19543): Scale graphs without taking into account excluded data.
terkhen <terkhen@openttd.org>
parents:
14940
diff
changeset
|
222 if (HasBit(this->excluded_data, i)) continue; |
14940
f042e7eb7d0e
(svn r19543) -Feature [FS#3726]: Scale the vertical axis of graphs depending on the graph's highest value.
terkhen <terkhen@openttd.org>
parents:
14939
diff
changeset
|
223 for (int j = 0; j < this->num_on_x_axis; j++) { |
f042e7eb7d0e
(svn r19543) -Feature [FS#3726]: Scale the vertical axis of graphs depending on the graph's highest value.
terkhen <terkhen@openttd.org>
parents:
14939
diff
changeset
|
224 OverflowSafeInt64 datapoint = this->cost[i][j]; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
225 |
14940
f042e7eb7d0e
(svn r19543) -Feature [FS#3726]: Scale the vertical axis of graphs depending on the graph's highest value.
terkhen <terkhen@openttd.org>
parents:
14939
diff
changeset
|
226 if (datapoint != INVALID_DATAPOINT) { |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
227 current_interval.highest = max(current_interval.highest, datapoint); |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
228 current_interval.lowest = min(current_interval.lowest, datapoint); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
229 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
230 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
231 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
232 |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
233 /* Prevent showing values too close to the graph limits. */ |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
234 current_interval.highest = (11 * current_interval.highest) / 10; |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
235 current_interval.lowest = (11 * current_interval.lowest) / 10; |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
236 |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
237 /* Always include zero in the shown range. */ |
15103
bd4b62132aed
(svn r19729) -Fix [FS#3793]: The company value graph crashed the game when displaying companies with a huge amount of money.
terkhen <terkhen@openttd.org>
parents:
15053
diff
changeset
|
238 double abs_lower = (current_interval.lowest > 0) ? 0 : (double)abs(current_interval.lowest); |
bd4b62132aed
(svn r19729) -Fix [FS#3793]: The company value graph crashed the game when displaying companies with a huge amount of money.
terkhen <terkhen@openttd.org>
parents:
15053
diff
changeset
|
239 double abs_higher = (current_interval.highest < 0) ? 0 : (double)current_interval.highest; |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
240 |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
241 int num_pos_grids; |
15103
bd4b62132aed
(svn r19729) -Fix [FS#3793]: The company value graph crashed the game when displaying companies with a huge amount of money.
terkhen <terkhen@openttd.org>
parents:
15053
diff
changeset
|
242 int64 grid_size; |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
243 |
15053
851a045406bc
(svn r19673) -Codechange: Optimize calculation of graph grid size (method by Alberth).
terkhen <terkhen@openttd.org>
parents:
15045
diff
changeset
|
244 if (abs_lower != 0 || abs_higher != 0) { |
851a045406bc
(svn r19673) -Codechange: Optimize calculation of graph grid size (method by Alberth).
terkhen <terkhen@openttd.org>
parents:
15045
diff
changeset
|
245 /* The number of grids to reserve for the positive part is: */ |
15103
bd4b62132aed
(svn r19729) -Fix [FS#3793]: The company value graph crashed the game when displaying companies with a huge amount of money.
terkhen <terkhen@openttd.org>
parents:
15053
diff
changeset
|
246 num_pos_grids = (int)floor(0.5 + num_hori_lines * abs_higher / (abs_higher + abs_lower)); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
247 |
15053
851a045406bc
(svn r19673) -Codechange: Optimize calculation of graph grid size (method by Alberth).
terkhen <terkhen@openttd.org>
parents:
15045
diff
changeset
|
248 /* If there are any positive or negative values, force that they have at least one grid. */ |
851a045406bc
(svn r19673) -Codechange: Optimize calculation of graph grid size (method by Alberth).
terkhen <terkhen@openttd.org>
parents:
15045
diff
changeset
|
249 if (num_pos_grids == 0 && abs_higher != 0) num_pos_grids++; |
851a045406bc
(svn r19673) -Codechange: Optimize calculation of graph grid size (method by Alberth).
terkhen <terkhen@openttd.org>
parents:
15045
diff
changeset
|
250 if (num_pos_grids == num_hori_lines && abs_lower != 0) num_pos_grids--; |
851a045406bc
(svn r19673) -Codechange: Optimize calculation of graph grid size (method by Alberth).
terkhen <terkhen@openttd.org>
parents:
15045
diff
changeset
|
251 |
851a045406bc
(svn r19673) -Codechange: Optimize calculation of graph grid size (method by Alberth).
terkhen <terkhen@openttd.org>
parents:
15045
diff
changeset
|
252 /* Get the required grid size for each side and use the maximum one. */ |
15103
bd4b62132aed
(svn r19729) -Fix [FS#3793]: The company value graph crashed the game when displaying companies with a huge amount of money.
terkhen <terkhen@openttd.org>
parents:
15053
diff
changeset
|
253 int64 grid_size_higher = (abs_higher > 0) ? ((int64)abs_higher + num_pos_grids - 1) / num_pos_grids : 0; |
bd4b62132aed
(svn r19729) -Fix [FS#3793]: The company value graph crashed the game when displaying companies with a huge amount of money.
terkhen <terkhen@openttd.org>
parents:
15053
diff
changeset
|
254 int64 grid_size_lower = (abs_lower > 0) ? ((int64)abs_lower + num_hori_lines - num_pos_grids - 1) / (num_hori_lines - num_pos_grids) : 0; |
15053
851a045406bc
(svn r19673) -Codechange: Optimize calculation of graph grid size (method by Alberth).
terkhen <terkhen@openttd.org>
parents:
15045
diff
changeset
|
255 grid_size = max(grid_size_higher, grid_size_lower); |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
256 } else { |
15053
851a045406bc
(svn r19673) -Codechange: Optimize calculation of graph grid size (method by Alberth).
terkhen <terkhen@openttd.org>
parents:
15045
diff
changeset
|
257 /* If both values are zero, show an empty graph. */ |
851a045406bc
(svn r19673) -Codechange: Optimize calculation of graph grid size (method by Alberth).
terkhen <terkhen@openttd.org>
parents:
15045
diff
changeset
|
258 num_pos_grids = num_hori_lines / 2; |
851a045406bc
(svn r19673) -Codechange: Optimize calculation of graph grid size (method by Alberth).
terkhen <terkhen@openttd.org>
parents:
15045
diff
changeset
|
259 grid_size = 1; |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
260 } |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
261 |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
262 current_interval.highest = num_pos_grids * grid_size; |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
263 current_interval.lowest = -(num_hori_lines - num_pos_grids) * grid_size; |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
264 return current_interval; |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
265 } |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
266 |
15620
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
267 /** |
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
268 * Get width for Y labels. |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
269 * @param current_interval Interval that contains all of the graph data. |
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
270 * @param num_hori_lines Number of horizontal lines to be drawn. |
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
271 */ |
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
272 uint GetYLabelWidth(ValuesInterval current_interval, int num_hori_lines) const |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
273 { |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
274 /* draw text strings on the y axis */ |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
275 int64 y_label = current_interval.highest; |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
276 int64 y_label_separation = (current_interval.highest - current_interval.lowest) / num_hori_lines; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
277 |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
278 uint max_width = 0; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
279 |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
280 for (int i = 0; i < (num_hori_lines + 1); i++) { |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
281 SetDParam(0, this->format_str_y_axis); |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
282 SetDParam(1, y_label); |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
283 Dimension d = GetStringBoundingBox(STR_GRAPH_Y_LABEL); |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
284 if (d.width > max_width) max_width = d.width; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
285 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
286 y_label -= y_label_separation; |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
287 } |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
288 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
289 return max_width; |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
290 } |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
291 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
292 /** |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
293 * Actually draw the graph. |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
294 * @param r the rectangle of the data field of the graph |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
295 */ |
13734
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
296 void DrawGraph(Rect r) const |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
297 { |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
298 uint x, y; ///< Reused whenever x and y coordinates are needed. |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
299 ValuesInterval interval; ///< Interval that contains all of the graph data. |
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
300 int x_axis_offset; ///< Distance from the top of the graph to the x axis. |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
301 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
302 /* the colours and cost array of GraphDrawer must accomodate |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
303 * both values for cargo and companies. So if any are higher, quit */ |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
304 assert_compile(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_COMPANIES); |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
305 assert(this->num_vert_lines > 0); |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
306 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
307 byte grid_colour = _colour_gradient[COLOUR_GREY][4]; |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
308 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
309 /* Rect r will be adjusted to contain just the graph, with labels being |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
310 * placed outside the area. */ |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
311 r.top += 5 + GetCharacterHeight(FS_SMALL) / 2; |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
312 r.bottom -= (this->month == 0xFF ? 1 : 3) * GetCharacterHeight(FS_SMALL) + 4; |
13636
eba941c66c5d
(svn r18160) -Codechange: The hyphen character may not line up in all fonts, so draw
peter1138 <peter1138@openttd.org>
parents:
13635
diff
changeset
|
313 r.left += 9; |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
314 r.right -= 5; |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
315 |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
316 /* Initial number of horizontal lines. */ |
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
317 int num_hori_lines = 160 / MIN_GRID_PIXEL_SIZE; |
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
318 /* For the rest of the height, the number of horizontal lines will increase more slowly. */ |
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
319 int resize = (r.bottom - r.top - 160) / (2 * MIN_GRID_PIXEL_SIZE); |
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
320 if (resize > 0) num_hori_lines += resize; |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
321 |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
322 interval = GetValuesInterval(num_hori_lines); |
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
323 |
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
324 int label_width = GetYLabelWidth(interval, num_hori_lines); |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
325 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
326 r.left += label_width; |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
327 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
328 int x_sep = (r.right - r.left) / this->num_vert_lines; |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
329 int y_sep = (r.bottom - r.top) / num_hori_lines; |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
330 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
331 /* Redetermine right and bottom edge of graph to fit with the integer |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
332 * separation values. */ |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
333 r.right = r.left + x_sep * this->num_vert_lines; |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
334 r.bottom = r.top + y_sep * num_hori_lines; |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
335 |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
336 OverflowSafeInt64 interval_size = interval.highest + abs(interval.lowest); |
15103
bd4b62132aed
(svn r19729) -Fix [FS#3793]: The company value graph crashed the game when displaying companies with a huge amount of money.
terkhen <terkhen@openttd.org>
parents:
15053
diff
changeset
|
337 /* Where to draw the X axis. Use floating point to avoid overflowing and results of zero. */ |
bd4b62132aed
(svn r19729) -Fix [FS#3793]: The company value graph crashed the game when displaying companies with a huge amount of money.
terkhen <terkhen@openttd.org>
parents:
15053
diff
changeset
|
338 x_axis_offset = (int)((r.bottom - r.top) * (double)interval.highest / (double)interval_size); |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
339 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
340 /* Draw the vertical grid lines. */ |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
341 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
342 /* Don't draw the first line, as that's where the axis will be. */ |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
343 x = r.left + x_sep; |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
344 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
345 for (int i = 0; i < this->num_vert_lines; i++) { |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
346 GfxFillRect(x, r.top, x, r.bottom, grid_colour); |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
347 x += x_sep; |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
348 } |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
349 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
350 /* Draw the horizontal grid lines. */ |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
351 y = r.bottom; |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
352 |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
353 for (int i = 0; i < (num_hori_lines + 1); i++) { |
13636
eba941c66c5d
(svn r18160) -Codechange: The hyphen character may not line up in all fonts, so draw
peter1138 <peter1138@openttd.org>
parents:
13635
diff
changeset
|
354 GfxFillRect(r.left - 3, y, r.left - 1, y, GRAPH_AXIS_LINE_COLOUR); |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
355 GfxFillRect(r.left, y, r.right, y, grid_colour); |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
356 y -= y_sep; |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
357 } |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
358 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
359 /* Draw the y axis. */ |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
360 GfxFillRect(r.left, r.top, r.left, r.bottom, GRAPH_AXIS_LINE_COLOUR); |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
361 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
362 /* Draw the x axis. */ |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
363 y = x_axis_offset + r.top; |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
364 GfxFillRect(r.left, y, r.right, y, GRAPH_AXIS_LINE_COLOUR); |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
365 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
366 /* Find the largest value that will be drawn. */ |
15552
683f2dbe75bb
(svn r20211) -Codechange: Indented code should have curly braces around it.
alberth <alberth@openttd.org>
parents:
15400
diff
changeset
|
367 if (this->num_on_x_axis == 0) return; |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
368 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
369 assert(this->num_on_x_axis > 0); |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
370 assert(this->num_dataset > 0); |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
371 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
372 /* draw text strings on the y axis */ |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
373 int64 y_label = interval.highest; |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
374 int64 y_label_separation = abs(interval.highest - interval.lowest) / num_hori_lines; |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
375 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
376 y = r.top - GetCharacterHeight(FS_SMALL) / 2; |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
377 |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
378 for (int i = 0; i < (num_hori_lines + 1); i++) { |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
379 SetDParam(0, this->format_str_y_axis); |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
380 SetDParam(1, y_label); |
13636
eba941c66c5d
(svn r18160) -Codechange: The hyphen character may not line up in all fonts, so draw
peter1138 <peter1138@openttd.org>
parents:
13635
diff
changeset
|
381 DrawString(r.left - label_width - 4, r.left - 4, y, STR_GRAPH_Y_LABEL, graph_axis_label_colour, SA_RIGHT); |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
382 |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
383 y_label -= y_label_separation; |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
384 y += y_sep; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
385 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
386 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
387 /* draw strings on the x axis */ |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
388 if (this->month != 0xFF) { |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
389 x = r.left; |
12610
0f2da83ae71c
(svn r17053) -Codechange: pass a Rect to DrawGraph so it knows where to draw
rubidium <rubidium@openttd.org>
parents:
12609
diff
changeset
|
390 y = r.bottom + 2; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
391 byte month = this->month; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
392 Year year = this->year; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
393 for (int i = 0; i < this->num_on_x_axis; i++) { |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
394 SetDParam(0, month + STR_MONTH_ABBREV_JAN); |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
395 SetDParam(1, month + STR_MONTH_ABBREV_JAN + 2); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
396 SetDParam(2, year); |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
397 DrawStringMultiLine(x, x + x_sep, y, this->height, month == 0 ? STR_GRAPH_X_LABEL_MONTH_YEAR : STR_GRAPH_X_LABEL_MONTH, graph_axis_label_colour); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
398 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
399 month += 3; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
400 if (month >= 12) { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
401 month = 0; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
402 year++; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
403 } |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
404 x += x_sep; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
405 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
406 } else { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
407 /* Draw the label under the data point rather than on the grid line. */ |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
408 x = r.left; |
12610
0f2da83ae71c
(svn r17053) -Codechange: pass a Rect to DrawGraph so it knows where to draw
rubidium <rubidium@openttd.org>
parents:
12609
diff
changeset
|
409 y = r.bottom + 2; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
410 uint16 label = this->x_values_start; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
411 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
412 for (int i = 0; i < this->num_on_x_axis; i++) { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
413 SetDParam(0, label); |
15400
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15183
diff
changeset
|
414 DrawString(x + 1, x + x_sep - 1, y, STR_GRAPH_Y_LABEL_NUMBER, graph_axis_label_colour, SA_HOR_CENTER); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
415 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
416 label += this->x_values_increment; |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
417 x += x_sep; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
418 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
419 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
420 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
421 /* draw lines and dots */ |
18650
7e084b7495c6
(svn r23497) -Add: Advanced display setting to control the linewidth in graphs. (ChillCore)
frosch <frosch@openttd.org>
parents:
18427
diff
changeset
|
422 uint linewidth = _settings_client.gui.graph_line_thickness; |
7e084b7495c6
(svn r23497) -Add: Advanced display setting to control the linewidth in graphs. (ChillCore)
frosch <frosch@openttd.org>
parents:
18427
diff
changeset
|
423 uint pointoffs1 = (linewidth + 1) / 2; |
7e084b7495c6
(svn r23497) -Add: Advanced display setting to control the linewidth in graphs. (ChillCore)
frosch <frosch@openttd.org>
parents:
18427
diff
changeset
|
424 uint pointoffs2 = linewidth + 1 - pointoffs1; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
425 for (int i = 0; i < this->num_dataset; i++) { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
426 if (!HasBit(this->excluded_data, i)) { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
427 /* Centre the dot between the grid lines. */ |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
428 x = r.left + (x_sep / 2); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
429 |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11080
diff
changeset
|
430 byte colour = this->colours[i]; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
431 uint prev_x = INVALID_DATAPOINT_POS; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
432 uint prev_y = INVALID_DATAPOINT_POS; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
433 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
434 for (int j = 0; j < this->num_on_x_axis; j++) { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
435 OverflowSafeInt64 datapoint = this->cost[i][j]; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
436 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
437 if (datapoint != INVALID_DATAPOINT) { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
438 /* |
11361
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11111
diff
changeset
|
439 * Check whether we need to reduce the 'accuracy' of the |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11111
diff
changeset
|
440 * datapoint value and the highest value to splut overflows. |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11111
diff
changeset
|
441 * And when 'drawing' 'one million' or 'one million and one' |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11111
diff
changeset
|
442 * there is no significant difference, so the least |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11111
diff
changeset
|
443 * significant bits can just be removed. |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11111
diff
changeset
|
444 * |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11111
diff
changeset
|
445 * If there are more bits needed than would fit in a 32 bits |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11111
diff
changeset
|
446 * integer, so at about 31 bits because of the sign bit, the |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11111
diff
changeset
|
447 * least significant bits are removed. |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11111
diff
changeset
|
448 */ |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
449 int mult_range = FindLastBit(x_axis_offset) + FindLastBit(abs(datapoint)); |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
450 int reduce_range = max(mult_range - 31, 0); |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
451 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
452 /* Handle negative values differently (don't shift sign) */ |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
453 if (datapoint < 0) { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
454 datapoint = -(abs(datapoint) >> reduce_range); |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
455 } else { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
456 datapoint >>= reduce_range; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
457 } |
15016
0df61c282687
(svn r19631) -Feature: Graphs with negative values are no longer forced to have the zero axis in the middle (grid size calculation by Alberth).
terkhen <terkhen@openttd.org>
parents:
15003
diff
changeset
|
458 y = r.top + x_axis_offset - ((r.bottom - r.top) * datapoint) / (interval_size >> reduce_range); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
459 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
460 /* Draw the point. */ |
18650
7e084b7495c6
(svn r23497) -Add: Advanced display setting to control the linewidth in graphs. (ChillCore)
frosch <frosch@openttd.org>
parents:
18427
diff
changeset
|
461 GfxFillRect(x - pointoffs1, y - pointoffs1, x + pointoffs2, y + pointoffs2, colour); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
462 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
463 /* Draw the line connected to the previous point. */ |
18650
7e084b7495c6
(svn r23497) -Add: Advanced display setting to control the linewidth in graphs. (ChillCore)
frosch <frosch@openttd.org>
parents:
18427
diff
changeset
|
464 if (prev_x != INVALID_DATAPOINT_POS) GfxDrawLine(prev_x, prev_y, x, y, colour, linewidth); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
465 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
466 prev_x = x; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
467 prev_y = y; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
468 } else { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
469 prev_x = INVALID_DATAPOINT_POS; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
470 prev_y = INVALID_DATAPOINT_POS; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
471 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
472 |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
473 x += x_sep; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
474 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
475 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
476 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
477 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
478 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
479 |
15017
b7446f6e1b69
(svn r19632) -Cleanup: has_negative_values is no longer used.
terkhen <terkhen@openttd.org>
parents:
15016
diff
changeset
|
480 BaseGraphWindow(int widget, StringID format_str_y_axis) : |
b7446f6e1b69
(svn r19632) -Cleanup: has_negative_values is no longer used.
terkhen <terkhen@openttd.org>
parents:
15016
diff
changeset
|
481 Window(), |
12610
0f2da83ae71c
(svn r17053) -Codechange: pass a Rect to DrawGraph so it knows where to draw
rubidium <rubidium@openttd.org>
parents:
12609
diff
changeset
|
482 format_str_y_axis(format_str_y_axis) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
483 { |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12979
diff
changeset
|
484 SetWindowDirty(WC_GRAPH_LEGEND, 0); |
12609
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
485 this->num_vert_lines = 24; |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
486 this->graph_widget = widget; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
487 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
488 |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
489 void InitializeWindow(const WindowDesc *desc, WindowNumber number) |
12671
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
490 { |
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
491 /* Initialise the dataset */ |
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
492 this->UpdateStatistics(true); |
13734
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
493 |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
494 this->InitNested(desc, number); |
12671
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
495 } |
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
496 |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
497 public: |
13734
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
498 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
499 { |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
500 if (widget != this->graph_widget) return; |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
501 |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
502 uint x_label_width = 0; |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
503 |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
504 if (this->month != 0xFF) { |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
505 byte month = this->month; |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
506 Year year = this->year; |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
507 for (int i = 0; i < this->num_on_x_axis; i++) { |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
508 SetDParam(0, month + STR_MONTH_ABBREV_JAN); |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
509 SetDParam(1, month + STR_MONTH_ABBREV_JAN + 2); |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
510 SetDParam(2, year); |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
511 x_label_width = max(x_label_width, GetStringBoundingBox(month == 0 ? STR_GRAPH_X_LABEL_MONTH_YEAR : STR_GRAPH_X_LABEL_MONTH).width); |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
512 |
13734
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
513 month += 3; |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
514 if (month >= 12) { |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
515 month = 0; |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
516 year++; |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
517 } |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
518 } |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
519 } else { |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
520 /* Draw the label under the data point rather than on the grid line. */ |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
521 SetDParam(0, this->x_values_start + this->num_on_x_axis * this->x_values_increment); |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
522 x_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL_NUMBER).width; |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
523 } |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
524 |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
525 SetDParam(0, this->format_str_y_axis); |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
526 SetDParam(1, INT64_MAX); |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
527 uint y_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL).width; |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
528 |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
529 size->width = max<uint>(size->width, 5 + y_label_width + this->num_on_x_axis * (x_label_width + 5) + 9); |
15044
7dc598210fb7
(svn r19661) -Codechange: Base the number of vertical grids of a graph on its size.
terkhen <terkhen@openttd.org>
parents:
15017
diff
changeset
|
530 size->height = max<uint>(size->height, 5 + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->month != 0xFF ? 3 : 1)) * FONT_HEIGHT_SMALL + 4); |
13734
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
531 size->height = max<uint>(size->height, size->width / 3); |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
532 } |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
533 |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
534 virtual void DrawWidget(const Rect &r, int widget) const |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
535 { |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
536 if (widget != this->graph_widget) return; |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
537 |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
538 DrawGraph(r); |
12609
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
539 } |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
540 |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
541 virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
542 { |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
543 return INVALID_DATAPOINT; |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
544 } |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
545 |
14409
1eaefde497fd
(svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents:
14258
diff
changeset
|
546 virtual void OnClick(Point pt, int widget, int click_count) |
12609
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
547 { |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
548 /* Clicked on legend? */ |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
549 if (widget == BGW_KEY_BUTTON) ShowGraphLegend(); |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
550 } |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
551 |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
552 virtual void OnTick() |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
553 { |
12671
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
554 this->UpdateStatistics(false); |
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
555 } |
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
556 |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
557 /** |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
558 * Some data on this window has become invalid. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
559 * @param data Information about the changed data. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
560 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
561 */ |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
562 virtual void OnInvalidateData(int data = 0, bool gui_scope = true) |
14966
c2e2c495370e
(svn r19574) -Fix: graphs were not properly updated when going toggling keys (i.e. companies)
rubidium <rubidium@openttd.org>
parents:
14965
diff
changeset
|
563 { |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
564 if (!gui_scope) return; |
15003
895f760ad105
(svn r19615) -Fix [FS#3763]: Company related graphs weren't updated correctly after changing the company colour.
terkhen <terkhen@openttd.org>
parents:
14971
diff
changeset
|
565 this->UpdateStatistics(true); |
14966
c2e2c495370e
(svn r19574) -Fix: graphs were not properly updated when going toggling keys (i.e. companies)
rubidium <rubidium@openttd.org>
parents:
14965
diff
changeset
|
566 } |
c2e2c495370e
(svn r19574) -Fix: graphs were not properly updated when going toggling keys (i.e. companies)
rubidium <rubidium@openttd.org>
parents:
14965
diff
changeset
|
567 |
12671
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
568 /** |
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
569 * Update the statistics. |
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
570 * @param initialize Initialize the data structure. |
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
571 */ |
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
572 void UpdateStatistics(bool initialize) |
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
573 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
574 uint excluded_companies = _legend_excluded_companies; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
575 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
576 /* Exclude the companies which aren't valid */ |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
577 for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
578 if (!Company::IsValidID(c)) SetBit(excluded_companies, c); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
579 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
580 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
581 byte nums = 0; |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
582 const Company *c; |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
583 FOR_ALL_COMPANIES(c) { |
12609
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
584 nums = min(this->num_vert_lines, max(nums, c->num_valid_stat_ent)); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
585 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
586 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
587 int mo = (_cur_month / 3 - nums) * 3; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
588 int yr = _cur_year; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
589 while (mo < 0) { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
590 yr--; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
591 mo += 12; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
592 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
593 |
12671
34de19198186
(svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents:
12632
diff
changeset
|
594 if (!initialize && this->excluded_data == excluded_companies && this->num_on_x_axis == nums && |
12609
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
595 this->year == yr && this->month == mo) { |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
596 /* There's no reason to get new stats */ |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
597 return; |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
598 } |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
599 |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
600 this->excluded_data = excluded_companies; |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
601 this->num_on_x_axis = nums; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
602 this->year = yr; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
603 this->month = mo; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
604 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
605 int numd = 0; |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
606 for (CompanyID k = COMPANY_FIRST; k < MAX_COMPANIES; k++) { |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
607 c = Company::GetIfValid(k); |
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
608 if (c != NULL) { |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11080
diff
changeset
|
609 this->colours[numd] = _colour_gradient[c->colour][6]; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
610 for (int j = this->num_on_x_axis, i = 0; --j >= 0;) { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
611 this->cost[numd][i] = (j >= c->num_valid_stat_ent) ? INVALID_DATAPOINT : GetGraphData(c, j); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
612 i++; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
613 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
614 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
615 numd++; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
616 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
617 |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
618 this->num_dataset = numd; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
619 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
620 }; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
621 |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
622 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
623 /********************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
624 /* OPERATING PROFIT */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
625 /********************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
626 |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
627 struct OperatingProfitGraphWindow : BaseGraphWindow { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
628 OperatingProfitGraphWindow(const WindowDesc *desc, WindowNumber window_number) : |
18427
980c099600c8
(svn r23269) -Codechange: rename some control/string codes/IDs to be more consistent
rubidium <rubidium@openttd.org>
parents:
18196
diff
changeset
|
629 BaseGraphWindow(BGW_GRAPH, STR_JUST_CURRENCY_SHORT) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
630 { |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
631 this->InitializeWindow(desc, 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
|
632 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
633 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
634 virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
635 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
636 return c->old_economy[j].income + c->old_economy[j].expenses; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
637 } |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
638 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
639 |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
640 static const NWidgetPart _nested_operating_profit_widgets[] = { |
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
641 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
642 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
643 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_OPERATING_PROFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), |
13629
de84b51f7506
(svn r18153) -Codechange: Correct height for 'key' button on graph windows.
peter1138 <peter1138@openttd.org>
parents:
13628
diff
changeset
|
644 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, BGW_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP), |
14045
68fabdc82f5b
(svn r18588) -Feature [FS#2943]: Add shading and unshading of windows.
alberth <alberth@openttd.org>
parents:
13954
diff
changeset
|
645 NWidget(WWT_SHADEBOX, COLOUR_GREY), |
13916
32bb7763b24a
(svn r18447) -Change: make some more windows (e.g. graphs, company view) stickyable
rubidium <rubidium@openttd.org>
parents:
13798
diff
changeset
|
646 NWidget(WWT_STICKYBOX, COLOUR_GREY), |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
647 EndContainer(), |
15045
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
648 NWidget(WWT_PANEL, COLOUR_GREY, BGW_BACKGROUND), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
649 NWidget(NWID_HORIZONTAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
650 NWidget(WWT_EMPTY, COLOUR_GREY, BGW_GRAPH), SetMinimalSize(576, 160), SetFill(1, 1), SetResize(1, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
651 NWidget(NWID_VERTICAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
652 NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
653 NWidget(WWT_RESIZEBOX, COLOUR_GREY, BGW_RESIZE), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
654 EndContainer(), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
655 EndContainer(), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
656 EndContainer(), |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
657 }; |
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
658 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
659 static const WindowDesc _operating_profit_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
660 WDP_AUTO, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
661 WC_OPERATING_PROFIT, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13739
diff
changeset
|
662 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13556
diff
changeset
|
663 _nested_operating_profit_widgets, lengthof(_nested_operating_profit_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
664 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
665 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
666 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
667 void ShowOperatingProfitGraph() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
668 { |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
669 AllocateWindowDescFront<OperatingProfitGraphWindow>(&_operating_profit_desc, 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
|
670 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
671 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
672 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
673 /****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
674 /* INCOME GRAPH */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
675 /****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
676 |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
677 struct IncomeGraphWindow : BaseGraphWindow { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
678 IncomeGraphWindow(const WindowDesc *desc, WindowNumber window_number) : |
18427
980c099600c8
(svn r23269) -Codechange: rename some control/string codes/IDs to be more consistent
rubidium <rubidium@openttd.org>
parents:
18196
diff
changeset
|
679 BaseGraphWindow(BGW_GRAPH, STR_JUST_CURRENCY_SHORT) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
680 { |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
681 this->InitializeWindow(desc, window_number); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
682 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
683 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
684 virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
685 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
686 return c->old_economy[j].income; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
687 } |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
688 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
689 |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
690 static const NWidgetPart _nested_income_graph_widgets[] = { |
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
691 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
692 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
693 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_INCOME_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), |
13629
de84b51f7506
(svn r18153) -Codechange: Correct height for 'key' button on graph windows.
peter1138 <peter1138@openttd.org>
parents:
13628
diff
changeset
|
694 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, BGW_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP), |
14045
68fabdc82f5b
(svn r18588) -Feature [FS#2943]: Add shading and unshading of windows.
alberth <alberth@openttd.org>
parents:
13954
diff
changeset
|
695 NWidget(WWT_SHADEBOX, COLOUR_GREY), |
13916
32bb7763b24a
(svn r18447) -Change: make some more windows (e.g. graphs, company view) stickyable
rubidium <rubidium@openttd.org>
parents:
13798
diff
changeset
|
696 NWidget(WWT_STICKYBOX, COLOUR_GREY), |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
697 EndContainer(), |
15045
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
698 NWidget(WWT_PANEL, COLOUR_GREY, BGW_BACKGROUND), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
699 NWidget(NWID_HORIZONTAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
700 NWidget(WWT_EMPTY, COLOUR_GREY, BGW_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
701 NWidget(NWID_VERTICAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
702 NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
703 NWidget(WWT_RESIZEBOX, COLOUR_GREY, BGW_RESIZE), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
704 EndContainer(), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
705 EndContainer(), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
706 EndContainer(), |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
707 }; |
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
708 |
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
709 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
710 static const WindowDesc _income_graph_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
711 WDP_AUTO, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
712 WC_INCOME_GRAPH, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13739
diff
changeset
|
713 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13556
diff
changeset
|
714 _nested_income_graph_widgets, lengthof(_nested_income_graph_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
715 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
716 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
717 void ShowIncomeGraph() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
718 { |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
719 AllocateWindowDescFront<IncomeGraphWindow>(&_income_graph_desc, 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
|
720 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
721 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
722 /*******************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
723 /* DELIVERED CARGO */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
724 /*******************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
725 |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
726 struct DeliveredCargoGraphWindow : BaseGraphWindow { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
727 DeliveredCargoGraphWindow(const WindowDesc *desc, WindowNumber window_number) : |
15045
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
728 BaseGraphWindow(BGW_GRAPH, STR_JUST_COMMA) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
729 { |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
730 this->InitializeWindow(desc, window_number); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
731 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
732 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
733 virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
734 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
735 return c->old_economy[j].delivered_cargo; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
736 } |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
737 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
738 |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
739 static const NWidgetPart _nested_delivered_cargo_graph_widgets[] = { |
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
740 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
741 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
742 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_CARGO_DELIVERED_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), |
13629
de84b51f7506
(svn r18153) -Codechange: Correct height for 'key' button on graph windows.
peter1138 <peter1138@openttd.org>
parents:
13628
diff
changeset
|
743 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, BGW_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP), |
14045
68fabdc82f5b
(svn r18588) -Feature [FS#2943]: Add shading and unshading of windows.
alberth <alberth@openttd.org>
parents:
13954
diff
changeset
|
744 NWidget(WWT_SHADEBOX, COLOUR_GREY), |
13916
32bb7763b24a
(svn r18447) -Change: make some more windows (e.g. graphs, company view) stickyable
rubidium <rubidium@openttd.org>
parents:
13798
diff
changeset
|
745 NWidget(WWT_STICKYBOX, COLOUR_GREY), |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
746 EndContainer(), |
15045
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
747 NWidget(WWT_PANEL, COLOUR_GREY, BGW_BACKGROUND), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
748 NWidget(NWID_HORIZONTAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
749 NWidget(WWT_EMPTY, COLOUR_GREY, BGW_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
750 NWidget(NWID_VERTICAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
751 NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
752 NWidget(WWT_RESIZEBOX, COLOUR_GREY, BGW_RESIZE), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
753 EndContainer(), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
754 EndContainer(), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
755 EndContainer(), |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
756 }; |
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
757 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
758 static const WindowDesc _delivered_cargo_graph_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
759 WDP_AUTO, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
760 WC_DELIVERED_CARGO, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13739
diff
changeset
|
761 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13556
diff
changeset
|
762 _nested_delivered_cargo_graph_widgets, lengthof(_nested_delivered_cargo_graph_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
763 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
764 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
765 void ShowDeliveredCargoGraph() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
766 { |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
767 AllocateWindowDescFront<DeliveredCargoGraphWindow>(&_delivered_cargo_graph_desc, 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
|
768 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
769 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
770 /***********************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
771 /* PERFORMANCE HISTORY */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
772 /***********************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
773 |
11749
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
774 /** Widget numbers of the performance history window. */ |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
775 enum PerformanceHistoryGraphWidgets { |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
776 PHW_KEY, |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
777 PHW_DETAILED_PERFORMANCE, |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
778 PHW_BACKGROUND, |
15045
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
779 PHW_GRAPH, |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
780 PHW_RESIZE, |
11749
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
781 }; |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
782 |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
783 struct PerformanceHistoryGraphWindow : BaseGraphWindow { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
784 PerformanceHistoryGraphWindow(const WindowDesc *desc, WindowNumber window_number) : |
15045
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
785 BaseGraphWindow(PHW_GRAPH, STR_JUST_COMMA) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
786 { |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
787 this->InitializeWindow(desc, window_number); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
788 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
789 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
790 virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
791 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
792 return c->old_economy[j].performance_history; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
793 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
794 |
14409
1eaefde497fd
(svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents:
14258
diff
changeset
|
795 virtual void OnClick(Point pt, int widget, int click_count) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
796 { |
11749
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
797 if (widget == PHW_DETAILED_PERFORMANCE) ShowPerformanceRatingDetail(); |
14409
1eaefde497fd
(svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents:
14258
diff
changeset
|
798 this->BaseGraphWindow::OnClick(pt, widget, click_count); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
799 } |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
800 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
801 |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
802 static const NWidgetPart _nested_performance_history_widgets[] = { |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
803 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
804 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
805 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_COMPANY_PERFORMANCE_RATINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), |
13629
de84b51f7506
(svn r18153) -Codechange: Correct height for 'key' button on graph windows.
peter1138 <peter1138@openttd.org>
parents:
13628
diff
changeset
|
806 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, PHW_DETAILED_PERFORMANCE), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_PERFORMANCE_DETAIL_KEY, STR_GRAPH_PERFORMANCE_DETAIL_TOOLTIP), |
de84b51f7506
(svn r18153) -Codechange: Correct height for 'key' button on graph windows.
peter1138 <peter1138@openttd.org>
parents:
13628
diff
changeset
|
807 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, PHW_KEY), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP), |
14045
68fabdc82f5b
(svn r18588) -Feature [FS#2943]: Add shading and unshading of windows.
alberth <alberth@openttd.org>
parents:
13954
diff
changeset
|
808 NWidget(WWT_SHADEBOX, COLOUR_GREY), |
13916
32bb7763b24a
(svn r18447) -Change: make some more windows (e.g. graphs, company view) stickyable
rubidium <rubidium@openttd.org>
parents:
13798
diff
changeset
|
809 NWidget(WWT_STICKYBOX, COLOUR_GREY), |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
810 EndContainer(), |
15045
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
811 NWidget(WWT_PANEL, COLOUR_GREY, PHW_BACKGROUND), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
812 NWidget(NWID_HORIZONTAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
813 NWidget(WWT_EMPTY, COLOUR_GREY, PHW_GRAPH), SetMinimalSize(576, 224), SetFill(1, 1), SetResize(1, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
814 NWidget(NWID_VERTICAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
815 NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
816 NWidget(WWT_RESIZEBOX, COLOUR_GREY, PHW_RESIZE), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
817 EndContainer(), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
818 EndContainer(), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
819 EndContainer(), |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
820 }; |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
821 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
822 static const WindowDesc _performance_history_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
823 WDP_AUTO, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
824 WC_PERFORMANCE_HISTORY, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13739
diff
changeset
|
825 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13556
diff
changeset
|
826 _nested_performance_history_widgets, lengthof(_nested_performance_history_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
827 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
828 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
829 void ShowPerformanceHistoryGraph() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
830 { |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
831 AllocateWindowDescFront<PerformanceHistoryGraphWindow>(&_performance_history_desc, 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
|
832 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
833 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
834 /*****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
835 /* COMPANY VALUE */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
836 /*****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
837 |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
838 struct CompanyValueGraphWindow : BaseGraphWindow { |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
839 CompanyValueGraphWindow(const WindowDesc *desc, WindowNumber window_number) : |
18427
980c099600c8
(svn r23269) -Codechange: rename some control/string codes/IDs to be more consistent
rubidium <rubidium@openttd.org>
parents:
18196
diff
changeset
|
840 BaseGraphWindow(BGW_GRAPH, STR_JUST_CURRENCY_SHORT) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
841 { |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
842 this->InitializeWindow(desc, window_number); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
843 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
844 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
845 virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
846 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
847 return c->old_economy[j].company_value; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
848 } |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
849 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
850 |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
851 static const NWidgetPart _nested_company_value_graph_widgets[] = { |
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
852 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
853 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
854 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_COMPANY_VALUES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), |
13629
de84b51f7506
(svn r18153) -Codechange: Correct height for 'key' button on graph windows.
peter1138 <peter1138@openttd.org>
parents:
13628
diff
changeset
|
855 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, BGW_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP), |
14045
68fabdc82f5b
(svn r18588) -Feature [FS#2943]: Add shading and unshading of windows.
alberth <alberth@openttd.org>
parents:
13954
diff
changeset
|
856 NWidget(WWT_SHADEBOX, COLOUR_GREY), |
13916
32bb7763b24a
(svn r18447) -Change: make some more windows (e.g. graphs, company view) stickyable
rubidium <rubidium@openttd.org>
parents:
13798
diff
changeset
|
857 NWidget(WWT_STICKYBOX, COLOUR_GREY), |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
858 EndContainer(), |
15045
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
859 NWidget(WWT_PANEL, COLOUR_GREY, BGW_BACKGROUND), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
860 NWidget(NWID_HORIZONTAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
861 NWidget(WWT_EMPTY, COLOUR_GREY, BGW_GRAPH), SetMinimalSize(576, 224), SetFill(1, 1), SetResize(1, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
862 NWidget(NWID_VERTICAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
863 NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
864 NWidget(WWT_RESIZEBOX, COLOUR_GREY, BGW_RESIZE), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
865 EndContainer(), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
866 EndContainer(), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
867 EndContainer(), |
11582
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
868 }; |
a72797507693
(svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents:
11574
diff
changeset
|
869 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
870 static const WindowDesc _company_value_graph_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
871 WDP_AUTO, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
872 WC_COMPANY_VALUE, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13739
diff
changeset
|
873 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13556
diff
changeset
|
874 _nested_company_value_graph_widgets, lengthof(_nested_company_value_graph_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
875 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
876 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
877 void ShowCompanyValueGraph() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
878 { |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
879 AllocateWindowDescFront<CompanyValueGraphWindow>(&_company_value_graph_desc, 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
|
880 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
881 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
882 /*****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
883 /* PAYMENT RATES */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
884 /*****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
885 |
12079
0f1b20a70f70
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
alberth <alberth@openttd.org>
parents:
11949
diff
changeset
|
886 /** Widget numbers of the cargo payment rates. */ |
0f1b20a70f70
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
alberth <alberth@openttd.org>
parents:
11949
diff
changeset
|
887 enum CargoPaymentRatesWidgets { |
0f1b20a70f70
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
alberth <alberth@openttd.org>
parents:
11949
diff
changeset
|
888 CPW_BACKGROUND, |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
889 CPW_HEADER, |
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
890 CPW_GRAPH, |
15045
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
891 CPW_RESIZE, |
13635
ff4e7183cd2a
(svn r18159) -Codechange: Rework graphs to scale to the widget they are in, instead of using absolute pixel placement. X-axis labels still need work for large fonts.
peter1138 <peter1138@openttd.org>
parents:
13629
diff
changeset
|
892 CPW_FOOTER, |
14939
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
893 CPW_ENABLE_CARGOS, |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
894 CPW_DISABLE_CARGOS, |
12079
0f1b20a70f70
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
alberth <alberth@openttd.org>
parents:
11949
diff
changeset
|
895 CPW_CARGO_FIRST, |
0f1b20a70f70
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
alberth <alberth@openttd.org>
parents:
11949
diff
changeset
|
896 }; |
0f1b20a70f70
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
alberth <alberth@openttd.org>
parents:
11949
diff
changeset
|
897 |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
898 struct PaymentRatesGraphWindow : BaseGraphWindow { |
14933
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
899 bool first_init; ///< This value is true until the first initialization of the window has finished. |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
900 PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) : |
18427
980c099600c8
(svn r23269) -Codechange: rename some control/string codes/IDs to be more consistent
rubidium <rubidium@openttd.org>
parents:
18196
diff
changeset
|
901 BaseGraphWindow(CPW_GRAPH, STR_JUST_CURRENCY_SHORT) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
902 { |
14933
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
903 this->first_init = true; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
904 this->num_on_x_axis = 20; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
905 this->num_vert_lines = 20; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
906 this->month = 0xFF; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
907 this->x_values_start = 10; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
908 this->x_values_increment = 10; |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
909 |
12609
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
910 /* Initialise the dataset */ |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
911 this->OnHundredthTick(); |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
912 |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
913 this->InitNested(desc, window_number); |
14199
e4aab18f4d6c
(svn r18750) -Fix [FS#3492]: the cargo payment button states weren't properly set on opening the window
rubidium <rubidium@openttd.org>
parents:
14097
diff
changeset
|
914 |
14933
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
915 this->UpdateLoweredWidgets(); |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
916 } |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
917 |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
918 virtual void OnInit() |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
919 { |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
920 /* UpdateLoweredWidgets needs to be called after a language or NewGRF change, but it can't be called before |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
921 * InitNested is done. On the first init these functions are called in the correct order by the constructor. */ |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
922 if (!this->first_init) { |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
923 /* Initialise the dataset */ |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
924 this->OnHundredthTick(); |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
925 this->UpdateLoweredWidgets(); |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
926 } |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
927 this->first_init = false; |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
928 } |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
929 |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
930 void UpdateExcludedData() |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
931 { |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
932 this->excluded_data = 0; |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
933 |
14936
58044b15c59e
(svn r19539) -Codechange: Use a macro to loop through the list of sorted cargo specifications.
terkhen <terkhen@openttd.org>
parents:
14933
diff
changeset
|
934 int i = 0; |
58044b15c59e
(svn r19539) -Codechange: Use a macro to loop through the list of sorted cargo specifications.
terkhen <terkhen@openttd.org>
parents:
14933
diff
changeset
|
935 const CargoSpec *cs; |
14965
8616df9ca587
(svn r19573) -Fix (r19541): Special cargos did not appear at the refit list.
terkhen <terkhen@openttd.org>
parents:
14947
diff
changeset
|
936 FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) { |
14936
58044b15c59e
(svn r19539) -Codechange: Use a macro to loop through the list of sorted cargo specifications.
terkhen <terkhen@openttd.org>
parents:
14933
diff
changeset
|
937 if (HasBit(_legend_excluded_cargo, cs->Index())) SetBit(this->excluded_data, i); |
58044b15c59e
(svn r19539) -Codechange: Use a macro to loop through the list of sorted cargo specifications.
terkhen <terkhen@openttd.org>
parents:
14933
diff
changeset
|
938 i++; |
14933
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
939 } |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
940 } |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
941 |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
942 void UpdateLoweredWidgets() |
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
943 { |
14965
8616df9ca587
(svn r19573) -Fix (r19541): Special cargos did not appear at the refit list.
terkhen <terkhen@openttd.org>
parents:
14947
diff
changeset
|
944 for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) { |
14933
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
945 this->SetWidgetLoweredState(CPW_CARGO_FIRST + i, !HasBit(this->excluded_data, i)); |
14199
e4aab18f4d6c
(svn r18750) -Fix [FS#3492]: the cargo payment button states weren't properly set on opening the window
rubidium <rubidium@openttd.org>
parents:
14097
diff
changeset
|
946 } |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
947 } |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
948 |
13705
8dee47e001b2
(svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents:
13704
diff
changeset
|
949 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
950 { |
13734
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
951 if (widget < CPW_CARGO_FIRST) { |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
952 BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize); |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
953 return; |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
954 } |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
955 |
14933
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
956 const CargoSpec *cs = _sorted_cargo_specs[widget - CPW_CARGO_FIRST]; |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
957 SetDParam(0, cs->name); |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
958 Dimension d = GetStringBoundingBox(STR_GRAPH_CARGO_PAYMENT_CARGO); |
14519
3c95cfb7a679
(svn r19090) -Codechange: some comment coding style fixes
rubidium <rubidium@openttd.org>
parents:
14505
diff
changeset
|
959 d.width += 14; // colour field |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
960 d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
961 d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
962 *size = maxdim(d, *size); |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
963 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
964 |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
965 virtual void DrawWidget(const Rect &r, int widget) const |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
966 { |
13734
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
967 if (widget < CPW_CARGO_FIRST) { |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
968 BaseGraphWindow::DrawWidget(r, widget); |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
969 return; |
f41a11f073f6
(svn r18259) -Codechange: make the graphs big font aware
rubidium <rubidium@openttd.org>
parents:
13725
diff
changeset
|
970 } |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
971 |
14933
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
972 const CargoSpec *cs = _sorted_cargo_specs[widget - CPW_CARGO_FIRST]; |
16441
86fd9bcc9d2f
(svn r21157) -Codechange: remove information about the text direction out of the language "list"
rubidium <rubidium@openttd.org>
parents:
16302
diff
changeset
|
973 bool rtl = _current_text_dir == TD_RTL; |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
974 |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
975 /* Since the buttons have no text, no images, |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
976 * both the text and the coloured box have to be manually painted. |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
977 * clk_dif will move one pixel down and one pixel to the right |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
978 * when the button is clicked */ |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
979 byte clk_dif = this->IsWidgetLowered(widget) ? 1 : 0; |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
980 int x = r.left + WD_FRAMERECT_LEFT; |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
981 int y = r.top; |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
982 |
13643
a790e57124b2
(svn r18167) -Change: make the graph legend, cargo payment graph and company league windows RTL aware
rubidium <rubidium@openttd.org>
parents:
13636
diff
changeset
|
983 int rect_x = clk_dif + (rtl ? r.right - 12 : r.left + WD_FRAMERECT_LEFT); |
a790e57124b2
(svn r18167) -Change: make the graph legend, cargo payment graph and company league windows RTL aware
rubidium <rubidium@openttd.org>
parents:
13636
diff
changeset
|
984 |
17657
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
985 GfxFillRect(rect_x, y + clk_dif, rect_x + 8, y + 5 + clk_dif, PC_BLACK); |
13643
a790e57124b2
(svn r18167) -Change: make the graph legend, cargo payment graph and company league windows RTL aware
rubidium <rubidium@openttd.org>
parents:
13636
diff
changeset
|
986 GfxFillRect(rect_x + 1, y + 1 + clk_dif, rect_x + 7, y + 4 + clk_dif, cs->legend_colour); |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
987 SetDParam(0, cs->name); |
13643
a790e57124b2
(svn r18167) -Change: make the graph legend, cargo payment graph and company league windows RTL aware
rubidium <rubidium@openttd.org>
parents:
13636
diff
changeset
|
988 DrawString(rtl ? r.left : x + 14 + clk_dif, (rtl ? r.right - 14 + clk_dif : r.right), y + clk_dif, STR_GRAPH_CARGO_PAYMENT_CARGO); |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
989 } |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
990 |
14409
1eaefde497fd
(svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents:
14258
diff
changeset
|
991 virtual void OnClick(Point pt, int widget, int click_count) |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
992 { |
14939
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
993 switch (widget) { |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
994 case CPW_ENABLE_CARGOS: |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
995 /* Remove all cargos from the excluded lists. */ |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
996 _legend_excluded_cargo = 0; |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
997 this->excluded_data = 0; |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
998 this->UpdateLoweredWidgets(); |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
999 this->SetDirty(); |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1000 break; |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1001 |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1002 case CPW_DISABLE_CARGOS: { |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1003 /* Add all cargos to the excluded lists. */ |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1004 int i = 0; |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1005 const CargoSpec *cs; |
14965
8616df9ca587
(svn r19573) -Fix (r19541): Special cargos did not appear at the refit list.
terkhen <terkhen@openttd.org>
parents:
14947
diff
changeset
|
1006 FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) { |
14939
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1007 SetBit(_legend_excluded_cargo, cs->Index()); |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1008 SetBit(this->excluded_data, i); |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1009 i++; |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1010 } |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1011 this->UpdateLoweredWidgets(); |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1012 this->SetDirty(); |
15618
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15552
diff
changeset
|
1013 break; |
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15552
diff
changeset
|
1014 } |
14939
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1015 |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1016 default: |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1017 if (widget >= CPW_CARGO_FIRST) { |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1018 int i = widget - CPW_CARGO_FIRST; |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1019 ToggleBit(_legend_excluded_cargo, _sorted_cargo_specs[i]->Index()); |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1020 this->ToggleWidgetLoweredState(widget); |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1021 this->UpdateExcludedData(); |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1022 this->SetDirty(); |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1023 } |
d5e618321973
(svn r19542) -Feature: Add buttons to enable / disable all cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14936
diff
changeset
|
1024 break; |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
1025 } |
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
1026 } |
12609
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1027 |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1028 virtual void OnTick() |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1029 { |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1030 /* Override default OnTick */ |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1031 } |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1032 |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1033 /** |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1034 * Some data on this window has become invalid. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1035 * @param data Information about the changed data. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1036 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1037 */ |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1038 virtual void OnInvalidateData(int data = 0, bool gui_scope = true) |
14966
c2e2c495370e
(svn r19574) -Fix: graphs were not properly updated when going toggling keys (i.e. companies)
rubidium <rubidium@openttd.org>
parents:
14965
diff
changeset
|
1039 { |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1040 if (!gui_scope) return; |
14966
c2e2c495370e
(svn r19574) -Fix: graphs were not properly updated when going toggling keys (i.e. companies)
rubidium <rubidium@openttd.org>
parents:
14965
diff
changeset
|
1041 this->OnHundredthTick(); |
c2e2c495370e
(svn r19574) -Fix: graphs were not properly updated when going toggling keys (i.e. companies)
rubidium <rubidium@openttd.org>
parents:
14965
diff
changeset
|
1042 } |
c2e2c495370e
(svn r19574) -Fix: graphs were not properly updated when going toggling keys (i.e. companies)
rubidium <rubidium@openttd.org>
parents:
14965
diff
changeset
|
1043 |
12609
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1044 virtual void OnHundredthTick() |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1045 { |
14933
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
1046 this->UpdateExcludedData(); |
12609
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1047 |
14936
58044b15c59e
(svn r19539) -Codechange: Use a macro to loop through the list of sorted cargo specifications.
terkhen <terkhen@openttd.org>
parents:
14933
diff
changeset
|
1048 int i = 0; |
58044b15c59e
(svn r19539) -Codechange: Use a macro to loop through the list of sorted cargo specifications.
terkhen <terkhen@openttd.org>
parents:
14933
diff
changeset
|
1049 const CargoSpec *cs; |
14965
8616df9ca587
(svn r19573) -Fix (r19541): Special cargos did not appear at the refit list.
terkhen <terkhen@openttd.org>
parents:
14947
diff
changeset
|
1050 FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) { |
14936
58044b15c59e
(svn r19539) -Codechange: Use a macro to loop through the list of sorted cargo specifications.
terkhen <terkhen@openttd.org>
parents:
14933
diff
changeset
|
1051 this->colours[i] = cs->legend_colour; |
12609
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1052 for (uint j = 0; j != 20; j++) { |
14936
58044b15c59e
(svn r19539) -Codechange: Use a macro to loop through the list of sorted cargo specifications.
terkhen <terkhen@openttd.org>
parents:
14933
diff
changeset
|
1053 this->cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 4 + 4, cs->Index()); |
12609
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1054 } |
14936
58044b15c59e
(svn r19539) -Codechange: Use a macro to loop through the list of sorted cargo specifications.
terkhen <terkhen@openttd.org>
parents:
14933
diff
changeset
|
1055 i++; |
12609
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1056 } |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1057 this->num_dataset = i; |
6324d0461e0c
(svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents:
12608
diff
changeset
|
1058 } |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
1059 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1060 |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1061 /** Construct the row containing the digit keys. */ |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1062 static NWidgetBase *MakeCargoButtons(int *biggest_index) |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1063 { |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1064 NWidgetVertical *ver = new NWidgetVertical; |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1065 |
14965
8616df9ca587
(svn r19573) -Fix (r19541): Special cargos did not appear at the refit list.
terkhen <terkhen@openttd.org>
parents:
14947
diff
changeset
|
1066 for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) { |
14933
7127e155ed79
(svn r19535) -Feature: Sort cargos at the cargo payment rates graph.
terkhen <terkhen@openttd.org>
parents:
14519
diff
changeset
|
1067 NWidgetBackground *leaf = new NWidgetBackground(WWT_PANEL, COLOUR_ORANGE, CPW_CARGO_FIRST + i, NULL); |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1068 leaf->tool_tip = STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO; |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13695
diff
changeset
|
1069 leaf->SetFill(1, 0); |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1070 leaf->SetLowered(true); |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1071 ver->Add(leaf); |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1072 } |
14965
8616df9ca587
(svn r19573) -Fix (r19541): Special cargos did not appear at the refit list.
terkhen <terkhen@openttd.org>
parents:
14947
diff
changeset
|
1073 *biggest_index = CPW_CARGO_FIRST + _sorted_standard_cargo_specs_size - 1; |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1074 return ver; |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1075 } |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1076 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1077 |
11621
cee8c1f807ea
(svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents:
11582
diff
changeset
|
1078 static const NWidgetPart _nested_cargo_payment_rates_widgets[] = { |
cee8c1f807ea
(svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents:
11582
diff
changeset
|
1079 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1080 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1081 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), |
14045
68fabdc82f5b
(svn r18588) -Feature [FS#2943]: Add shading and unshading of windows.
alberth <alberth@openttd.org>
parents:
13954
diff
changeset
|
1082 NWidget(WWT_SHADEBOX, COLOUR_GREY), |
13916
32bb7763b24a
(svn r18447) -Change: make some more windows (e.g. graphs, company view) stickyable
rubidium <rubidium@openttd.org>
parents:
13798
diff
changeset
|
1083 NWidget(WWT_STICKYBOX, COLOUR_GREY), |
11621
cee8c1f807ea
(svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents:
11582
diff
changeset
|
1084 EndContainer(), |
15045
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1085 NWidget(WWT_PANEL, COLOUR_GREY, CPW_BACKGROUND), SetMinimalSize(568, 128), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1086 NWidget(NWID_HORIZONTAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1087 NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1088 NWidget(WWT_TEXT, COLOUR_GREY, CPW_HEADER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_TITLE, STR_NULL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1089 NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1090 EndContainer(), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1091 NWidget(NWID_HORIZONTAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1092 NWidget(WWT_EMPTY, COLOUR_GREY, CPW_GRAPH), SetMinimalSize(495, 0), SetFill(1, 1), SetResize(1, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1093 NWidget(NWID_VERTICAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1094 NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 0), SetResize(0, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1095 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, CPW_ENABLE_CARGOS), SetDataTip(STR_GRAPH_CARGO_ENABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_ENABLE_ALL), SetFill(1, 0), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1096 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, CPW_DISABLE_CARGOS), SetDataTip(STR_GRAPH_CARGO_DISABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL), SetFill(1, 0), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1097 NWidget(NWID_SPACER), SetMinimalSize(0, 4), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1098 NWidgetFunction(MakeCargoButtons), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1099 NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 1), SetResize(0, 1), |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1100 EndContainer(), |
15045
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1101 NWidget(NWID_SPACER), SetMinimalSize(5, 0), SetFill(0, 1), SetResize(0, 1), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1102 EndContainer(), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1103 NWidget(NWID_HORIZONTAL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1104 NWidget(NWID_SPACER), SetMinimalSize(WD_RESIZEBOX_WIDTH, 0), SetFill(1, 0), SetResize(1, 0), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1105 NWidget(WWT_TEXT, COLOUR_GREY, CPW_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL, STR_NULL), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1106 NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0), |
a23bdec8ddcb
(svn r19662) -Feature: Resizable graphs.
terkhen <terkhen@openttd.org>
parents:
15044
diff
changeset
|
1107 NWidget(WWT_RESIZEBOX, COLOUR_GREY, CPW_RESIZE), |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1108 EndContainer(), |
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1109 EndContainer(), |
11621
cee8c1f807ea
(svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents:
11582
diff
changeset
|
1110 }; |
cee8c1f807ea
(svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents:
11582
diff
changeset
|
1111 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
1112 static const WindowDesc _cargo_payment_rates_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
1113 WDP_AUTO, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
1114 WC_PAYMENT_RATES, WC_NONE, |
14971
34548761af22
(svn r19579) -Codechange: auto-raise 'Enable/Disable all' buttons in the Cargo payment rates window
smatz <smatz@openttd.org>
parents:
14966
diff
changeset
|
1115 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13556
diff
changeset
|
1116 _nested_cargo_payment_rates_widgets, lengthof(_nested_cargo_payment_rates_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
1117 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1118 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1119 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
1120 void ShowCargoPaymentRates() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1121 { |
9290
8d0747f9b5af
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents:
9289
diff
changeset
|
1122 AllocateWindowDescFront<PaymentRatesGraphWindow>(&_cargo_payment_rates_desc, 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
|
1123 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1124 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1125 /************************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1126 /* COMPANY LEAGUE TABLE */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1127 /************************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1128 |
13615
469d32611e74
(svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents:
13564
diff
changeset
|
1129 /** Widget numbers for the company league window. */ |
469d32611e74
(svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents:
13564
diff
changeset
|
1130 enum CompanyLeagueWidgets { |
469d32611e74
(svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents:
13564
diff
changeset
|
1131 CLW_BACKGROUND, |
469d32611e74
(svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents:
13564
diff
changeset
|
1132 }; |
469d32611e74
(svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents:
13564
diff
changeset
|
1133 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1134 static const StringID _performance_titles[] = { |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1135 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ENGINEER, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1136 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ENGINEER, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1137 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TRAFFIC_MANAGER, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1138 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TRAFFIC_MANAGER, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1139 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TRANSPORT_COORDINATOR, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1140 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TRANSPORT_COORDINATOR, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1141 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ROUTE_SUPERVISOR, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1142 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ROUTE_SUPERVISOR, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1143 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_DIRECTOR, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1144 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_DIRECTOR, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1145 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_CHIEF_EXECUTIVE, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1146 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_CHIEF_EXECUTIVE, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1147 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_CHAIRMAN, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1148 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_CHAIRMAN, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1149 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_PRESIDENT, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11623
diff
changeset
|
1150 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TYCOON, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1151 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1152 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1153 static inline StringID GetPerformanceTitleFromValue(uint value) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1154 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1155 return _performance_titles[minu(value, 1000) >> 6]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1156 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1157 |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1158 class CompanyLeagueWindow : public Window { |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1159 private: |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1160 GUIList<const Company*> companies; |
13739
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1161 uint ordinal_width; ///< The width of the ordinal number |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1162 uint text_width; ///< The width of the actual text |
18053
f8d3b568aef2
(svn r22868) -Change: Resize the company league window according to the company icon's size
planetmaker <planetmaker@openttd.org>
parents:
17657
diff
changeset
|
1163 uint icon_width; ///< The width of the company icon |
f8d3b568aef2
(svn r22868) -Change: Resize the company league window according to the company icon's size
planetmaker <planetmaker@openttd.org>
parents:
17657
diff
changeset
|
1164 int line_height; ///< Height of the text lines |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1165 |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1166 /** |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1167 * (Re)Build the company league list |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1168 */ |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1169 void BuildCompanyList() |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1170 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1171 if (!this->companies.NeedRebuild()) return; |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1172 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1173 this->companies.Clear(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1174 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1175 const Company *c; |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1176 FOR_ALL_COMPANIES(c) { |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1177 *this->companies.Append() = c; |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1178 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1179 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1180 this->companies.Compact(); |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1181 this->companies.RebuildDone(); |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1182 } |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1183 |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1184 /** Sort the company league by performance history */ |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10480
diff
changeset
|
1185 static int CDECL PerformanceSorter(const Company * const *c1, const Company * const *c2) |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1186 { |
16867
b7a2b1958d0e
(svn r21601) -Fix [FS#4323]: company league table used stats from two quarters ago instead of last quarter
rubidium <rubidium@openttd.org>
parents:
16601
diff
changeset
|
1187 return (*c2)->old_economy[0].performance_history - (*c1)->old_economy[0].performance_history; |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1188 } |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1189 |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1190 public: |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1191 CompanyLeagueWindow(const WindowDesc *desc, WindowNumber window_number) : Window() |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
1192 { |
13357
5ff3fc9fc1dc
(svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1193 this->InitNested(desc, window_number); |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1194 this->companies.ForceRebuild(); |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1195 this->companies.NeedResort(); |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
1196 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1197 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
1198 virtual void OnPaint() |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
1199 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1200 this->BuildCompanyList(); |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1201 this->companies.Sort(&PerformanceSorter); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1202 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
1203 this->DrawWidgets(); |
13615
469d32611e74
(svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents:
13564
diff
changeset
|
1204 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1205 |
13615
469d32611e74
(svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents:
13564
diff
changeset
|
1206 virtual void DrawWidget(const Rect &r, int widget) const |
469d32611e74
(svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents:
13564
diff
changeset
|
1207 { |
469d32611e74
(svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents:
13564
diff
changeset
|
1208 if (widget != CLW_BACKGROUND) return; |
469d32611e74
(svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents:
13564
diff
changeset
|
1209 |
18053
f8d3b568aef2
(svn r22868) -Change: Resize the company league window according to the company icon's size
planetmaker <planetmaker@openttd.org>
parents:
17657
diff
changeset
|
1210 int icon_y_offset = 1 + (FONT_HEIGHT_NORMAL - this->line_height) / 2; |
f8d3b568aef2
(svn r22868) -Change: Resize the company league window according to the company icon's size
planetmaker <planetmaker@openttd.org>
parents:
17657
diff
changeset
|
1211 uint y = r.top + WD_FRAMERECT_TOP - icon_y_offset; |
13739
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1212 |
16441
86fd9bcc9d2f
(svn r21157) -Codechange: remove information about the text direction out of the language "list"
rubidium <rubidium@openttd.org>
parents:
16302
diff
changeset
|
1213 bool rtl = _current_text_dir == TD_RTL; |
13739
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1214 uint ordinal_left = rtl ? r.right - WD_FRAMERECT_LEFT - this->ordinal_width : r.left + WD_FRAMERECT_LEFT; |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1215 uint ordinal_right = rtl ? r.right - WD_FRAMERECT_LEFT : r.left + WD_FRAMERECT_LEFT + this->ordinal_width; |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1216 uint icon_left = r.left + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT + (rtl ? this->text_width : this->ordinal_width); |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1217 uint text_left = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - WD_FRAMERECT_LEFT - this->text_width; |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1218 uint text_right = rtl ? r.left + WD_FRAMERECT_LEFT + this->text_width : r.right - WD_FRAMERECT_LEFT; |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1219 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1220 for (uint i = 0; i != this->companies.Length(); i++) { |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1221 const Company *c = this->companies[i]; |
13739
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1222 DrawString(ordinal_left, ordinal_right, y, i + STR_ORDINAL_NUMBER_1ST, i == 0 ? TC_WHITE : TC_YELLOW); |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1223 |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1224 DrawCompanyIcon(c->index, icon_left, y + icon_y_offset); |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1225 |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1226 SetDParam(0, c->index); |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1227 SetDParam(1, c->index); |
16867
b7a2b1958d0e
(svn r21601) -Fix [FS#4323]: company league table used stats from two quarters ago instead of last quarter
rubidium <rubidium@openttd.org>
parents:
16601
diff
changeset
|
1228 SetDParam(2, GetPerformanceTitleFromValue(c->old_economy[0].performance_history)); |
13739
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1229 DrawString(text_left, text_right, y, STR_COMPANY_LEAGUE_COMPANY_NAME); |
18053
f8d3b568aef2
(svn r22868) -Change: Resize the company league window according to the company icon's size
planetmaker <planetmaker@openttd.org>
parents:
17657
diff
changeset
|
1230 y += this->line_height; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1231 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1232 } |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1233 |
13739
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1234 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1235 { |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1236 if (widget != CLW_BACKGROUND) return; |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1237 |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1238 this->ordinal_width = 0; |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1239 for (uint i = 0; i < MAX_COMPANIES; i++) { |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1240 this->ordinal_width = max(this->ordinal_width, GetStringBoundingBox(STR_ORDINAL_NUMBER_1ST + i).width); |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1241 } |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1242 this->ordinal_width += 5; // Keep some extra spacing |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1243 |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1244 uint widest_width = 0; |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1245 uint widest_title = 0; |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1246 for (uint i = 0; i < lengthof(_performance_titles); i++) { |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1247 uint width = GetStringBoundingBox(_performance_titles[i]).width; |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1248 if (width > widest_width) { |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1249 widest_title = i; |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1250 widest_width = width; |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1251 } |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1252 } |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1253 |
18053
f8d3b568aef2
(svn r22868) -Change: Resize the company league window according to the company icon's size
planetmaker <planetmaker@openttd.org>
parents:
17657
diff
changeset
|
1254 Dimension d = GetSpriteSize(SPR_COMPANY_ICON); |
f8d3b568aef2
(svn r22868) -Change: Resize the company league window according to the company icon's size
planetmaker <planetmaker@openttd.org>
parents:
17657
diff
changeset
|
1255 this->icon_width = d.width + 2; |
f8d3b568aef2
(svn r22868) -Change: Resize the company league window according to the company icon's size
planetmaker <planetmaker@openttd.org>
parents:
17657
diff
changeset
|
1256 this->line_height = max<int>(d.height + 2, FONT_HEIGHT_NORMAL); |
f8d3b568aef2
(svn r22868) -Change: Resize the company league window according to the company icon's size
planetmaker <planetmaker@openttd.org>
parents:
17657
diff
changeset
|
1257 |
13739
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1258 const Company *c; |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1259 FOR_ALL_COMPANIES(c) { |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1260 SetDParam(0, c->index); |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1261 SetDParam(1, c->index); |
14097
e3c772e8163d
(svn r18644) -Fix [FS#3434]: company league window was too narrow
rubidium <rubidium@openttd.org>
parents:
14045
diff
changeset
|
1262 SetDParam(2, _performance_titles[widest_title]); |
13739
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1263 widest_width = max(widest_width, GetStringBoundingBox(STR_COMPANY_LEAGUE_COMPANY_NAME).width); |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1264 } |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1265 |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1266 this->text_width = widest_width + 30; // Keep some extra spacing |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1267 |
18053
f8d3b568aef2
(svn r22868) -Change: Resize the company league window according to the company icon's size
planetmaker <planetmaker@openttd.org>
parents:
17657
diff
changeset
|
1268 size->width = WD_FRAMERECT_LEFT + this->ordinal_width + WD_FRAMERECT_RIGHT + this->icon_width + WD_FRAMERECT_LEFT + this->text_width + WD_FRAMERECT_RIGHT; |
f8d3b568aef2
(svn r22868) -Change: Resize the company league window according to the company icon's size
planetmaker <planetmaker@openttd.org>
parents:
17657
diff
changeset
|
1269 size->height = WD_FRAMERECT_TOP + this->line_height * MAX_COMPANIES + WD_FRAMERECT_BOTTOM; |
13739
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1270 } |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1271 |
49a2ea927978
(svn r18264) -Codechange: make the company league window big font aware
rubidium <rubidium@openttd.org>
parents:
13734
diff
changeset
|
1272 |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1273 virtual void OnTick() |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1274 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1275 if (this->companies.NeedResort()) { |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1276 this->SetDirty(); |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1277 } |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1278 } |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1279 |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1280 /** |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1281 * Some data on this window has become invalid. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1282 * @param data Information about the changed data. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1283 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1284 */ |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1285 virtual void OnInvalidateData(int data = 0, bool gui_scope = true) |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1286 { |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1287 if (data == 0) { |
17492
b50ba9cf01a9
(svn r22247) -Codechange: Update comments wrt. ForceRebuild() in command-scope.
frosch <frosch@openttd.org>
parents:
17486
diff
changeset
|
1288 /* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */ |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1289 this->companies.ForceRebuild(); |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1290 } else { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1291 this->companies.ForceResort(); |
9525
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1292 } |
939a335c63b9
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents:
9333
diff
changeset
|
1293 } |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
1294 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1295 |
11622
6782ab076a1e
(svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents:
11621
diff
changeset
|
1296 static const NWidgetPart _nested_company_league_widgets[] = { |
6782ab076a1e
(svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents:
11621
diff
changeset
|
1297 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1298 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1299 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_COMPANY_LEAGUE_TABLE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), |
14045
68fabdc82f5b
(svn r18588) -Feature [FS#2943]: Add shading and unshading of windows.
alberth <alberth@openttd.org>
parents:
13954
diff
changeset
|
1300 NWidget(WWT_SHADEBOX, COLOUR_GREY), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1301 NWidget(WWT_STICKYBOX, COLOUR_GREY), |
11622
6782ab076a1e
(svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents:
11621
diff
changeset
|
1302 EndContainer(), |
13615
469d32611e74
(svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents:
13564
diff
changeset
|
1303 NWidget(WWT_PANEL, COLOUR_GREY, CLW_BACKGROUND), SetMinimalSize(400, 0), SetMinimalTextLines(15, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), |
11622
6782ab076a1e
(svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents:
11621
diff
changeset
|
1304 }; |
6782ab076a1e
(svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents:
11621
diff
changeset
|
1305 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
1306 static const WindowDesc _company_league_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
1307 WDP_AUTO, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
1308 WC_COMPANY_LEAGUE, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13739
diff
changeset
|
1309 0, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13556
diff
changeset
|
1310 _nested_company_league_widgets, lengthof(_nested_company_league_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
1311 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1312 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
1313 void ShowCompanyLeagueTable() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1314 { |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
1315 AllocateWindowDescFront<CompanyLeagueWindow>(&_company_league_desc, 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
|
1316 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1317 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1318 /*****************************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1319 /* PERFORMANCE RATING DETAIL */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1320 /*****************************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1321 |
11749
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
1322 /** Widget numbers of the performance rating details window. */ |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
1323 enum PerformanceRatingDetailsWidgets { |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
1324 PRW_SCORE_FIRST, |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
1325 PRW_SCORE_LAST = PRW_SCORE_FIRST + (SCORE_END - SCORE_BEGIN) - 1, |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
1326 |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
1327 PRW_COMPANY_FIRST, |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
1328 PRW_COMPANY_LAST = PRW_COMPANY_FIRST + MAX_COMPANIES - 1, |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
1329 }; |
31fe7c0637e4
(svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents:
11730
diff
changeset
|
1330 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1331 struct PerformanceRatingDetailWindow : Window { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1332 static CompanyID company; |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1333 int timeout; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1334 |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1335 PerformanceRatingDetailWindow(const WindowDesc *desc, WindowNumber window_number) : Window() |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1336 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1337 this->UpdateCompanyStats(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1338 |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1339 this->InitNested(desc, window_number); |
12912
6e3b759a3b58
(svn r17404) -Change (r17379): silence gcc warning caused by inlining of a virtual function
rubidium <rubidium@openttd.org>
parents:
12908
diff
changeset
|
1340 this->OnInvalidateData(INVALID_COMPANY); |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1341 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1342 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1343 void UpdateCompanyStats() |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1344 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1345 /* Update all company stats with the current data |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1346 * (this is because _score_info is not saved to a savegame) */ |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1347 Company *c; |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1348 FOR_ALL_COMPANIES(c) { |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1349 UpdateCompanyRatingAndValue(c, false); |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1350 } |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1351 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1352 this->timeout = DAY_TICKS * 5; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1353 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1354 |
13671
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1355 uint score_info_left; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1356 uint score_info_right; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1357 uint bar_left; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1358 uint bar_right; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1359 uint bar_width; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1360 uint bar_height; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1361 uint score_detail_left; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1362 uint score_detail_right; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1363 |
13705
8dee47e001b2
(svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents:
13704
diff
changeset
|
1364 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
13671
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1365 { |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1366 switch (widget) { |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1367 case PRW_SCORE_FIRST: |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1368 this->bar_height = FONT_HEIGHT_NORMAL + 4; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1369 size->height = this->bar_height + 2 * WD_MATRIX_TOP; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1370 |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1371 uint score_info_width = 0; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1372 for (uint i = SCORE_BEGIN; i < SCORE_END; i++) { |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1373 score_info_width = max(score_info_width, GetStringBoundingBox(STR_PERFORMANCE_DETAIL_VEHICLES + i).width); |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1374 } |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1375 SetDParam(0, 1000); |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1376 score_info_width += GetStringBoundingBox(STR_BLACK_COMMA).width + WD_FRAMERECT_LEFT; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1377 |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1378 SetDParam(0, 100); |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1379 this->bar_width = GetStringBoundingBox(STR_PERFORMANCE_DETAIL_PERCENT).width + 20; // Wide bars! |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1380 |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1381 /* At this number we are roughly at the max; it can become wider, |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1382 * but then you need at 1000 times more money. At that time you're |
16302
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1383 * not that interested anymore in the last few digits anyway. |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1384 * The 500 is because 999 999 500 to 999 999 999 are rounded to |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1385 * 1 000 M, and not 999 999 k. Use negative numbers to account for |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1386 * the negative income/amount of money etc. as well. */ |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1387 int max = -(999999999 - 500); |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1388 |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1389 /* Scale max for the display currency. Prior to rendering the value |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1390 * is converted into the display currency, which may cause it to |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1391 * raise significantly. We need to compensate for that since {{CURRCOMPACT}} |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1392 * is used, which can produce quite short renderings of very large |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1393 * values. Otherwise the calculated width could be too narrow. |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1394 * Note that it doesn't work if there was a currency with an exchange |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1395 * rate greater than max. |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1396 * When the currency rate is more than 1000, the 999 999 k becomes at |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1397 * least 999 999 M which roughly is equally long. Furthermore if the |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1398 * exchange rate is that high, 999 999 k is usually not enough anymore |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1399 * to show the different currency numbers. */ |
78ed3fe0f2ee
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents:
15876
diff
changeset
|
1400 if (_currency->rate < 1000) max /= _currency->rate; |
13671
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1401 SetDParam(0, max); |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1402 SetDParam(1, max); |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1403 uint score_detail_width = GetStringBoundingBox(STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY).width; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1404 |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1405 size->width = 7 + score_info_width + 5 + this->bar_width + 5 + score_detail_width + 7; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1406 uint left = 7; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1407 uint right = size->width - 7; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1408 |
16441
86fd9bcc9d2f
(svn r21157) -Codechange: remove information about the text direction out of the language "list"
rubidium <rubidium@openttd.org>
parents:
16302
diff
changeset
|
1409 bool rtl = _current_text_dir == TD_RTL; |
13671
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1410 this->score_info_left = rtl ? right - score_info_width : left; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1411 this->score_info_right = rtl ? right : left + score_info_width; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1412 |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1413 this->score_detail_left = rtl ? left : right - score_detail_width; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1414 this->score_detail_right = rtl ? left + score_detail_width : right; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1415 |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1416 this->bar_left = left + (rtl ? score_detail_width : score_info_width) + 5; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1417 this->bar_right = this->bar_left + this->bar_width; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1418 break; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1419 } |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1420 } |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1421 |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1422 virtual void DrawWidget(const Rect &r, int widget) const |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1423 { |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1424 /* No need to draw when there's nothing to draw */ |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1425 if (this->company == INVALID_COMPANY) return; |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1426 |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1427 if (IsInsideMM(widget, PRW_COMPANY_FIRST, PRW_COMPANY_LAST + 1)) { |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1428 if (this->IsWidgetDisabled(widget)) return; |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1429 CompanyID cid = (CompanyID)(widget - PRW_COMPANY_FIRST); |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1430 int offset = (cid == this->company) ? 1 : 0; |
13446
37fb6e7b7eb9
(svn r17955) -Codechange: s/SPR_PLAYER_ICON/SPR_COMPANY_ICON/
rubidium <rubidium@openttd.org>
parents:
13357
diff
changeset
|
1431 Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON); |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1432 DrawCompanyIcon(cid, (r.left + r.right - sprite_size.width) / 2 + offset, (r.top + r.bottom - sprite_size.height) / 2 + offset); |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1433 return; |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1434 } |
12888
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1435 |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1436 if (!IsInsideMM(widget, PRW_SCORE_FIRST, PRW_SCORE_LAST + 1)) return; |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1437 |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1438 ScoreID score_type = (ScoreID)(widget - PRW_SCORE_FIRST); |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1439 |
17657
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
1440 /* The colours used to show how the progress is going */ |
12888
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1441 int colour_done = _colour_gradient[COLOUR_GREEN][4]; |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1442 int colour_notdone = _colour_gradient[COLOUR_RED][4]; |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1443 |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1444 /* Draw all the score parts */ |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1445 int val = _score_part[company][score_type]; |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1446 int needed = _score_info[score_type].needed; |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1447 int score = _score_info[score_type].score; |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1448 |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1449 /* SCORE_TOTAL has his own rules ;) */ |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1450 if (score_type == SCORE_TOTAL) { |
12908
730eacf8ad29
(svn r17400) -Fix [FS#3172] (r17380): total line of performance rating was calculated wrong
rubidium <rubidium@openttd.org>
parents:
12888
diff
changeset
|
1451 for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) score += _score_info[i].score; |
730eacf8ad29
(svn r17400) -Fix [FS#3172] (r17380): total line of performance rating was calculated wrong
rubidium <rubidium@openttd.org>
parents:
12888
diff
changeset
|
1452 needed = SCORE_MAX; |
12888
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1453 } |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1454 |
13671
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1455 uint bar_top = r.top + WD_MATRIX_TOP; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1456 uint text_top = bar_top + 2; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1457 |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1458 DrawString(this->score_info_left, this->score_info_right, text_top, STR_PERFORMANCE_DETAIL_VEHICLES + score_type); |
12888
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1459 |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1460 /* Draw the score */ |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1461 SetDParam(0, score); |
13671
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1462 DrawString(this->score_info_left, this->score_info_right, text_top, STR_BLACK_COMMA, TC_FROMSTRING, SA_RIGHT); |
12888
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1463 |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1464 /* Calculate the %-bar */ |
13671
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1465 uint x = Clamp(val, 0, needed) * this->bar_width / needed; |
16441
86fd9bcc9d2f
(svn r21157) -Codechange: remove information about the text direction out of the language "list"
rubidium <rubidium@openttd.org>
parents:
16302
diff
changeset
|
1466 bool rtl = _current_text_dir == TD_RTL; |
13671
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1467 if (rtl) { |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1468 x = this->bar_right - x; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1469 } else { |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1470 x = this->bar_left + x; |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1471 } |
12888
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1472 |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1473 /* Draw the bar */ |
13671
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1474 if (x != this->bar_left) GfxFillRect(this->bar_left, bar_top, x, bar_top + this->bar_height, rtl ? colour_notdone : colour_done); |
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1475 if (x != this->bar_right) GfxFillRect(x, bar_top, this->bar_right, bar_top + this->bar_height, rtl ? colour_done : colour_notdone); |
12888
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1476 |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1477 /* Draw it */ |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1478 SetDParam(0, Clamp(val, 0, needed) * 100 / needed); |
15400
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15183
diff
changeset
|
1479 DrawString(this->bar_left, this->bar_right, text_top, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING, SA_HOR_CENTER); |
12888
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1480 |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1481 /* SCORE_LOAN is inversed */ |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1482 if (score_type == SCORE_LOAN) val = needed - val; |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1483 |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1484 /* Draw the amount we have against what is needed |
13454
24547db62b5c
(svn r17963) -Codechange: some documentation style
rubidium <rubidium@openttd.org>
parents:
13446
diff
changeset
|
1485 * For some of them it is in currency format */ |
12888
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1486 SetDParam(0, val); |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1487 SetDParam(1, needed); |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1488 switch (score_type) { |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1489 case SCORE_MIN_PROFIT: |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1490 case SCORE_MIN_INCOME: |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1491 case SCORE_MAX_INCOME: |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1492 case SCORE_MONEY: |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1493 case SCORE_LOAN: |
13671
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1494 DrawString(this->score_detail_left, this->score_detail_right, text_top, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY); |
12888
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1495 break; |
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1496 default: |
13671
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1497 DrawString(this->score_detail_left, this->score_detail_right, text_top, STR_PERFORMANCE_DETAIL_AMOUNT_INT); |
12888
a464f3bd54ed
(svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents:
12887
diff
changeset
|
1498 } |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1499 } |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1500 |
14409
1eaefde497fd
(svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents:
14258
diff
changeset
|
1501 virtual void OnClick(Point pt, int widget, int click_count) |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1502 { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1503 /* Check which button is clicked */ |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1504 if (IsInsideMM(widget, PRW_COMPANY_FIRST, PRW_COMPANY_LAST + 1)) { |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1505 /* Is it no on disable? */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1506 if (!this->IsWidgetDisabled(widget)) { |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1507 this->RaiseWidget(this->company + PRW_COMPANY_FIRST); |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1508 this->company = (CompanyID)(widget - PRW_COMPANY_FIRST); |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1509 this->LowerWidget(this->company + PRW_COMPANY_FIRST); |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1510 this->SetDirty(); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1511 } |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1512 } |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1513 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1514 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1515 virtual void OnTick() |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1516 { |
11852
862dd1024fe7
(svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents:
11770
diff
changeset
|
1517 if (_pause_mode != PM_UNPAUSED) return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1518 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1519 /* Update the company score every 5 days */ |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1520 if (--this->timeout == 0) { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1521 this->UpdateCompanyStats(); |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1522 this->SetDirty(); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1523 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1524 } |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1525 |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1526 /** |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1527 * Some data on this window has become invalid. |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1528 * @param data the company ID of the company that is going to be removed |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1529 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1530 */ |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1531 virtual void OnInvalidateData(int data = 0, bool gui_scope = true) |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1532 { |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17152
diff
changeset
|
1533 if (!gui_scope) return; |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1534 /* Disable the companies who are not active */ |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1535 for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) { |
12979
6266831f418a
(svn r17473) -Codechange: use the post destructor for destroying companies too instead of complicating the graph GUI invalidate code.
rubidium <rubidium@openttd.org>
parents:
12927
diff
changeset
|
1536 this->SetWidgetDisabledState(i + PRW_COMPANY_FIRST, !Company::IsValidID(i)); |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1537 } |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1538 |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1539 /* Check if the currently selected company is still active. */ |
12979
6266831f418a
(svn r17473) -Codechange: use the post destructor for destroying companies too instead of complicating the graph GUI invalidate code.
rubidium <rubidium@openttd.org>
parents:
12927
diff
changeset
|
1540 if (this->company != INVALID_COMPANY && !Company::IsValidID(this->company)) { |
12887
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1541 /* Raise the widget for the previous selection. */ |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1542 this->RaiseWidget(this->company + PRW_COMPANY_FIRST); |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1543 this->company = INVALID_COMPANY; |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1544 } |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1545 |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1546 if (this->company == INVALID_COMPANY) { |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1547 const Company *c; |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1548 FOR_ALL_COMPANIES(c) { |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1549 this->company = c->index; |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1550 break; |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1551 } |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1552 } |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1553 |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1554 /* Make sure the widget is lowered */ |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1555 this->LowerWidget(this->company + PRW_COMPANY_FIRST); |
bda0d7a566ac
(svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
1556 } |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1557 }; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1558 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10054
diff
changeset
|
1559 CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY; |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1560 |
15620
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
1561 /** |
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
1562 * Make a vertical list of panels for outputting score details. |
12403
0024ba6bb40e
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents:
12079
diff
changeset
|
1563 * @param biggest_index Storage for collecting the biggest index used in the returned tree. |
0024ba6bb40e
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents:
12079
diff
changeset
|
1564 * @return Panel with performance details. |
13954
79b889a3a0cd
(svn r18490) -Doc: Fixed syntax of a few doxygen pre and post coditions.
alberth <alberth@openttd.org>
parents:
13916
diff
changeset
|
1565 * @post \c *biggest_index contains the largest used index in the tree. |
12403
0024ba6bb40e
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents:
12079
diff
changeset
|
1566 */ |
0024ba6bb40e
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents:
12079
diff
changeset
|
1567 static NWidgetBase *MakePerformanceDetailPanels(int *biggest_index) |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1568 { |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1569 const StringID performance_tips[] = { |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12615
diff
changeset
|
1570 STR_PERFORMANCE_DETAIL_VEHICLES_TOOLTIP, |
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12615
diff
changeset
|
1571 STR_PERFORMANCE_DETAIL_STATIONS_TOOLTIP, |
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12615
diff
changeset
|
1572 STR_PERFORMANCE_DETAIL_MIN_PROFIT_TOOLTIP, |
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12615
diff
changeset
|
1573 STR_PERFORMANCE_DETAIL_MIN_INCOME_TOOLTIP, |
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12615
diff
changeset
|
1574 STR_PERFORMANCE_DETAIL_MAX_INCOME_TOOLTIP, |
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12615
diff
changeset
|
1575 STR_PERFORMANCE_DETAIL_DELIVERED_TOOLTIP, |
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12615
diff
changeset
|
1576 STR_PERFORMANCE_DETAIL_CARGO_TOOLTIP, |
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12615
diff
changeset
|
1577 STR_PERFORMANCE_DETAIL_MONEY_TOOLTIP, |
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12615
diff
changeset
|
1578 STR_PERFORMANCE_DETAIL_LOAN_TOOLTIP, |
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12615
diff
changeset
|
1579 STR_PERFORMANCE_DETAIL_TOTAL_TOOLTIP, |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1580 }; |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1581 |
12927
950767ea4ee5
(svn r17420) -Codechange: replace assert() by assert_compile() where possible
smatz <smatz@openttd.org>
parents:
12912
diff
changeset
|
1582 assert_compile(lengthof(performance_tips) == SCORE_END - SCORE_BEGIN); |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1583 |
13671
e411d2d97fc1
(svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents:
13643
diff
changeset
|
1584 NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE); |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1585 for (int widnum = PRW_SCORE_FIRST; widnum <= PRW_SCORE_LAST; widnum++) { |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1586 NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum); |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13695
diff
changeset
|
1587 panel->SetFill(1, 1); |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1588 panel->SetDataTip(0x0, performance_tips[widnum - PRW_SCORE_FIRST]); |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1589 vert->Add(panel); |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1590 } |
12403
0024ba6bb40e
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents:
12079
diff
changeset
|
1591 *biggest_index = PRW_SCORE_LAST; |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1592 return vert; |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1593 } |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1594 |
15876
625f70985d01
(svn r20558) -Codechange: use one generic function to create a list of company buttons
yexo <yexo@openttd.org>
parents:
15873
diff
changeset
|
1595 /** Make a number of rows with buttons for each company for the performance rating detail window. */ |
625f70985d01
(svn r20558) -Codechange: use one generic function to create a list of company buttons
yexo <yexo@openttd.org>
parents:
15873
diff
changeset
|
1596 NWidgetBase *MakeCompanyButtonRowsGraphGUI(int *biggest_index) |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1597 { |
15876
625f70985d01
(svn r20558) -Codechange: use one generic function to create a list of company buttons
yexo <yexo@openttd.org>
parents:
15873
diff
changeset
|
1598 return MakeCompanyButtonRows(biggest_index, PRW_COMPANY_FIRST, PRW_COMPANY_LAST, 8, STR_PERFORMANCE_DETAIL_SELECT_COMPANY_TOOLTIP); |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1599 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1600 |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1601 static const NWidgetPart _nested_performance_rating_detail_widgets[] = { |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1602 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1603 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1604 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_PERFORMANCE_DETAIL, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), |
14045
68fabdc82f5b
(svn r18588) -Feature [FS#2943]: Add shading and unshading of windows.
alberth <alberth@openttd.org>
parents:
13954
diff
changeset
|
1605 NWidget(WWT_SHADEBOX, COLOUR_GREY), |
13916
32bb7763b24a
(svn r18447) -Change: make some more windows (e.g. graphs, company view) stickyable
rubidium <rubidium@openttd.org>
parents:
13798
diff
changeset
|
1606 NWidget(WWT_STICKYBOX, COLOUR_GREY), |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1607 EndContainer(), |
13755
bf8a4ced15fe
(svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents:
13752
diff
changeset
|
1608 NWidget(WWT_PANEL, COLOUR_GREY), |
15876
625f70985d01
(svn r20558) -Codechange: use one generic function to create a list of company buttons
yexo <yexo@openttd.org>
parents:
15873
diff
changeset
|
1609 NWidgetFunction(MakeCompanyButtonRowsGraphGUI), SetPadding(0, 1, 1, 2), |
11751
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1610 EndContainer(), |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1611 NWidgetFunction(MakePerformanceDetailPanels), |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1612 }; |
090ef9105d01
(svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents:
11749
diff
changeset
|
1613 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
1614 static const WindowDesc _performance_rating_detail_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
1615 WDP_AUTO, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
1616 WC_PERFORMANCE_DETAIL, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13739
diff
changeset
|
1617 0, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13556
diff
changeset
|
1618 _nested_performance_rating_detail_widgets, lengthof(_nested_performance_rating_detail_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
1619 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1620 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
1621 void ShowPerformanceRatingDetail() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1622 { |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1623 AllocateWindowDescFront<PerformanceRatingDetailWindow>(&_performance_rating_detail_desc, 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
|
1624 } |