annotate src/graph_gui.cpp @ 13725:a1342a520bb0 draft

(svn r18250) -Codechange: make the graph legend big font aware
author rubidium <rubidium@openttd.org>
date Sun, 22 Nov 2009 22:21:00 +0000
parents 8dee47e001b2
children f41a11f073f6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
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"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
13 #include "openttd.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
14 #include "gui.h"
8107
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
15 #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
16 #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
17 #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
18 #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
19 #include "cargotype.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8107
diff changeset
20 #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
21 #include "window_func.h"
8140
fb8a05d579da (svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents: 8131
diff changeset
22 #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
23 #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
24 #include "sortlist_type.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
25
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
26 #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
27 #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
28
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
29 /* 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
30 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
31 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
32
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
33 /* 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
34 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
35 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
36
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
37 /****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
38 /* 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
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
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
41 /** 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
42 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
43 GLW_CLOSEBOX,
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 GLW_CAPTION,
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
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
63 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
64 {
12608
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
65 this->DrawWidgets();
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
66 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
67
12608
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
68 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
69 {
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
70 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
71
12608
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
72 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
73
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
74 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
75
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
76 bool rtl = _dynlang.text_dir == TD_RTL;
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
77
13725
a1342a520bb0 (svn r18250) -Codechange: make the graph legend big font aware
rubidium <rubidium@openttd.org>
parents: 13705
diff changeset
78 DrawCompanyIcon(cid, rtl ? r.right - 16 : r.left + 2, r.top + 2 + (FONT_HEIGHT_NORMAL - 10) / 2);
12608
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
79
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
80 SetDParam(0, cid);
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
81 SetDParam(1, cid);
13725
a1342a520bb0 (svn r18250) -Codechange: make the graph legend big font aware
rubidium <rubidium@openttd.org>
parents: 13705
diff changeset
82 DrawString(r.left + (rtl ? WD_FRAMERECT_LEFT : 19), r.right - (rtl ? 19 : WD_FRAMERECT_RIGHT), r.top + WD_FRAMERECT_TOP, 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
83 }
6203
60d5fce9d6b0 (svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents: 6192
diff changeset
84
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
85 virtual void OnClick(Point pt, int 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
86 {
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
87 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
88
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
89 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
90 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
91 this->SetDirty();
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12979
diff changeset
92 SetWindowDirty(WC_INCOME_GRAPH, 0);
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12979
diff changeset
93 SetWindowDirty(WC_OPERATING_PROFIT, 0);
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12979
diff changeset
94 SetWindowDirty(WC_DELIVERED_CARGO, 0);
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12979
diff changeset
95 SetWindowDirty(WC_PERFORMANCE_HISTORY, 0);
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12979
diff changeset
96 SetWindowDirty(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
97 }
12608
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
98
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
99 virtual void OnInvalidateData(int data)
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
100 {
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
101 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
102
e260c3e0576e (svn r17051) -Codechange: make the graph legend window use nested widgets
rubidium <rubidium@openttd.org>
parents: 12598
diff changeset
103 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
104 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
105 }
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
106 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
107
12403
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
108 /**
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
109 * 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
110 * @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
111 * @return Panel with company buttons.
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
112 * @postcond \c *biggest_index contains the largest used index in the tree.
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
113 */
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
114 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
115 {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
116 NWidgetVertical *vert = new NWidgetVertical();
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 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
119 NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
13725
a1342a520bb0 (svn r18250) -Codechange: make the graph legend big font aware
rubidium <rubidium@openttd.org>
parents: 13705
diff changeset
120 panel->SetMinimalSize(246, FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
a1342a520bb0 (svn r18250) -Codechange: make the graph legend big font aware
rubidium <rubidium@openttd.org>
parents: 13705
diff changeset
121 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
122 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
123 vert->Add(panel);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
124 }
12403
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
125 *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
126 return vert;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
127 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
128
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
129 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
130 NWidget(NWID_HORIZONTAL),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
131 NWidget(WWT_CLOSEBOX, COLOUR_GREY, GLW_CLOSEBOX),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
132 NWidget(WWT_CAPTION, COLOUR_GREY, GLW_CAPTION), SetDataTip(STR_GRAPH_KEY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
133 EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
134 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
135 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
136 NWidget(NWID_HORIZONTAL),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
137 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
138 NWidgetFunction(MakeNWidgetCompanyLines),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
139 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
140 EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
141 EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
142 };
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
143
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
144 static const WindowDesc _graph_legend_desc(
13628
2123810ad874 (svn r18152) -Codechange: remove the 'minimum window size' from the WindowDesc; it's determined from the (nested) widgets
rubidium <rubidium@openttd.org>
parents: 13615
diff changeset
145 WDP_AUTO, WDP_AUTO, 250, 196,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
146 WC_GRAPH_LEGEND, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
147 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13556
diff changeset
148 _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
149 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
150
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
151 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
152 {
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
153 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
154 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
155
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
156 /******************/
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
157 /* BASE OF GRAPHS */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
158 /*****************/
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
159
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
160 /** 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
161 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
162 BGW_CLOSEBOX,
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
163 BGW_CAPTION,
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
164 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
165 BGW_BACKGROUND,
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
166 };
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
167
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
168 struct BaseGraphWindow : Window {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
169 protected:
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
170 enum {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
171 GRAPH_MAX_DATASETS = 32,
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
172 GRAPH_AXIS_LINE_COLOUR = 215,
12615
5f44b757d251 (svn r17058) -Codechange: magic numbers removal.
belugas <belugas@openttd.org>
parents: 12610
diff changeset
173 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
174
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
175 GRAPH_NUM_LINES_Y = 9, ///< How many horizontal lines to draw.
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
176 /* 9 is convenient as that means the distance between them is the gd_height of the graph / 8,
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
177 * which is the same
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
178 * as height >> 3. */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
179 };
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
180
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
181 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
182 byte num_dataset;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
183 byte num_on_x_axis;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
184 bool has_negative_values;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
185 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
186 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
187
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
188 /* 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
189 * 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
190 byte month;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
191 Year year;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
192
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
193 /* 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
194 * 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
195 uint16 x_values_start;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
196 uint16 x_values_increment;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
197
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
198 int graph_widget;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
199 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
200 byte colours[GRAPH_MAX_DATASETS];
12615
5f44b757d251 (svn r17058) -Codechange: magic numbers removal.
belugas <belugas@openttd.org>
parents: 12610
diff changeset
201 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
202
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
203 int64 GetHighestValue(int initial_highest_value) const
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
204 {
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
205 OverflowSafeInt64 highest_value = initial_highest_value;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
206
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
207 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
208 if (!HasBit(this->excluded_data, i)) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
209 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
210 OverflowSafeInt64 datapoint = this->cost[i][j];
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
211
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
212 if (datapoint != INVALID_DATAPOINT) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
213 /* For now, if the graph has negative values the scaling is
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
214 * symmetrical about the x axis, so take the absolute value
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
215 * of each data point. */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
216 highest_value = max(highest_value, abs(datapoint));
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
217 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
218 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
219 }
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
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
222 /* Round up highest_value so that it will divide cleanly into the number of
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
223 * axis labels used. */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
224 int round_val = highest_value % (GRAPH_NUM_LINES_Y - 1);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
225 if (round_val != 0) highest_value += (GRAPH_NUM_LINES_Y - 1 - round_val);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
226
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
227 return highest_value;
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
228 }
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
229
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
230 uint GetYLabelWidth(int64 highest_value) const
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
231 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
232 /* draw text strings on the y axis */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
233 int64 y_label = highest_value;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
234 int64 y_label_separation = highest_value / (GRAPH_NUM_LINES_Y - 1);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
235
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
236 /* If there are negative values, the graph goes from highest_value to
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
237 * -highest_value, not highest_value to 0. */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
238 if (this->has_negative_values) y_label_separation *= 2;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
239
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
240 uint max_width = 0;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
241
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
242 for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
243 SetDParam(0, this->format_str_y_axis);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
244 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
245 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
246 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
247
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
248 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
249 }
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
250
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
251 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
252 }
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
253
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
254 /**
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
255 * 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
256 * @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
257 */
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
258 void DrawGraph(Rect &r) const
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
259 {
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
260 uint x, y; ///< Reused whenever x and y coordinates are needed.
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
261 OverflowSafeInt64 highest_value; ///< Highest value to be drawn.
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
262 int x_axis_offset; ///< Distance from the top of the graph to 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
263
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
264 /* 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
265 * 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
266 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
267 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
268
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
269 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
270
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
271 /* 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
272 * 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
273 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
274 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
275 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
276 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
277
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 /* Start of with a highest_value of twice the height of the graph in pixels.
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
279 * It's a bit arbitrary, but it makes the cargo payment graph look a little
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
280 * nicer, and prevents division by zero when calculating where the datapoint
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
281 * should be drawn. */
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
282 highest_value = r.bottom - r.top + 1;
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 if (!this->has_negative_values) highest_value *= 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
284 highest_value = GetHighestValue(highest_value);
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
285
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
286 /* Get width for Y labels */
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 int label_width = GetYLabelWidth(highest_value);
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 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
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 int x_sep = (r.right - r.left) / this->num_vert_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
292 int y_sep = (r.bottom - r.top) / (GRAPH_NUM_LINES_Y - 1);
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
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 /* 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
295 * 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
296 r.right = r.left + x_sep * this->num_vert_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
297 r.bottom = r.top + y_sep * (GRAPH_NUM_LINES_Y - 1);
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
298
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
299 /* Where to 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
300 x_axis_offset = r.bottom - 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
301 if (this->has_negative_values) x_axis_offset /= 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
302
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 /* 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
304
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 /* 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
306 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
307
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 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
309 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
310 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
311 }
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
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
313 /* 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
314 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
315
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
316 for (int i = 0; i < GRAPH_NUM_LINES_Y; 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
317 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
318 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
319 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
320 }
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
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
322 /* 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
323 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
324
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 /* 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
326 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
327 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
328
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
329 /* Find the largest value that will be drawn. */
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 if (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
331 return;
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
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 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
334 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
335
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
336 /* draw text strings on 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
337 int64 y_label = highest_value;
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
338 int64 y_label_separation = highest_value / (GRAPH_NUM_LINES_Y - 1);
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 /* If there are negative values, the graph goes from highest_value to
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 * -highest_value, not highest_value to 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
342 if (this->has_negative_values) y_label_separation *= 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
343
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 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
345
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 for (int i = 0; i < GRAPH_NUM_LINES_Y; 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
347 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
348 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
349 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
350
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_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
352 y += y_sep;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
353 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
354
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
355 /* draw strings on the x axis */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
356 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
357 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
358 y = r.bottom + 2;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
359 byte month = this->month;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
360 Year year = this->year;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
361 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
362 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
363 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
364 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
365 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
366
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
367 month += 3;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
368 if (month >= 12) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
369 month = 0;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
370 year++;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
371 }
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
372 x += x_sep;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
373 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
374 } else {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
375 /* 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
376 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
377 y = r.bottom + 2;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
378 uint16 label = this->x_values_start;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
379
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
380 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
381 SetDParam(0, 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
382 DrawString(x + 1, x + x_sep - 1, y, STR_GRAPH_Y_LABEL_NUMBER, graph_axis_label_colour, SA_CENTER);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
383
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
384 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
385 x += x_sep;
9290
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 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
388
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
389 /* draw lines and dots */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
390 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
391 if (!HasBit(this->excluded_data, i)) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
392 /* 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
393 x = r.left + (x_sep / 2);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
394
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
395 byte colour = this->colours[i];
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
396 uint prev_x = INVALID_DATAPOINT_POS;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
397 uint prev_y = INVALID_DATAPOINT_POS;
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 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
400 OverflowSafeInt64 datapoint = this->cost[i][j];
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
401
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
402 if (datapoint != INVALID_DATAPOINT) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
403 /*
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
404 * 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
405 * 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
406 * 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
407 * 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
408 * significant bits can just be removed.
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
409 *
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
410 * 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
411 * 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
412 * least significant bits are removed.
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
413 */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
414 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
415 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
416
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
417 /* 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
418 if (datapoint < 0) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
419 datapoint = -(abs(datapoint) >> reduce_range);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
420 } else {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
421 datapoint >>= reduce_range;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
422 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
423
12610
0f2da83ae71c (svn r17053) -Codechange: pass a Rect to DrawGraph so it knows where to draw
rubidium <rubidium@openttd.org>
parents: 12609
diff changeset
424 y = r.top + x_axis_offset - (x_axis_offset * datapoint) / (highest_value >> reduce_range);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
425
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
426 /* Draw the point. */
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
427 GfxFillRect(x - 1, y - 1, x + 1, y + 1, colour);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
428
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
429 /* Draw the line connected to the previous point. */
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
430 if (prev_x != INVALID_DATAPOINT_POS) GfxDrawLine(prev_x, prev_y, x, y, colour);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
431
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
432 prev_x = x;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
433 prev_y = y;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
434 } else {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
435 prev_x = INVALID_DATAPOINT_POS;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
436 prev_y = INVALID_DATAPOINT_POS;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
437 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
438
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
439 x += x_sep;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
440 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
441 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
442 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
443 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
444
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
445
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
446 BaseGraphWindow(int widget, bool has_negative_values, StringID format_str_y_axis) :
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
447 Window(), has_negative_values(has_negative_values),
12610
0f2da83ae71c (svn r17053) -Codechange: pass a Rect to DrawGraph so it knows where to draw
rubidium <rubidium@openttd.org>
parents: 12609
diff changeset
448 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
449 {
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12979
diff changeset
450 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
451 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
452 this->graph_widget = widget;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
453 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
454
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
455 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
456 {
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
457 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
458
34de19198186 (svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents: 12632
diff changeset
459 /* 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
460 this->UpdateStatistics(true);
34de19198186 (svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents: 12632
diff changeset
461 }
34de19198186 (svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents: 12632
diff changeset
462
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
463 public:
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
464 virtual void OnPaint()
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 this->DrawWidgets();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
467
13695
75560523443c (svn r18220) -Codechange: Reduce number of nested widget dynamic casts.
alberth <alberth@openttd.org>
parents: 13671
diff changeset
468 NWidgetBase *nwid = this->GetWidget<NWidgetBase>(this->graph_widget);
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
469 Rect r;
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
470 r.left = nwid->pos_x;
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
471 r.right = nwid->pos_x + nwid->current_x - 1;
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
472 r.top = nwid->pos_y;
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 r.bottom = nwid->pos_y + nwid->current_y - 1;
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
474
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
475 this->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
476 }
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
477
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
478 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
479 {
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
480 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
481 }
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
482
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
483 virtual void OnClick(Point pt, int widget)
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
484 {
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
485 /* 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
486 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
487 }
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
488
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
489 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
490 {
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
491 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
492 }
34de19198186 (svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents: 12632
diff changeset
493
34de19198186 (svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents: 12632
diff changeset
494 /**
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 * 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
496 * @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
497 */
34de19198186 (svn r17126) -Fix [FS#3096]: Initialize graph data from the constructor of the derived class.
alberth <alberth@openttd.org>
parents: 12632
diff changeset
498 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
499 {
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
500 uint excluded_companies = _legend_excluded_companies;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
501
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
502 /* 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
503 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
504 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
505 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
506
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
507 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
508 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
509 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
510 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
511 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
512
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
513 int mo = (_cur_month / 3 - nums) * 3;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
514 int yr = _cur_year;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
515 while (mo < 0) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
516 yr--;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
517 mo += 12;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
518 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
519
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
520 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
521 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
522 /* 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
523 return;
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
524 }
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
525
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
526 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
527 this->num_on_x_axis = nums;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
528 this->year = yr;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
529 this->month = mo;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
530
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
531 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
532 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
533 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
534 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
535 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
536 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
537 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
538 i++;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
539 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
540 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
541 numd++;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
542 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
543
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
544 this->num_dataset = numd;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
545 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
546 };
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
547
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
548
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
549 /********************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
550 /* 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
551 /********************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
552
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
553 struct OperatingProfitGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
554 OperatingProfitGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
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
555 BaseGraphWindow(BGW_BACKGROUND, true, STR_JUST_CURRCOMPACT)
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
556 {
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
557 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
558 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
559
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
560 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
561 {
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
562 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
563 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
564 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
565
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
566 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
567 NWidget(NWID_HORIZONTAL),
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
568 NWidget(WWT_CLOSEBOX, COLOUR_GREY, BGW_CLOSEBOX),
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
569 NWidget(WWT_CAPTION, COLOUR_GREY, BGW_CAPTION), 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
570 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),
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
571 EndContainer(),
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
572 NWidget(WWT_PANEL, COLOUR_GREY, BGW_BACKGROUND), SetMinimalSize(576, 160), EndContainer(),
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
573 };
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
574
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
575 static const WindowDesc _operating_profit_desc(
13628
2123810ad874 (svn r18152) -Codechange: remove the 'minimum window size' from the WindowDesc; it's determined from the (nested) widgets
rubidium <rubidium@openttd.org>
parents: 13615
diff changeset
576 WDP_AUTO, WDP_AUTO, 576, 174,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
577 WC_OPERATING_PROFIT, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
578 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13556
diff changeset
579 _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
580 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
581
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
582
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
583 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
584 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
585 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
586 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
587
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
588
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
589 /****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
590 /* 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
591 /****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
592
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
593 struct IncomeGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
594 IncomeGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
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
595 BaseGraphWindow(BGW_BACKGROUND, false, STR_JUST_CURRCOMPACT)
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
596 {
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
597 this->InitializeWindow(desc, window_number);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
598 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
599
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
600 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
601 {
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
602 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
603 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
604 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
605
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
606 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
607 NWidget(NWID_HORIZONTAL),
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
608 NWidget(WWT_CLOSEBOX, COLOUR_GREY, BGW_CLOSEBOX),
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
609 NWidget(WWT_CAPTION, COLOUR_GREY, BGW_CAPTION), 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
610 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),
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
611 EndContainer(),
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
612 NWidget(WWT_PANEL, COLOUR_GREY, BGW_BACKGROUND), SetMinimalSize(576, 128), EndContainer(),
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
613 };
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
614
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
615
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
616 static const WindowDesc _income_graph_desc(
13628
2123810ad874 (svn r18152) -Codechange: remove the 'minimum window size' from the WindowDesc; it's determined from the (nested) widgets
rubidium <rubidium@openttd.org>
parents: 13615
diff changeset
617 WDP_AUTO, WDP_AUTO, 576, 142,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
618 WC_INCOME_GRAPH, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
619 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13556
diff changeset
620 _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
621 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
622
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
623 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
624 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
625 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
626 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
627
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
628 /*******************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
629 /* 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
630 /*******************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
631
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
632 struct DeliveredCargoGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
633 DeliveredCargoGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
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
634 BaseGraphWindow(BGW_BACKGROUND, false, STR_JUST_COMMA)
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
635 {
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
636 this->InitializeWindow(desc, window_number);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
637 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
638
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
639 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
640 {
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
641 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
642 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
643 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
644
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
645 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
646 NWidget(NWID_HORIZONTAL),
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 NWidget(WWT_CLOSEBOX, COLOUR_GREY, BGW_CLOSEBOX),
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
648 NWidget(WWT_CAPTION, COLOUR_GREY, BGW_CAPTION), 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
649 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),
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
650 EndContainer(),
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
651 NWidget(WWT_PANEL, COLOUR_GREY, BGW_BACKGROUND), SetMinimalSize(576, 128), EndContainer(),
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
652 };
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
653
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
654 static const WindowDesc _delivered_cargo_graph_desc(
13628
2123810ad874 (svn r18152) -Codechange: remove the 'minimum window size' from the WindowDesc; it's determined from the (nested) widgets
rubidium <rubidium@openttd.org>
parents: 13615
diff changeset
655 WDP_AUTO, WDP_AUTO, 576, 142,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
656 WC_DELIVERED_CARGO, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
657 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13556
diff changeset
658 _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
659 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
660
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
661 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
662 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
663 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
664 }
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 /***********************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
667 /* 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
668 /***********************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
669
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
670 /** 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
671 enum PerformanceHistoryGraphWidgets {
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
672 PHW_CLOSEBOX,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
673 PHW_CAPTION,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
674 PHW_KEY,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
675 PHW_DETAILED_PERFORMANCE,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
676 PHW_BACKGROUND,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
677 };
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
678
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
679 struct PerformanceHistoryGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
680 PerformanceHistoryGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
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
681 BaseGraphWindow(PHW_BACKGROUND, false, STR_JUST_COMMA)
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
682 {
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
683 this->InitializeWindow(desc, window_number);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
684 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
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 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
687 {
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
688 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
689 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
690
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
691 virtual void OnClick(Point pt, int widget)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
692 {
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
693 if (widget == PHW_DETAILED_PERFORMANCE) ShowPerformanceRatingDetail();
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
694 this->BaseGraphWindow::OnClick(pt, widget);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
695 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
696 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
697
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
698 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
699 NWidget(NWID_HORIZONTAL),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
700 NWidget(WWT_CLOSEBOX, COLOUR_GREY, PHW_CLOSEBOX),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
701 NWidget(WWT_CAPTION, COLOUR_GREY, PHW_CAPTION), 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
702 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
703 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),
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
704 EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
705 NWidget(WWT_PANEL, COLOUR_GREY, PHW_BACKGROUND), SetMinimalSize(576, 224), EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
706 };
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
707
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
708 static const WindowDesc _performance_history_desc(
13628
2123810ad874 (svn r18152) -Codechange: remove the 'minimum window size' from the WindowDesc; it's determined from the (nested) widgets
rubidium <rubidium@openttd.org>
parents: 13615
diff changeset
709 WDP_AUTO, WDP_AUTO, 576, 238,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
710 WC_PERFORMANCE_HISTORY, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
711 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13556
diff changeset
712 _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
713 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
714
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
715 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
716 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
717 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
718 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
719
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 /* 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
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
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
724 struct CompanyValueGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
725 CompanyValueGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
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
726 BaseGraphWindow(BGW_BACKGROUND, false, STR_JUST_CURRCOMPACT)
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
727 {
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
728 this->InitializeWindow(desc, window_number);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
729 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
730
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
731 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
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 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
734 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
735 };
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
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
737 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
738 NWidget(NWID_HORIZONTAL),
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 NWidget(WWT_CLOSEBOX, COLOUR_GREY, BGW_CLOSEBOX),
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
740 NWidget(WWT_CAPTION, COLOUR_GREY, BGW_CAPTION), 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
741 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),
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
742 EndContainer(),
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
743 NWidget(WWT_PANEL, COLOUR_GREY, BGW_BACKGROUND), SetMinimalSize(576, 224), EndContainer(),
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
744 };
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
745
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
746 static const WindowDesc _company_value_graph_desc(
13628
2123810ad874 (svn r18152) -Codechange: remove the 'minimum window size' from the WindowDesc; it's determined from the (nested) widgets
rubidium <rubidium@openttd.org>
parents: 13615
diff changeset
747 WDP_AUTO, WDP_AUTO, 576, 238,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
748 WC_COMPANY_VALUE, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
749 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13556
diff changeset
750 _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
751 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
752
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
753 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
754 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
755 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
756 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
757
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
758 /*****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
759 /* 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
760 /*****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
761
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
762 /** 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
763 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
764 CPW_CLOSEBOX,
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
765 CPW_CAPTION,
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
766 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
767 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
768 CPW_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
769 CPW_FOOTER,
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
770 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
771 };
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
772
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
773 struct PaymentRatesGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
774 PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
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
775 BaseGraphWindow(CPW_GRAPH, false, STR_JUST_CURRCOMPACT)
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
776 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
777 this->num_on_x_axis = 20;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
778 this->num_vert_lines = 20;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
779 this->month = 0xFF;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
780 this->x_values_start = 10;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
781 this->x_values_increment = 10;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
782
12609
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
783 /* 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
784 this->OnHundredthTick();
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
785
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
786 this->InitNested(desc, window_number);
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
787 }
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
788
13705
8dee47e001b2 (svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents: 13704
diff changeset
789 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
790 {
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
791 if (widget < CPW_CARGO_FIRST) return;
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
792
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
793 const CargoSpec *cs = CargoSpec::Get(widget - CPW_CARGO_FIRST);
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
794 SetDParam(0, cs->name);
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
795 Dimension d = GetStringBoundingBox(STR_GRAPH_CARGO_PAYMENT_CARGO);
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
796 d.width += 14; /* colour field */
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
797 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
798 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
799 *size = maxdim(d, *size);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
800 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
801
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
802 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
803 {
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
804 if (widget < CPW_CARGO_FIRST) return;
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
805
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
806 const CargoSpec *cs = CargoSpec::Get(widget - CPW_CARGO_FIRST);
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
807 bool rtl = _dynlang.text_dir == TD_RTL;
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
808
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
809 /* 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
810 * 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
811 * 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
812 * when the button is clicked */
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
813 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
814 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
815 int y = r.top;
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
816
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
817 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
818
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
819 GfxFillRect(rect_x, y + clk_dif, rect_x + 8, y + 5 + clk_dif, 0);
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
820 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
821 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
822 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
823 }
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
824
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
825 virtual void OnClick(Point pt, int widget)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
826 {
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
827 if (widget >= CPW_CARGO_FIRST) {
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
828 int i = 0;
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
829 const CargoSpec *cs;
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
830 FOR_ALL_CARGOSPECS(cs) {
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
831 if (cs->Index() + CPW_CARGO_FIRST == widget) break;
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
832 i++;
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
833 }
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
834
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
835 ToggleBit(_legend_excluded_cargo, i);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
836 this->ToggleWidgetLoweredState(widget);
12609
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
837 this->excluded_data = _legend_excluded_cargo;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
838 this->SetDirty();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
839 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
840 }
12609
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
841
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
842 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
843 {
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
844 /* 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
845 }
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
846
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
847 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
848 {
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
849 this->excluded_data = _legend_excluded_cargo;
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
850
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
851 int i = 0;
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
852 const CargoSpec *cs;
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
853 FOR_ALL_CARGOSPECS(cs) {
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
854 this->colours[i] = cs->legend_colour;
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
855 for (uint j = 0; j != 20; j++) {
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
856 this->cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 4 + 4, cs->Index());
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
857 }
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
858
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
859 i++;
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
860 }
6324d0461e0c (svn r17052) -Codechange: move state changes out of OnPaint for the graph windows
rubidium <rubidium@openttd.org>
parents: 12608
diff changeset
861 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
862 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
863 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
864
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
865 /** 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
866 static NWidgetBase *MakeCargoButtons(int *biggest_index)
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
867 {
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
868 NWidgetVertical *ver = new NWidgetVertical;
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
869
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
870 const CargoSpec *cs;
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
871 FOR_ALL_CARGOSPECS(cs) {
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
872 *biggest_index = CPW_CARGO_FIRST + cs->Index();
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
873 NWidgetBackground *leaf = new NWidgetBackground(WWT_PANEL, COLOUR_ORANGE, *biggest_index, NULL);
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
874 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
875 leaf->SetFill(1, 0);
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
876 leaf->SetLowered(true);
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
877 ver->Add(leaf);
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
878 }
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
879 return ver;
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
880 }
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
881
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
882
11621
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
883 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
884 NWidget(NWID_HORIZONTAL),
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
885 NWidget(WWT_CLOSEBOX, COLOUR_GREY, CPW_CLOSEBOX),
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
886 NWidget(WWT_CAPTION, COLOUR_GREY, CPW_CAPTION), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
11621
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
887 EndContainer(),
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
888 NWidget(WWT_PANEL, COLOUR_GREY, CPW_BACKGROUND), SetMinimalSize(568, 128), SetResize(0, 1),
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 NWidget(NWID_VERTICAL),
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 NWidget(NWID_HORIZONTAL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
891 NWidget(NWID_SPACER), SetFill(1, 0),
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 NWidget(WWT_TEXT, COLOUR_GREY, CPW_HEADER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_TITLE, STR_NULL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
893 NWidget(NWID_SPACER), SetFill(1, 0),
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
894 EndContainer(),
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
895 NWidget(NWID_HORIZONTAL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
896 NWidget(WWT_EMPTY, COLOUR_GREY, CPW_GRAPH), SetMinimalSize(495, 0), SetFill(1, 1),
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
897 NWidget(NWID_VERTICAL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
898 NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 0),
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
899 NWidgetFunction(MakeCargoButtons),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
900 NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 1),
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
901 EndContainer(),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
902 NWidget(NWID_SPACER), SetMinimalSize(5, 0), SetFill(0, 1),
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
903 EndContainer(),
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
904 NWidget(NWID_HORIZONTAL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
905 NWidget(NWID_SPACER), SetFill(1, 0),
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
906 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),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
907 NWidget(NWID_SPACER), SetFill(1, 0),
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
908 EndContainer(),
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
909 EndContainer(),
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
910 EndContainer(),
11621
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
911 };
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
912
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
913 static const WindowDesc _cargo_payment_rates_desc(
13628
2123810ad874 (svn r18152) -Codechange: remove the 'minimum window size' from the WindowDesc; it's determined from the (nested) widgets
rubidium <rubidium@openttd.org>
parents: 13615
diff changeset
914 WDP_AUTO, WDP_AUTO, 568, 46,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
915 WC_PAYMENT_RATES, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
916 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13556
diff changeset
917 _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
918 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
919
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
920
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
921 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
922 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
923 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
924 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
925
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
926 /************************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
927 /* 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
928 /************************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
929
13615
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
930 /** 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
931 enum CompanyLeagueWidgets {
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
932 CLW_CLOSEBOX,
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
933 CLW_CAPTION,
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
934 CLW_STICKYBOX,
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
935 CLW_BACKGROUND,
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
936 };
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
937
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
938 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
939 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
940 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
941 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
942 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
943 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
944 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
945 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
946 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
947 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
948 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
949 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
950 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
951 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
952 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
953 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
954 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
955 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
956
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
957 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
958 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
959 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
960 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
961
9525
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
962 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
963 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
964 GUIList<const Company*> companies;
9525
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
965
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
966 /**
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
967 * (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
968 */
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
969 void BuildCompanyList()
9525
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
970 {
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
971 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
972
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
973 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
974
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
975 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
976 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
977 *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
978 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
979
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
980 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
981 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
982 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
983
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
984 /** Sort the company league by performance history */
10647
592ae9307430 (svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents: 10480
diff changeset
985 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
986 {
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
987 return (*c2)->old_economy[1].performance_history - (*c1)->old_economy[1].performance_history;
9525
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
988 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
989
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
990 public:
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
991 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
992 {
13357
5ff3fc9fc1dc (svn r17866) -Codechange: make the remaining graph windows nested
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
993 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
994 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
995 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
996 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
997
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
998 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
999 {
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
1000 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
1001 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
1002
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
1003 this->DrawWidgets();
13615
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
1004 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1005
13615
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
1006 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
1007 {
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
1008 if (widget != CLW_BACKGROUND) return;
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
1009
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
1010 uint y = r.top + WD_FRAMERECT_TOP;
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
1011 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
1012 const Company *c = this->companies[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
1013 SetDParam(0, i + STR_ORDINAL_NUMBER_1ST);
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
1014 SetDParam(1, c->index);
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
1015 SetDParam(2, c->index);
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
1016 SetDParam(3, GetPerformanceTitleFromValue(c->old_economy[1].performance_history));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1017
13615
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
1018 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, i == 0 ? STR_COMPANY_LEAGUE_FIRST : STR_COMPANY_LEAGUE_OTHER);
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
1019 DrawCompanyIcon(c->index, _dynlang.text_dir == TD_RTL ? r.right - 43 : r.left + 27, y + 1);
13615
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
1020 y += FONT_HEIGHT_NORMAL;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1021 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1022 }
9525
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
1023
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
1024 virtual void OnTick()
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
1025 {
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
1026 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
1027 this->SetDirty();
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
1028 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
1029 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
1030
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
1031 virtual void OnInvalidateData(int data)
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
1032 {
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
1033 if (data == 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
1034 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
1035 } 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
1036 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
1037 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
1038 }
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
1039 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1040
11622
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
1041 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
1042 NWidget(NWID_HORIZONTAL),
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
1043 NWidget(WWT_CLOSEBOX, COLOUR_GREY, CLW_CLOSEBOX),
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
1044 NWidget(WWT_CAPTION, COLOUR_GREY, CLW_CAPTION), SetDataTip(STR_COMPANY_LEAGUE_TABLE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
11622
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
1045 NWidget(WWT_STICKYBOX, COLOUR_GREY, CLW_STICKYBOX),
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
1046 EndContainer(),
13615
469d32611e74 (svn r18139) -Codechange: Scale company league table for font height.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
1047 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
1048 };
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
1049
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
1050 static const WindowDesc _company_league_desc(
13628
2123810ad874 (svn r18152) -Codechange: remove the 'minimum window size' from the WindowDesc; it's determined from the (nested) widgets
rubidium <rubidium@openttd.org>
parents: 13615
diff changeset
1051 WDP_AUTO, WDP_AUTO, 400, 167,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
1052 WC_COMPANY_LEAGUE, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1053 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13556
diff changeset
1054 _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
1055 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1056
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
1057 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
1058 {
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
1059 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
1060 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1061
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1062 /*****************************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1063 /* 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
1064 /*****************************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1065
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1066 /** 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
1067 enum PerformanceRatingDetailsWidgets {
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1068 PRW_CLOSEBOX,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1069 PRW_CAPTION,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1070 PRW_BACKGROUND,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1071
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1072 PRW_SCORE_FIRST,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1073 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
1074
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1075 PRW_COMPANY_FIRST,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1076 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
1077 };
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1078
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1079 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
1080 static CompanyID company;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1081 int timeout;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1082
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
1083 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
1084 {
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
1085 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
1086
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
1087 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
1088 this->OnInvalidateData(INVALID_COMPANY);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1089 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1090
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
1091 void UpdateCompanyStats()
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1092 {
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
1093 /* 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
1094 * (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
1095 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
1096 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
1097 UpdateCompanyRatingAndValue(c, false);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1098 }
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1099
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1100 this->timeout = DAY_TICKS * 5;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1101 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1102
13671
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1103 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
1104 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
1105 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
1106 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
1107 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
1108 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
1109 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
1110 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
1111
13705
8dee47e001b2 (svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents: 13704
diff changeset
1112 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
1113 {
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1114 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
1115 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
1116 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
1117 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
1118
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1119 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
1120 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
1121 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
1122 }
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1123 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
1124 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
1125
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1126 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
1127 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
1128
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1129 /* 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
1130 * but then you need at 1000 times more money. At that time you're
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1131 * not that interested anymore in the last few digits anyway. */
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1132 uint max = 999999999; // nine 9s
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1133 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
1134 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
1135 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
1136
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1137 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
1138 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
1139 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
1140
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1141 bool rtl = _dynlang.text_dir == TD_RTL;
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1142 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
1143 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
1144
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1145 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
1146 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
1147
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1148 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
1149 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
1150 break;
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1151 }
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1152 }
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1153
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1154 virtual void OnPaint()
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1155 {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1156 /* Draw standard stuff */
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9255
diff changeset
1157 this->DrawWidgets();
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1158 }
8179
a0879dc1b54d (svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138 <peter1138@openttd.org>
parents: 8140
diff changeset
1159
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
1160 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
1161 {
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1162 /* 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
1163 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
1164
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1165 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
1166 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
1167 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
1168 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
1169 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
1170 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
1171 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
1172 }
12888
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1173
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1174 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
1175
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1176 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
1177
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1178 /* The colours used to show how the progress is going */
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1179 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
1180 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
1181
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1182 /* 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
1183 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
1184 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
1185 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
1186
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1187 /* 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
1188 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
1189 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
1190 needed = SCORE_MAX;
12888
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1191 }
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1192
13671
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1193 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
1194 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
1195
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1196 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
1197
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1198 /* Draw the score */
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1199 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
1200 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
1201
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1202 /* 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
1203 uint x = Clamp(val, 0, needed) * this->bar_width / needed;
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1204 bool rtl = _dynlang.text_dir == TD_RTL;
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1205 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
1206 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
1207 } else {
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1208 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
1209 }
12888
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1210
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1211 /* 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
1212 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
1213 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
1214
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1215 /* Draw it */
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1216 SetDParam(0, Clamp(val, 0, needed) * 100 / needed);
13671
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1217 DrawString(this->bar_left, this->bar_right, text_top, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING, SA_CENTER);
12888
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1218
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1219 /* SCORE_LOAN is inversed */
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1220 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
1221
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1222 /* 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
1223 * 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
1224 SetDParam(0, val);
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1225 SetDParam(1, needed);
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1226 switch (score_type) {
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1227 case SCORE_MIN_PROFIT:
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1228 case SCORE_MIN_INCOME:
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1229 case SCORE_MAX_INCOME:
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1230 case SCORE_MONEY:
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1231 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
1232 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
1233 break;
a464f3bd54ed (svn r17380) -Codechange: move drawing the performance detail data to DrawWidget
rubidium <rubidium@openttd.org>
parents: 12887
diff changeset
1234 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
1235 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
1236 }
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
1237 }
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1238
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1239 virtual void OnClick(Point pt, int widget)
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1240 {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1241 /* 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
1242 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
1243 /* Is it no on disable? */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1244 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
1245 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
1246 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
1247 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
1248 this->SetDirty();
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1249 }
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1250 }
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1251 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1252
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1253 virtual void OnTick()
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1254 {
11852
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11770
diff changeset
1255 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
1256
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
1257 /* 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
1258 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
1259 this->UpdateCompanyStats();
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1260 this->SetDirty();
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1261 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1262 }
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
1263
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1264 /**
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1265 * Invalidate the data of this window.
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1266 * @param data the company ID of the company that is going to be removed
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1267 */
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1268 virtual void OnInvalidateData(int data)
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1269 {
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1270 /* 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
1271 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
1272 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
1273 }
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1274
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1275 /* 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
1276 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
1277 /* 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
1278 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
1279 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
1280 }
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1281
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1282 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
1283 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
1284 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
1285 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
1286 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
1287 }
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1288 }
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1289
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1290 /* 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
1291 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
1292 }
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1293 };
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1294
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
1295 CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1296
12403
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1297 /** Make a vertical list of panels for outputting score details.
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1298 * @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
1299 * @return Panel with performance details.
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1300 * @postcond \c *biggest_index contains the largest used index in the tree.
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1301 */
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1302 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
1303 {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1304 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
1305 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
1306 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
1307 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
1308 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
1309 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
1310 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
1311 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
1312 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
1313 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
1314 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
1315 };
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1316
12927
950767ea4ee5 (svn r17420) -Codechange: replace assert() by assert_compile() where possible
smatz <smatz@openttd.org>
parents: 12912
diff changeset
1317 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
1318
13671
e411d2d97fc1 (svn r18196) -Codechange: make the performance rating details window big font and RTL aware
rubidium <rubidium@openttd.org>
parents: 13643
diff changeset
1319 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
1320 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
1321 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
1322 panel->SetFill(1, 1);
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1323 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
1324 vert->Add(panel);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1325 }
12403
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1326 *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
1327 return vert;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1328 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1329
12403
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1330 /**
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1331 * Make a number of rows with button-like graphics, for enabling/disabling each company.
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1332 * @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
1333 * @return Panel with rows of company buttons.
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1334 * @postcond \c *biggest_index contains the largest used index in the tree.
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1335 */
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1336 static NWidgetBase *MakeCompanyButtonRows(int *biggest_index)
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1337 {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1338 static const int MAX_LENGTH = 8; // Maximal number of company buttons in one row.
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1339 NWidgetVertical *vert = NULL; // Storage for all rows.
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1340 NWidgetHorizontal *hor = NULL; // Storage for buttons in one row.
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1341 int hor_length = 0;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1342
13446
37fb6e7b7eb9 (svn r17955) -Codechange: s/SPR_PLAYER_ICON/SPR_COMPANY_ICON/
rubidium <rubidium@openttd.org>
parents: 13357
diff changeset
1343 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
1344 sprite_size.width += WD_MATRIX_LEFT + WD_MATRIX_RIGHT;
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1345 sprite_size.height += WD_MATRIX_TOP + WD_MATRIX_BOTTOM + 1; // 1 for the 'offset' of being pressed
bda0d7a566ac (svn r17379) -Codechange: make the performance rating window nested, although it still needs some improvements
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
1346
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1347 for (int widnum = PRW_COMPANY_FIRST; widnum <= PRW_COMPANY_LAST; widnum++) {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1348 /* Ensure there is room in 'hor' for another button. */
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1349 if (hor_length == MAX_LENGTH) {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1350 if (vert == NULL) vert = new NWidgetVertical();
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1351 vert->Add(hor);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1352 hor = NULL;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1353 hor_length = 0;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1354 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1355 if (hor == NULL) {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1356 hor = new NWidgetHorizontal();
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1357 hor_length = 0;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1358 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1359
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1360 NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
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
1361 panel->SetMinimalSize(sprite_size.width, sprite_size.height);
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
1362 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
1363 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
1364 hor->Add(panel);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1365 hor_length++;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1366 }
12403
0024ba6bb40e (svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
alberth <alberth@openttd.org>
parents: 12079
diff changeset
1367 *biggest_index = PRW_COMPANY_LAST;
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1368 if (vert == NULL) return hor; // All buttons fit in a single row.
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1369
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1370 if (hor_length > 0 && hor_length < MAX_LENGTH) {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1371 /* Last row is partial, add a spacer at the end to force all buttons to the left. */
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1372 NWidgetSpacer *spc = new NWidgetSpacer(0, 0);
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
1373 spc->SetMinimalSize(sprite_size.width, sprite_size.height);
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
1374 spc->SetFill(1, 0);
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1375 hor->Add(spc);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1376 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1377 if (hor != NULL) vert->Add(hor);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1378 return vert;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1379 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1380
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1381 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
1382 NWidget(NWID_HORIZONTAL),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1383 NWidget(WWT_CLOSEBOX, COLOUR_GREY, PRW_CLOSEBOX),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1384 NWidget(WWT_CAPTION, COLOUR_GREY, PRW_CAPTION), SetDataTip(STR_PERFORMANCE_DETAIL, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1385 EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1386 NWidget(WWT_PANEL, COLOUR_GREY, PRW_BACKGROUND),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1387 NWidgetFunction(MakeCompanyButtonRows), SetPadding(0, 1, 1, 2),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1388 EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1389 NWidgetFunction(MakePerformanceDetailPanels),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1390 };
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1391
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
1392 static const WindowDesc _performance_rating_detail_desc(
13628
2123810ad874 (svn r18152) -Codechange: remove the 'minimum window size' from the WindowDesc; it's determined from the (nested) widgets
rubidium <rubidium@openttd.org>
parents: 13615
diff changeset
1393 WDP_AUTO, WDP_AUTO, 299, 241,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
1394 WC_PERFORMANCE_DETAIL, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1395 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13556
diff changeset
1396 _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
1397 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1398
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
1399 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
1400 {
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1401 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
1402 }