annotate src/graph_gui.cpp @ 11949:c89301974eb8 draft

(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
author smatz <smatz@openttd.org>
date Mon, 18 May 2009 16:21:28 +0000 (2009-05-18)
parents fccc9cea27a7
children 0f1b20a70f70
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
9111
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 8409
diff changeset
3 /** @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
4
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
5 #include "stdafx.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
6 #include "openttd.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
7 #include "gui.h"
8107
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
8 #include "window_gui.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
9 #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
10 #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
11 #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
12 #include "cargotype.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8107
diff changeset
13 #include "strings_func.h"
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
14 #include "window_func.h"
8140
fb8a05d579da (svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents: 8131
diff changeset
15 #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
16 #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
17 #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
18
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
19 #include "table/strings.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
20
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
21 /* 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
22 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
23 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
24
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
25 /* 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
26 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
27 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
28
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
29 /****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
30 /* 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
31 /****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
32
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
33 /** 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
34 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
35 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
36 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
37 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
38
7f91f3d79f90 (svn r16003) -Codechange: Replaced magic widget number constant with enumerated value in graph legend window.
alberth <alberth@openttd.org>
parents: 11622
diff changeset
39 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
40 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
41 };
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
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
43 struct GraphLegendWindow : Window {
c052caf473db (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
44 GraphLegendWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
c052caf473db (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
45 {
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
46 for (uint i = GLW_FIRST_COMPANY; i < this->widget_count; i++) {
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 if (!HasBit(_legend_excluded_companies, i - GLW_FIRST_COMPANY)) this->LowerWidget(i);
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
48 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
49
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
50 this->FindWindowPlacementAndResize(desc);
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 }
6203
60d5fce9d6b0 (svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents: 6192
diff changeset
52
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 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
54 {
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
55 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
56 if (Company::IsValidID(c)) continue;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
57
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
58 SetBit(_legend_excluded_companies, c);
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
59 this->RaiseWidget(c + GLW_FIRST_COMPANY);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
60 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
61
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
62 this->DrawWidgets();
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
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
64 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
65 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
66 DrawCompanyIcon(c->index, 4, 18 + c->index * 12);
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
67
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
68 SetDParam(0, 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
69 SetDParam(1, c->index);
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
70 DrawString(21, this->width - 4, 17 + c->index * 12, STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, c->index) ? 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
71 }
c052caf473db (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
72 }
6203
60d5fce9d6b0 (svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents: 6192
diff changeset
73
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
74 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
75 {
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
76 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
77
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
78 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
79 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
80 this->SetDirty();
c052caf473db (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
81 InvalidateWindow(WC_INCOME_GRAPH, 0);
c052caf473db (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
82 InvalidateWindow(WC_OPERATING_PROFIT, 0);
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 InvalidateWindow(WC_DELIVERED_CARGO, 0);
c052caf473db (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
84 InvalidateWindow(WC_PERFORMANCE_HISTORY, 0);
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 InvalidateWindow(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
86 }
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
87 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
88
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
89 static NWidgetBase *MakeNWidgetCompanyLines()
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
90 {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
91 NWidgetVertical *vert = new NWidgetVertical();
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
92
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
93 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
94 NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
95 panel->SetMinimalSize(246, 12);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
96 panel->SetFill(false, false);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
97 panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
98 vert->Add(panel);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
99 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
100 return vert;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
101 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
102
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
103 static const Widget _graph_legend_widgets[] = {
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
104 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW}, // GLW_CLOSEBOX
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
105 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 249, 0, 13, STR_GRAPH_KEY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS}, // GLW_CAPTION
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
106 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 249, 14, 195, 0x0, STR_NULL}, // GLW_BACKGROUND
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
107 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 16, 27, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION}, // GLW_FIRST_COMPANY
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
108 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 28, 39, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
109 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 40, 51, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
110 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 52, 63, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
111 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 64, 75, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
112 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 76, 87, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
113 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 88, 99, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
114 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 100, 111, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
115 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 112, 123, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
116 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 124, 135, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
117 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 136, 147, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
118 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 148, 159, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
119 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 160, 171, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
120 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 172, 183, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
121 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 184, 195, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION}, // GLW_LAST_COMPANY
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
122 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
123 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
124
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
125 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
126 NWidget(NWID_HORIZONTAL),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
127 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
128 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
129 EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
130 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
131 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
132 NWidget(NWID_HORIZONTAL),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
133 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
134 NWidgetFunction(MakeNWidgetCompanyLines),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
135 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
136 EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
137 EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
138 };
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
139
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
140 static const WindowDesc _graph_legend_desc(
10480
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
141 WDP_AUTO, WDP_AUTO, 250, 198, 250, 198,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
142 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
143 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
144 _graph_legend_widgets, _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
145 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
146
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
147 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
148 {
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
149 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
150 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
151
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
152 /******************/
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
153 /* BASE OF GRAPHS */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
154 /*****************/
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
155
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
156 struct BaseGraphWindow : Window {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
157 protected:
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
158 enum {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
159 GRAPH_MAX_DATASETS = 32,
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
160 GRAPH_AXIS_LINE_COLOUR = 215,
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
161
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
162 GRAPH_X_POSITION_BEGINNING = 44, ///< Start the graph 44 pixels from gd_left
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
163 GRAPH_X_POSITION_SEPARATION = 22, ///< There are 22 pixels between each X value
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
164
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
165 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
166 /* 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
167 * which is the same
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
168 * as height >> 3. */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
169 };
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
170
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
171 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
172 byte num_dataset;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
173 byte num_on_x_axis;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
174 bool has_negative_values;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
175 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
176 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
177
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
178 /* 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
179 * 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
180 byte month;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
181 Year year;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
182
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
183 /* 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
184 * 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
185 uint16 x_values_start;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
186 uint16 x_values_increment;
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 int gd_left, gd_top; ///< Where to start drawing the graph, in pixels.
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
189 uint gd_height; ///< The height of the graph in pixels.
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
190 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
191 byte colours[GRAPH_MAX_DATASETS];
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
192 OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
193
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
194 void DrawGraph() const
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
195 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
196 uint x, y; ///< Reused whenever x and y coordinates are needed.
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
197 OverflowSafeInt64 highest_value; ///< Highest value to be drawn.
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
198 int x_axis_offset; ///< Distance from the top of the graph to the x axis.
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
199
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
200 /* the colours and cost array of GraphDrawer must accomodate
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
201 * both values for cargo and companies. So if any are higher, quit */
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
202 assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_COMPANIES);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
203 assert(this->num_vert_lines > 0);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
204
9850
00c8758ef6b8 (svn r13994) -Codechange: replace a few rogue magic numbers with Colours enum values
belugas <belugas@openttd.org>
parents: 9748
diff changeset
205 byte grid_colour = _colour_gradient[COLOUR_GREY][4];
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 /* The coordinates of the opposite edges of the graph. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
208 int bottom = this->gd_top + this->gd_height - 1;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
209 int right = this->gd_left + GRAPH_X_POSITION_BEGINNING + this->num_vert_lines * GRAPH_X_POSITION_SEPARATION - 1;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
210
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
211 /* Draw the vertical grid lines. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
212
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
213 /* Don't draw the first line, as that's where the axis will be. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
214 x = this->gd_left + GRAPH_X_POSITION_BEGINNING + GRAPH_X_POSITION_SEPARATION;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
215
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
216 for (int i = 0; i < this->num_vert_lines; i++) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
217 GfxFillRect(x, this->gd_top, x, bottom, grid_colour);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
218 x += GRAPH_X_POSITION_SEPARATION;
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 /* Draw the horizontal grid lines. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
222 x = this->gd_left + GRAPH_X_POSITION_BEGINNING;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
223 y = this->gd_height + this->gd_top;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
224
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
225 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
226 GfxFillRect(x, y, right, y, grid_colour);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
227 y -= (this->gd_height / (GRAPH_NUM_LINES_Y - 1));
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
228 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
229
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
230 /* Draw the y axis. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
231 GfxFillRect(x, this->gd_top, x, bottom, GRAPH_AXIS_LINE_COLOUR);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
232
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
233 /* Find the distance from the gd_top of the graph to the x axis. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
234 x_axis_offset = this->gd_height;
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 /* The graph is currently symmetrical about the x axis. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
237 if (this->has_negative_values) x_axis_offset /= 2;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
238
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
239 /* Draw the x axis. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
240 y = x_axis_offset + this->gd_top;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
241 GfxFillRect(x, y, right, y, GRAPH_AXIS_LINE_COLOUR);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
242
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
243 /* Find the largest value that will be drawn. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
244 if (this->num_on_x_axis == 0)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
245 return;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
246
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
247 assert(this->num_on_x_axis > 0);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
248 assert(this->num_dataset > 0);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
249
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
250 /* Start of with a value of twice the gd_height of the graph in pixels. It's a
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
251 * bit arbitrary, but it makes the cargo payment graph look a little nicer,
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
252 * and prevents division by zero when calculating where the datapoint
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
253 * should be drawn. */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
254 highest_value = x_axis_offset * 2;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
255
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
256 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
257 if (!HasBit(this->excluded_data, i)) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
258 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
259 OverflowSafeInt64 datapoint = this->cost[i][j];
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
260
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
261 if (datapoint != INVALID_DATAPOINT) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
262 /* 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
263 * 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
264 * of each data point. */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
265 highest_value = max(highest_value, abs(datapoint));
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
266 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
267 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
268 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
269 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
270
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
271 /* 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
272 * axis labels used. */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
273 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
274 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
275
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
276 /* draw text strings on the y axis */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
277 int64 y_label = highest_value;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
278 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
279
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
280 /* 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
281 * -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
282 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
283
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
284 x = this->gd_left + GRAPH_X_POSITION_BEGINNING + 1;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
285 y = this->gd_top - 3;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
286
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
287 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
288 SetDParam(0, this->format_str_y_axis);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
289 SetDParam(1, y_label);
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
290 DrawString(x - GRAPH_X_POSITION_BEGINNING, x, y, STR_GRAPH_Y_LABEL, graph_axis_label_colour, SA_RIGHT);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
291
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
292 y_label -= y_label_separation;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
293 y += (this->gd_height / (GRAPH_NUM_LINES_Y - 1));
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
294 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
295
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
296 /* draw strings on the x axis */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
297 if (this->month != 0xFF) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
298 x = this->gd_left + GRAPH_X_POSITION_BEGINNING;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
299 y = this->gd_top + this->gd_height + 1;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
300 byte month = this->month;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
301 Year year = this->year;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
302 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
303 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
304 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
305 SetDParam(2, year);
11767
50309ee29ef8 (svn r16157) -Fix: wrong truncation of refit cost/graph x labels because they were multiline strings being drawn using DrawString instead of DrawStringMultiLine.
rubidium <rubidium@openttd.org>
parents: 11751
diff changeset
306 DrawStringMultiLine(x, x + GRAPH_X_POSITION_SEPARATION, 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
307
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
308 month += 3;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
309 if (month >= 12) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
310 month = 0;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
311 year++;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
312 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
313 x += GRAPH_X_POSITION_SEPARATION;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
314 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
315 } else {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
316 /* Draw the label under the data point rather than on the grid line. */
11432
a20dd0000d96 (svn r15790) -Codechange: remove the *Centered part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11373
diff changeset
317 x = this->gd_left + GRAPH_X_POSITION_BEGINNING;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
318 y = this->gd_top + this->gd_height + 1;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
319 uint16 label = this->x_values_start;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
320
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
321 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
322 SetDParam(0, label);
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
323 DrawString(x + 1, x + GRAPH_X_POSITION_SEPARATION - 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
324
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
325 label += this->x_values_increment;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
326 x += GRAPH_X_POSITION_SEPARATION;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
327 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
328 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
329
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
330 /* draw lines and dots */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
331 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
332 if (!HasBit(this->excluded_data, i)) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
333 /* Centre the dot between the grid lines. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
334 x = this->gd_left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
335
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
336 byte colour = this->colours[i];
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
337 uint prev_x = INVALID_DATAPOINT_POS;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
338 uint prev_y = INVALID_DATAPOINT_POS;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
339
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
340 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
341 OverflowSafeInt64 datapoint = this->cost[i][j];
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
342
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
343 if (datapoint != INVALID_DATAPOINT) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
344 /*
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
345 * 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
346 * 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
347 * 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
348 * 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
349 * significant bits can just be removed.
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
350 *
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
351 * 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
352 * 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
353 * least significant bits are removed.
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
354 */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
355 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
356 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
357
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
358 /* 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
359 if (datapoint < 0) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
360 datapoint = -(abs(datapoint) >> reduce_range);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
361 } else {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
362 datapoint >>= reduce_range;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
363 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
364
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
365 y = this->gd_top + x_axis_offset - (x_axis_offset * datapoint) / (highest_value >> reduce_range);
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 /* 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
368 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
369
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
370 /* 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
371 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
372
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
373 prev_x = x;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
374 prev_y = y;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
375 } else {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
376 prev_x = INVALID_DATAPOINT_POS;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
377 prev_y = INVALID_DATAPOINT_POS;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
378 }
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 x += GRAPH_X_POSITION_SEPARATION;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
381 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
382 }
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 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
385
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
386
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
387 BaseGraphWindow(const WindowDesc *desc, WindowNumber window_number, int left,
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
388 int top, int height, bool has_negative_values, StringID format_str_y_axis) :
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
389 Window(desc, window_number), has_negative_values(has_negative_values),
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
390 gd_left(left), gd_top(top), gd_height(height), format_str_y_axis(format_str_y_axis)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
391 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
392 InvalidateWindow(WC_GRAPH_LEGEND, 0);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
393 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
394
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
395 public:
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
396 virtual void OnPaint()
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
397 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
398 this->DrawWidgets();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
399
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
400 uint excluded_companies = _legend_excluded_companies;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
401
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
402 /* 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
403 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
404 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
405 }
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
406 this->excluded_data = excluded_companies;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
407 this->num_vert_lines = 24;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
408
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
409 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
410 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
411 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
412 nums = 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
413 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
414 this->num_on_x_axis = min(nums, 24);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
415
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
416 int mo = (_cur_month / 3 - nums) * 3;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
417 int yr = _cur_year;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
418 while (mo < 0) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
419 yr--;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
420 mo += 12;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
421 }
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 this->year = yr;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
424 this->month = mo;
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 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
427 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
428 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
429 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
430 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
431 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
432 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
433 i++;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
434 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
435 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
436 numd++;
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
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
439 this->num_dataset = numd;
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 this->DrawGraph();
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
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
444 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
445 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
446 return INVALID_DATAPOINT;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
447 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
448
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
449 virtual void OnClick(Point pt, int widget)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
450 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
451 /* Clicked on legend? */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
452 if (widget == 2) ShowGraphLegend();
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 };
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
455
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
456 /** Widget numbers of a base graph window. */
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
457 enum CompanyValueWidgets {
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
458 BGW_CLOSEBOX,
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
459 BGW_CAPTION,
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
460 BGW_KEY_BUTTON,
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
461 BGW_BACKGROUND,
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
462 };
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
463
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
464
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
465 /********************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
466 /* 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
467 /********************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
468
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
469 struct OperatingProfitGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
470 OperatingProfitGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
471 BaseGraphWindow(desc, window_number, 2, 18, 136, true, STR_CURRCOMPACT)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
472 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
473 this->FindWindowPlacementAndResize(desc);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
474 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
475
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
476 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
477 {
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
478 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
479 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
480 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
481
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
482 static const Widget _operating_profit_widgets[] = {
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
483 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW},
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
484 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 525, 0, 13, STR_GRAPH_OPERATING_PROFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},
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
485 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 526, 575, 0, 13, STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP},
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
486 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 575, 14, 173, 0x0, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
487 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
488 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
489
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
490 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
491 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
492 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
493 NWidget(WWT_CAPTION, COLOUR_GREY, BGW_CAPTION), SetDataTip(STR_GRAPH_OPERATING_PROFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
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
494 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, BGW_KEY_BUTTON), SetMinimalSize(50, 14), 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
495 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
496 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
497 };
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
498
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
499 static const WindowDesc _operating_profit_desc(
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
500 WDP_AUTO, WDP_AUTO, 576, 174, 576, 174,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
501 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
502 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
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
503 _operating_profit_widgets, _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
504 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
505
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
506
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
507 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
508 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
509 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
510 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
511
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
512
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
513 /****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
514 /* 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
515 /****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
516
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
517 struct IncomeGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
518 IncomeGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
519 BaseGraphWindow(desc, window_number, 2, 18, 104, false, STR_CURRCOMPACT)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
520 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
521 this->FindWindowPlacementAndResize(desc);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
522 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
523
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
524 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
525 {
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
526 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
527 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
528 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
529
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
530 static const Widget _income_graph_widgets[] = {
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
531 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW},
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
532 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 525, 0, 13, STR_GRAPH_INCOME_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},
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
533 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 526, 575, 0, 13, STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP},
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
534 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 575, 14, 141, 0x0, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
535 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
536 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
537
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
538 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
539 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
540 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
541 NWidget(WWT_CAPTION, COLOUR_GREY, BGW_CAPTION), SetDataTip(STR_GRAPH_INCOME_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
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
542 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, BGW_KEY_BUTTON), SetMinimalSize(50, 14), 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
543 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
544 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
545 };
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
546
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
547
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
548 static const WindowDesc _income_graph_desc(
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
549 WDP_AUTO, WDP_AUTO, 576, 142, 576, 142,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
550 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
551 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
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
552 _income_graph_widgets, _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
553 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
554
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
555 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
556 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
557 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
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
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
560 /*******************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
561 /* 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
562 /*******************/
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 struct DeliveredCargoGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
565 DeliveredCargoGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
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
566 BaseGraphWindow(desc, window_number, 2, 18, 104, false, STR_JUST_COMMA)
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
567 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
568 this->FindWindowPlacementAndResize(desc);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
569 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
570
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
571 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
572 {
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
573 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
574 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
575 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
576
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
577 static const Widget _delivered_cargo_graph_widgets[] = {
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
578 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW},
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
579 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 525, 0, 13, STR_GRAPH_CARGO_DELIVERED_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},
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
580 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 526, 575, 0, 13, STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP},
9748
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
581 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 575, 14, 141, 0x0, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
582 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
583 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
584
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
585 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
586 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
587 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
588 NWidget(WWT_CAPTION, COLOUR_GREY, BGW_CAPTION), SetDataTip(STR_GRAPH_CARGO_DELIVERED_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
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
589 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, BGW_KEY_BUTTON), SetMinimalSize(50, 14), 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
590 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
591 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
592 };
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
593
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
594 static const WindowDesc _delivered_cargo_graph_desc(
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
595 WDP_AUTO, WDP_AUTO, 576, 142, 576, 142,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
596 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
597 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
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
598 _delivered_cargo_graph_widgets, _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
599 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
600
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
601 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
602 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
603 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
604 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
605
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
606 /***********************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
607 /* 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
608 /***********************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
609
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
610 /** 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
611 enum PerformanceHistoryGraphWidgets {
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
612 PHW_CLOSEBOX,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
613 PHW_CAPTION,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
614 PHW_KEY,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
615 PHW_DETAILED_PERFORMANCE,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
616 PHW_BACKGROUND,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
617 };
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
618
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
619 struct PerformanceHistoryGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
620 PerformanceHistoryGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
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
621 BaseGraphWindow(desc, window_number, 2, 18, 200, false, STR_JUST_COMMA)
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
622 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
623 this->FindWindowPlacementAndResize(desc);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
624 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
625
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
626 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
627 {
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
628 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
629 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
630
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
631 virtual void OnClick(Point pt, int widget)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
632 {
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
633 if (widget == PHW_DETAILED_PERFORMANCE) ShowPerformanceRatingDetail();
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
634 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
635 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
636 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
637
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
638 static const Widget _performance_history_widgets[] = {
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
639 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW}, // PHW_CLOSEBOX
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
640 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 475, 0, 13, STR_GRAPH_COMPANY_PERFORMANCE_RATINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS}, // PHW_CAPTION
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
641 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 526, 575, 0, 13, STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP}, // PHW_KEY
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
642 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 476, 525, 0, 13, STR_PERFORMANCE_DETAIL_KEY, STR_SHOW_DETAILED_PERFORMANCE_RATINGS}, // PHW_DETAILED_PERFORMANCE
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
643 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 575, 14, 237, 0x0, STR_NULL}, // PHW_BACKGROUND
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 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
645 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
646
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
647 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
648 NWidget(NWID_HORIZONTAL),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
649 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
650 NWidget(WWT_CAPTION, COLOUR_GREY, PHW_CAPTION), SetDataTip(STR_GRAPH_COMPANY_PERFORMANCE_RATINGS_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
651 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, PHW_DETAILED_PERFORMANCE), SetMinimalSize(50, 14), SetDataTip(STR_PERFORMANCE_DETAIL_KEY, STR_SHOW_DETAILED_PERFORMANCE_RATINGS),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
652 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, PHW_KEY), SetMinimalSize(50, 14), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
653 EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
654 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
655 };
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
656
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
657 static const WindowDesc _performance_history_desc(
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
658 WDP_AUTO, WDP_AUTO, 576, 238, 576, 238,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
659 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
660 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
661 _performance_history_widgets, _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
662 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
663
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
664 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
665 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
666 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
667 }
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 /*****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
670 /* 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
671 /*****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
672
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
673 struct CompanyValueGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
674 CompanyValueGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
675 BaseGraphWindow(desc, window_number, 2, 18, 200, false, STR_CURRCOMPACT)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
676 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
677 this->FindWindowPlacementAndResize(desc);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
678 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
679
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
680 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
681 {
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
682 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
683 }
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
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
686 static const Widget _company_value_graph_widgets[] = {
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
687 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW},
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
688 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 525, 0, 13, STR_GRAPH_COMPANY_VALUES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},
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
689 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 526, 575, 0, 13, STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP},
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
690 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 575, 14, 237, 0x0, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
691 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
692 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
693
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
694 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
695 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
696 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
697 NWidget(WWT_CAPTION, COLOUR_GREY, BGW_CAPTION), SetDataTip(STR_GRAPH_COMPANY_VALUES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
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
698 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, BGW_KEY_BUTTON), SetMinimalSize(50, 14), 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
699 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
700 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
701 };
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
702
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
703 static const WindowDesc _company_value_graph_desc(
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
704 WDP_AUTO, WDP_AUTO, 576, 238, 576, 238,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
705 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
706 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
11582
a72797507693 (svn r15952) -Codechange: Added nested widgets to operating profit, income, delivered cargo, and company value windows.
alberth <alberth@openttd.org>
parents: 11574
diff changeset
707 _company_value_graph_widgets, _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
708 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
709
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
710 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
711 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
712 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
713 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
714
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
715 /*****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
716 /* 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
717 /*****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
718
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
719 struct PaymentRatesGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
720 PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
721 BaseGraphWindow(desc, window_number, 2, 24, 200, false, STR_CURRCOMPACT)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
722 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
723 uint num_active = 0;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
724 for (CargoID c = 0; c < NUM_CARGO; c++) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
725 if (GetCargo(c)->IsValid()) num_active++;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
726 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
727
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
728 /* Resize the window to fit the cargo types */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
729 ResizeWindow(this, 0, max(num_active, 12U) * 8);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
730
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
731 /* Add widgets for each cargo type */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
732 this->widget_count += num_active;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
733 this->widget = ReallocT(this->widget, this->widget_count + 1);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
734 this->widget[this->widget_count].type = WWT_LAST;
6192
44da08e7d3d1 (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138 <peter1138@openttd.org>
parents: 6179
diff changeset
735
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
736 /* Set the properties of each widget */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
737 for (uint i = 0; i != num_active; i++) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
738 Widget *wi = &this->widget[3 + i];
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
739 wi->type = WWT_PANEL;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
740 wi->display_flags = RESIZE_NONE;
11080
02d314ea4f63 (svn r15423) -Codechange: split widget related types to their own header and add a bit of type strictness.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
741 wi->colour = COLOUR_ORANGE;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
742 wi->left = 493;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
743 wi->right = 562;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
744 wi->top = 24 + i * 8;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
745 wi->bottom = wi->top + 7;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
746 wi->data = 0;
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
747 wi->tooltips = STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO;
6192
44da08e7d3d1 (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138 <peter1138@openttd.org>
parents: 6179
diff changeset
748
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
749 if (!HasBit(_legend_excluded_cargo, i)) this->LowerWidget(i + 3);
6203
60d5fce9d6b0 (svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents: 6192
diff changeset
750 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
751
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
752 this->SetDirty();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
753
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
754 this->gd_height = this->height - 38;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
755 this->num_on_x_axis = 20;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
756 this->num_vert_lines = 20;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
757 this->month = 0xFF;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
758 this->x_values_start = 10;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
759 this->x_values_increment = 10;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
760
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
761 this->FindWindowPlacementAndResize(desc);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
762 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
763
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
764 virtual void OnPaint()
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
765 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
766 this->DrawWidgets();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
767
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
768 this->excluded_data = _legend_excluded_cargo;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
769
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
770 int x = 495;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
771 int y = 24;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
772
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
773 uint i = 0;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
774 for (CargoID c = 0; c < NUM_CARGO; c++) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
775 const CargoSpec *cs = GetCargo(c);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
776 if (!cs->IsValid()) continue;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
777
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
778 /* Only draw labels for widgets that exist. If the widget doesn't
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
779 * exist then the local company has used the climate cheat or
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
780 * changed the NewGRF configuration with this window open. */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
781 if (i + 3 < this->widget_count) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
782 /* Since the buttons have no text, no images,
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
783 * both the text and the coloured box have to be manually painted.
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
784 * clk_dif will move one pixel down and one pixel to the right
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
785 * when the button is clicked */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
786 byte clk_dif = this->IsWidgetLowered(i + 3) ? 1 : 0;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
787
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
788 GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
789 GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
790 SetDParam(0, cs->name);
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11767
diff changeset
791 DrawString(x + 14 + clk_dif, this->width, y + clk_dif, STR_GRAPH_CARGO_PAYMENT_CARGO);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
792 y += 8;
6203
60d5fce9d6b0 (svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents: 6192
diff changeset
793 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
794
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
795 this->colours[i] = cs->legend_colour;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
796 for (uint j = 0; j != 20; j++) {
10054
fe831433ff7a (svn r14219) -Fix (rthebeginning): 10 days != 6*2.5 days, effectively causing the payment graph to show the wrong data.
rubidium <rubidium@openttd.org>
parents: 9865
diff changeset
797 this->cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 4 + 4, c);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
798 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
799
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
800 i++;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
801 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
802 this->num_dataset = i;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
803
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
804 this->DrawGraph();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
805
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11767
diff changeset
806 DrawString(2 + 46, this->width, 24 + this->gd_height + 7, STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL);
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11767
diff changeset
807 DrawString(2 + 84, this->width, 24 - 9, STR_GRAPH_CARGO_PAYMENT_RATES_TITLE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
808 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
809
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
810 virtual void OnClick(Point pt, int widget)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
811 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
812 if (widget >= 3) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
813 ToggleBit(_legend_excluded_cargo, widget - 3);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
814 this->ToggleWidgetLoweredState(widget);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
815 this->SetDirty();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
816 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
817 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
818 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
819
11621
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
820 /** Widget numbers of the cargo payment rates. */
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
821 enum CargoPaymentRatesWidgets {
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
822 CPW_CLOSEBOX,
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
823 CPW_CAPTION,
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
824 CPW_BACKGROUND,
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
825 };
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
826
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
827 static const Widget _cargo_payment_rates_widgets[] = {
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
828 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW},
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
829 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 567, 0, 13, STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},
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
830 { WWT_PANEL, RESIZE_BOTTOM, COLOUR_GREY, 0, 567, 14, 45, 0x0, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
831 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
832 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
833
11621
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
834 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
835 NWidget(NWID_HORIZONTAL),
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
836 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
837 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
838 EndContainer(),
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
839 NWidget(WWT_PANEL, COLOUR_GREY, CPW_BACKGROUND), SetMinimalSize(568, 32), SetResize(0, 1), EndContainer(),
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
840 };
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
841
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
842 static const WindowDesc _cargo_payment_rates_desc(
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
843 WDP_AUTO, WDP_AUTO, 568, 46, 568, 46,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
844 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
845 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
11621
cee8c1f807ea (svn r16001) -Codechange: Added nested widgets to cargo payment rates window
alberth <alberth@openttd.org>
parents: 11582
diff changeset
846 _cargo_payment_rates_widgets, _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
847 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
848
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
849
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
850 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
851 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
852 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
853 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
854
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
855 /************************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
856 /* 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
857 /************************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
858
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
859 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
860 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
861 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
862 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
863 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
864 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
865 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
866 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
867 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
868 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
869 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
870 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
871 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
872 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
873 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
874 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
875 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
876 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
877
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
878 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
879 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
880 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
881 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
882
9525
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
883 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
884 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
885 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
886
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
887 /**
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
888 * (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
889 */
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
890 void BuildCompanyList()
9525
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
891 {
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
892 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
893
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
894 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
895
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
896 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
897 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
898 *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
899 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
900
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
901 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
902 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
903 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
904
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
905 /** Sort the company league by performance history */
10647
592ae9307430 (svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents: 10480
diff changeset
906 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
907 {
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
908 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
909 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
910
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
911 public:
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
912 CompanyLeagueWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
c052caf473db (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
913 {
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
914 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
915 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
916
9333
5236ba6c7d54 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138 <peter1138@openttd.org>
parents: 9317
diff changeset
917 this->FindWindowPlacementAndResize(desc);
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
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
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
920 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
921 {
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
922 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
923 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
924
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
925 this->DrawWidgets();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
926
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
927 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
928 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
929 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
930 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
931 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
932 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
933
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11767
diff changeset
934 DrawString(2, this->width, 15 + i * 10, i == 0 ? STR_COMPANY_LEAGUE_FIRST : STR_COMPANY_LEAGUE_OTHER);
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
935 DrawCompanyIcon(c->index, 27, 16 + i * 10);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
936 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
937 }
9525
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
938
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
939 virtual void OnTick()
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
940 {
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
941 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
942 this->SetDirty();
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
943 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
944 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
945
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
946 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
947 {
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
948 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
949 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
950 } 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
951 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
952 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
953 }
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
954 };
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
11622
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
956 /** Widget numbers for the company league window. */
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
957 enum CompanyLeagueWidgets {
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
958 CLW_CLOSEBOX,
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
959 CLW_CAPTION,
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
960 CLW_STICKYBOX,
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
961 CLW_BACKGROUND,
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
962 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
963
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
964 static const Widget _company_league_widgets[] = {
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
965 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW},
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
966 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 387, 0, 13, STR_COMPANY_LEAGUE_TABLE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},
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
967 { WWT_STICKYBOX, RESIZE_NONE, COLOUR_GREY, 388, 399, 0, 13, STR_NULL, STR_STICKY_BUTTON},
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
968 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 399, 14, 166, 0x0, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
969 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
970 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
971
11622
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
972 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
973 NWidget(NWID_HORIZONTAL),
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
974 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
975 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
976 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
977 EndContainer(),
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
978 NWidget(WWT_PANEL, COLOUR_GREY, CLW_BACKGROUND), SetMinimalSize(400, 153),
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
979 };
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
980
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
981 static const WindowDesc _company_league_desc(
10480
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
982 WDP_AUTO, WDP_AUTO, 400, 167, 400, 167,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
983 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
984 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
11622
6782ab076a1e (svn r16002) -Codechange: Added nested widgets for company league window
alberth <alberth@openttd.org>
parents: 11621
diff changeset
985 _company_league_widgets, _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
986 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
987
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
988 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
989 {
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
990 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
991 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
992
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
993 /*****************************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
994 /* 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
995 /*****************************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
996
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
997 /** 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
998 enum PerformanceRatingDetailsWidgets {
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
999 PRW_CLOSEBOX,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1000 PRW_CAPTION,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1001 PRW_BACKGROUND,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1002
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1003 PRW_SCORE_FIRST,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1004 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
1005
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1006 PRW_COMPANY_FIRST,
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1007 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
1008 };
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1009
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1010 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
1011 static CompanyID company;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1012 int timeout;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1013
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1014 PerformanceRatingDetailWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1015 {
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
1016 /* Disable the companies who are not active */
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
1017 for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
1018 this->SetWidgetDisabledState(i + PRW_COMPANY_FIRST, !Company::IsValidID(i));
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1019 }
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1020
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
1021 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
1022
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
1023 if (company != INVALID_COMPANY) this->LowerWidget(company + PRW_COMPANY_FIRST);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
1024
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
1025 this->FindWindowPlacementAndResize(desc);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1026 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1027
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
1028 void UpdateCompanyStats()
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1029 {
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
1030 /* 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
1031 * (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
1032 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
1033 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
1034 UpdateCompanyRatingAndValue(c, false);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1035 }
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1036
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1037 this->timeout = DAY_TICKS * 5;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1038
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
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
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1041 virtual void OnPaint()
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1042 {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1043 byte x;
10480
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
1044 uint16 y = 27;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1045 int total_score = 0;
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
1046 int colour_done, colour_notdone;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1047
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1048 /* 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
1049 this->DrawWidgets();
5946
1dc5b0b8fe69 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents: 5893
diff changeset
1050
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
1051 /* Check if the currently selected company is still active. */
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
1052 if (company == INVALID_COMPANY || !Company::IsValidID(company)) {
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
1053 if (company != INVALID_COMPANY) {
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1054 /* Raise and disable the widget for the previous selection. */
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
1055 this->RaiseWidget(company + PRW_COMPANY_FIRST);
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
1056 this->DisableWidget(company + PRW_COMPANY_FIRST);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1057 this->SetDirty();
5946
1dc5b0b8fe69 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents: 5893
diff changeset
1058
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
1059 company = INVALID_COMPANY;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1060 }
5946
1dc5b0b8fe69 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents: 5893
diff changeset
1061
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
1062 for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
1063 if (Company::IsValidID(i)) {
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
1064 /* Lower the widget corresponding to this company. */
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
1065 this->LowerWidget(i + PRW_COMPANY_FIRST);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1066 this->SetDirty();
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1067
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
1068 company = i;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1069 break;
5946
1dc5b0b8fe69 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents: 5893
diff changeset
1070 }
1dc5b0b8fe69 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents: 5893
diff changeset
1071 }
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1072 }
5946
1dc5b0b8fe69 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents: 5893
diff changeset
1073
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
1074 /* If there are no active companies, don't display anything else. */
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
1075 if (company == INVALID_COMPANY) return;
5946
1dc5b0b8fe69 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents: 5893
diff changeset
1076
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
1077 /* Paint the company icons */
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
1078 for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
1079 if (!Company::IsValidID(i)) {
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 /* Check if we have the company as an active company */
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
1081 if (!this->IsWidgetDisabled(i + PRW_COMPANY_FIRST)) {
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
1082 /* Bah, company gone :( */
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
1083 this->DisableWidget(i + PRW_COMPANY_FIRST);
5946
1dc5b0b8fe69 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents: 5893
diff changeset
1084
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1085 /* We need a repaint */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1086 this->SetDirty();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1087 }
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1088 continue;
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 /* Check if we have the company marked as inactive */
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
1092 if (this->IsWidgetDisabled(i + PRW_COMPANY_FIRST)) {
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 /* New company! Yippie :p */
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
1094 this->EnableWidget(i + PRW_COMPANY_FIRST);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1095 /* We need a repaint */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1096 this->SetDirty();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1097 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1098
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
1099 x = (i == company) ? 1 : 0;
10480
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
1100 DrawCompanyIcon(i, (i % 8) * 37 + 13 + x, (i < 8 ? 0 : 13) + 16 + x);
9255
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
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
1103 /* The colours used to show how the progress is going */
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
1104 colour_done = _colour_gradient[COLOUR_GREEN][4];
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
1105 colour_notdone = _colour_gradient[COLOUR_RED][4];
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1106
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1107 /* Draw all the score parts */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1108 for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) {
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
1109 int val = _score_part[company][i];
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1110 int needed = _score_info[i].needed;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1111 int score = _score_info[i].score;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1112
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1113 y += 20;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1114 /* SCORE_TOTAL has his own rulez ;) */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1115 if (i == SCORE_TOTAL) {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1116 needed = total_score;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1117 score = SCORE_MAX;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1118 } else {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1119 total_score += score;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1120 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1121
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11767
diff changeset
1122 DrawString(7, 107, y, STR_PERFORMANCE_DETAIL_VEHICLES + i);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1123
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1124 /* Draw the score */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1125 SetDParam(0, score);
11454
9bfb4cdd8e22 (svn r15812) -Codechange: use the new DrawString API in another set of GUIs
rubidium <rubidium@openttd.org>
parents: 11433
diff changeset
1126 DrawString(7, 107, y, STR_PERFORMANCE_DETAIL_INT, TC_FROMSTRING, SA_RIGHT);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1127
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1128 /* Calculate the %-bar */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1129 x = Clamp(val, 0, needed) * 50 / needed;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1130
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1131 /* SCORE_LOAN is inversed */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1132 if (val < 0 && i == SCORE_LOAN) x = 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
1133
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1134 /* Draw the bar */
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
1135 if (x != 0) GfxFillRect(112, y - 2, 112 + x, y + 10, colour_done);
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
1136 if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, colour_notdone);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1137
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1138 /* Calculate the % */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1139 x = Clamp(val, 0, needed) * 100 / needed;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1140
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1141 /* SCORE_LOAN is inversed */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1142 if (val < 0 && i == SCORE_LOAN) x = 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
1143
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1144 /* Draw it */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1145 SetDParam(0, x);
11432
a20dd0000d96 (svn r15790) -Codechange: remove the *Centered part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11373
diff changeset
1146 DrawString(112, 162, y, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING, SA_CENTER);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1147
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1148 /* SCORE_LOAN is inversed */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1149 if (i == SCORE_LOAN) val = needed - val;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1150
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1151 /* Draw the amount we have against what is needed
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11111
diff changeset
1152 * For some of them it is in currency format */
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1153 SetDParam(0, val);
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1154 SetDParam(1, needed);
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1155 switch (i) {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1156 case SCORE_MIN_PROFIT:
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1157 case SCORE_MIN_INCOME:
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1158 case SCORE_MAX_INCOME:
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1159 case SCORE_MONEY:
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1160 case SCORE_LOAN:
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11767
diff changeset
1161 DrawString(167, this->width, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1162 break;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1163 default:
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11767
diff changeset
1164 DrawString(167, this->width, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1165 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1166 }
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1167 }
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
1168
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1169 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
1170 {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1171 /* 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
1172 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
1173 /* Is it no on disable? */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1174 if (!this->IsWidgetDisabled(widget)) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10054
diff changeset
1175 this->RaiseWidget(company + PRW_COMPANY_FIRST);
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10054
diff changeset
1176 company = (CompanyID)(widget - PRW_COMPANY_FIRST);
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10054
diff changeset
1177 this->LowerWidget(company + PRW_COMPANY_FIRST);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1178 this->SetDirty();
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1179 }
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1180 }
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1181 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1182
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1183 virtual void OnTick()
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1184 {
11852
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11770
diff changeset
1185 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
1186
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
1187 /* 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
1188 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
1189 this->UpdateCompanyStats();
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1190 this->SetDirty();
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1191 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1192 }
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1193 };
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1194
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
1195 CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1196
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1197 /** Make a vertical list of panels for outputting score details. */
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1198 static NWidgetBase *MakePerformanceDetailPanels()
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1199 {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1200 const StringID performance_tips[] = {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1201 STR_PERFORMANCE_DETAIL_VEHICLES_TIP,
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1202 STR_PERFORMANCE_DETAIL_STATIONS_TIP,
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1203 STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP,
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1204 STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP,
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1205 STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP,
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1206 STR_PERFORMANCE_DETAIL_DELIVERED_TIP,
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1207 STR_PERFORMANCE_DETAIL_CARGO_TIP,
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1208 STR_PERFORMANCE_DETAIL_MONEY_TIP,
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1209 STR_PERFORMANCE_DETAIL_LOAN_TIP,
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1210 STR_PERFORMANCE_DETAIL_TOTAL_TIP,
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1211 };
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1212
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1213 assert(lengthof(performance_tips) == SCORE_END - SCORE_BEGIN);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1214
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1215 NWidgetVertical *vert = new NWidgetVertical();
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1216 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
1217 NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1218 panel->SetMinimalSize(299, 20);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1219 panel->SetFill(false, false);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1220 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
1221 vert->Add(panel);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1222 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1223 return vert;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1224 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1225
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1226 /** Make a number of rows with button-like graphics, for enabling/disabling each company. */
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1227 static NWidgetBase *MakeCompanyButtonRows()
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1228 {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1229 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
1230 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
1231 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
1232 int hor_length = 0;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1233
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1234 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
1235 /* 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
1236 if (hor_length == MAX_LENGTH) {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1237 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
1238 vert->Add(hor);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1239 hor = NULL;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1240 hor_length = 0;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1241 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1242 if (hor == NULL) {
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1243 hor = new NWidgetHorizontal();
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1244 hor_length = 0;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1245 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1246
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1247 NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1248 panel->SetMinimalSize(37, 13);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1249 panel->SetFill(false, false);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1250 panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1251 hor->Add(panel);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1252 hor_length++;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1253 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1254 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
1255
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1256 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
1257 /* 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
1258 NWidgetSpacer *spc = new NWidgetSpacer(0, 0);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1259 spc->SetFill(true, false);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1260 hor->Add(spc);
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1261 }
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1262 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
1263 return vert;
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1264 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1265
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1266 static const Widget _performance_rating_detail_widgets[] = {
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1267 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW}, // PRW_CLOSEBOX
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1268 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 298, 0, 13, STR_PERFORMANCE_DETAIL, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS}, // PRW_CAPTION
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1269 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 14, 40, 0x0, STR_NULL}, // PRW_BACKGROUND
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1270
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1271 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 41, 60, 0x0, STR_PERFORMANCE_DETAIL_VEHICLES_TIP}, // PRW_SCORE_FIRST
10480
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
1272 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 61, 80, 0x0, STR_PERFORMANCE_DETAIL_STATIONS_TIP},
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
1273 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 81, 100, 0x0, STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP},
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
1274 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 101, 120, 0x0, STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP},
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
1275 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 121, 140, 0x0, STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP},
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
1276 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 141, 160, 0x0, STR_PERFORMANCE_DETAIL_DELIVERED_TIP},
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
1277 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 161, 180, 0x0, STR_PERFORMANCE_DETAIL_CARGO_TIP},
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
1278 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 181, 200, 0x0, STR_PERFORMANCE_DETAIL_MONEY_TIP},
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
1279 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 201, 220, 0x0, STR_PERFORMANCE_DETAIL_LOAN_TIP},
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1280 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 221, 240, 0x0, STR_PERFORMANCE_DETAIL_TOTAL_TIP}, // PRW_SCORE_LAST
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1281
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1282 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 38, 14, 26, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION}, // PRW_COMPANY_FIRST
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
1283 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 39, 75, 14, 26, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
1284 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 76, 112, 14, 26, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
1285 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 113, 149, 14, 26, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
1286 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 150, 186, 14, 26, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
1287 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 187, 223, 14, 26, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
1288 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 224, 260, 14, 26, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
1289 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 261, 297, 14, 26, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
1290 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 38, 27, 39, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
1291 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 39, 75, 27, 39, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
1292 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 76, 112, 27, 39, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
1293 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 113, 149, 27, 39, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
1294 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 150, 186, 27, 39, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
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
1295 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 187, 223, 27, 39, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION},
11749
31fe7c0637e4 (svn r16139) -Codechange: Adding/completing widget number enums of several graph windows.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
1296 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 224, 260, 27, 39, 0x0, STR_GRAPH_KEY_COMPANY_SELECTION}, // PRW_COMPANY_LAST
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1297 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1298 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1299
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1300 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
1301 NWidget(NWID_HORIZONTAL),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1302 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
1303 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
1304 EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1305 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
1306 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
1307 EndContainer(),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1308 NWidgetFunction(MakePerformanceDetailPanels),
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1309 };
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1310
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
1311 static const WindowDesc _performance_rating_detail_desc(
10480
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10477
diff changeset
1312 WDP_AUTO, WDP_AUTO, 299, 241, 299, 241,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5812
diff changeset
1313 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
1314 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
11751
090ef9105d01 (svn r16141) -Codechange: Adding nested widgets to remaining graph windows.
alberth <alberth@openttd.org>
parents: 11749
diff changeset
1315 _performance_rating_detail_widgets, _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
1316 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1317
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
1318 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
1319 {
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1320 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
1321 }