annotate src/graph_gui.cpp @ 11085:8da1855e9f14 draft

(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
author rubidium <rubidium@openttd.org>
date Mon, 09 Feb 2009 02:57:15 +0000
parents 02d314ea4f63
children 797581aa0b62
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
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
33 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
34 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
35 {
c052caf473db (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
36 for (uint i = 3; i < this->widget_count; 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
37 if (!HasBit(_legend_excluded_companies, i - 3)) 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
38 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
39
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
40 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
41 }
6203
60d5fce9d6b0 (svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents: 6192
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 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
44 {
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
45 for (CompanyID c = COMPANY_FIRST; c < MAX_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
46 if (IsValidCompanyID(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
47
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
48 SetBit(_legend_excluded_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
49 this->RaiseWidget(c + 3);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
50 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
51
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
52 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
53
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
54 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
55 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
56 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
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 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
59 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
60 DrawString(21, 17 + c->index * 12, STR_7021, 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
61 }
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 }
6203
60d5fce9d6b0 (svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents: 6192
diff changeset
63
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
64 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
65 {
10477
20da0dd3f897 (svn r14732) -Codechange: replace some magic number with less magic constants and use the proper type for a few variables.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
66 if (!IsInsideMM(widget, 3, MAX_COMPANIES + 3)) 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
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 ToggleBit(_legend_excluded_companies, widget - 3);
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
69 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
70 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
71 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
72 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
73 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
74 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
75 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
76 }
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 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
78
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
79 static const Widget _graph_legend_widgets[] = {
9748
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
80 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
81 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 249, 0, 13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS},
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
82 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 249, 14, 195, 0x0, STR_NULL},
9748
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
83 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 16, 27, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
84 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 28, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
85 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 40, 51, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
86 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 52, 63, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
87 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 64, 75, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
88 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 76, 87, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
89 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 88, 99, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
90 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 100, 111, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
91 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 112, 123, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
92 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 124, 135, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
93 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 136, 147, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
94 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 148, 159, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
95 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 160, 171, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
96 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 172, 183, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
97 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 184, 195, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_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
98 { 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
99 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
100
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
101 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
102 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
103 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
104 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
105 _graph_legend_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
106 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
107
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
108 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
109 {
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
110 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
111 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
112
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
113 /******************/
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
114 /* BASE OF GRAPHS */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
115 /*****************/
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
116
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
117 struct BaseGraphWindow : Window {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
118 protected:
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
119 enum {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
120 GRAPH_MAX_DATASETS = 32,
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
121 GRAPH_AXIS_LINE_COLOUR = 215,
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
122
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
123 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
124 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
125
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
126 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
127 /* 9 is convenient as that means the distance between them is the gd_height of the graph / 8,
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
128 * which is the same
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
129 * as height >> 3. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
130 };
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
131
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
132 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
133 byte num_dataset;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
134 byte num_on_x_axis;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
135 bool has_negative_values;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
136 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
137 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
138
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
139 /* 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
140 * 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
141 byte month;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
142 Year year;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
143
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
144 /* 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
145 * 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
146 uint16 x_values_start;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
147 uint16 x_values_increment;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
148
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
149 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
150 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
151 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
152 byte colours[GRAPH_MAX_DATASETS];
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
153 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
154
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
155 void DrawGraph() const
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
156 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
157 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
158 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
159 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
160
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
161 /* the colours and cost array of GraphDrawer must accomodate
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
162 * both values for cargo and companies. So if any are higher, quit */
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
163 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
164 assert(this->num_vert_lines > 0);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
165
9850
00c8758ef6b8 (svn r13994) -Codechange: replace a few rogue magic numbers with Colours enum values
belugas <belugas@openttd.org>
parents: 9748
diff changeset
166 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
167
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
168 /* 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
169 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
170 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
171
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
172 /* Draw the vertical grid lines. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
173
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
174 /* 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
175 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
176
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
177 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
178 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
179 x += GRAPH_X_POSITION_SEPARATION;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
180 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
181
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
182 /* Draw the horizontal grid lines. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
183 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
184 y = this->gd_height + this->gd_top;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
185
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
186 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
187 GfxFillRect(x, y, right, y, grid_colour);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
188 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
189 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
190
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
191 /* Draw the y axis. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
192 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
193
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
194 /* 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
195 x_axis_offset = this->gd_height;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
196
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
197 /* 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
198 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
199
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
200 /* Draw the x axis. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
201 y = x_axis_offset + this->gd_top;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
202 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
203
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
204 /* 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
205 if (this->num_on_x_axis == 0)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
206 return;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
207
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
208 assert(this->num_on_x_axis > 0);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
209 assert(this->num_dataset > 0);
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 /* Start of with a value of twice the gd_height of the graph in pixels. It's a
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
212 * bit arbitrary, but it makes the cargo payment graph look a little nicer,
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
213 * and prevents division by zero when calculating where the datapoint
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
214 * should be drawn. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
215 highest_value = x_axis_offset * 2;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
216
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
217 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
218 if (!HasBit(this->excluded_data, i)) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
219 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
220 OverflowSafeInt64 datapoint = this->cost[i][j];
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
221
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
222 if (datapoint != INVALID_DATAPOINT) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
223 /* For now, if the graph has negative values the scaling is
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
224 * symmetrical about the x axis, so take the absolute value
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
225 * of each data point. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
226 highest_value = max(highest_value, abs(datapoint));
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
227 }
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 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
231
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
232 /* Round up highest_value so that it will divide cleanly into the number of
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
233 * axis labels used. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
234 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
235 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
236
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
237 /* draw text strings on the y axis */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
238 int64 y_label = highest_value;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
239 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
240
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
241 /* If there are negative values, the graph goes from highest_value to
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
242 * -highest_value, not highest_value to 0. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
243 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
244
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
245 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
246 y = this->gd_top - 3;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
247
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
248 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
249 SetDParam(0, this->format_str_y_axis);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
250 SetDParam(1, y_label);
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
251 DrawStringRightAligned(x, y, STR_0170, graph_axis_label_colour);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
252
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
253 y_label -= y_label_separation;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
254 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
255 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
256
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
257 /* draw strings on the x axis */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
258 if (this->month != 0xFF) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
259 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
260 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
261 byte month = this->month;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
262 Year year = this->year;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
263 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
264 SetDParam(0, month + STR_0162_JAN);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
265 SetDParam(1, month + STR_0162_JAN + 2);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
266 SetDParam(2, year);
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
267 DrawString(x, y, month == 0 ? STR_016F : STR_016E, graph_axis_label_colour);
9290
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 month += 3;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
270 if (month >= 12) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
271 month = 0;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
272 year++;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
273 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
274 x += GRAPH_X_POSITION_SEPARATION;
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 } else {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
277 /* Draw the label under the data point rather than on the grid line. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
278 x = this->gd_left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2) + 1;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
279 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
280 uint16 label = this->x_values_start;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
281
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
282 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
283 SetDParam(0, label);
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
284 DrawStringCentered(x, y, STR_01CB, graph_axis_label_colour);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
285
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
286 label += this->x_values_increment;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
287 x += GRAPH_X_POSITION_SEPARATION;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
288 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
289 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
291 /* draw lines and dots */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
292 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
293 if (!HasBit(this->excluded_data, i)) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
294 /* Centre the dot between the grid lines. */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
295 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
296
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
297 byte colour = this->colours[i];
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
298 uint prev_x = INVALID_DATAPOINT_POS;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
299 uint prev_y = INVALID_DATAPOINT_POS;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
300
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
301 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
302 OverflowSafeInt64 datapoint = this->cost[i][j];
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
303
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
304 if (datapoint != INVALID_DATAPOINT) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
305 /*
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
306 * Check whether we need to reduce the 'accuracy' of the
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
307 * datapoint value and the highest value to splut overflows.
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
308 * And when 'drawing' 'one million' or 'one million and one'
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
309 * there is no significant difference, so the least
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
310 * significant bits can just be removed.
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
311 *
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
312 * If there are more bits needed than would fit in a 32 bits
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
313 * integer, so at about 31 bits because of the sign bit, the
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
314 * least significant bits are removed.
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
315 */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
316 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
317 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
318
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
319 /* 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
320 if (datapoint < 0) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
321 datapoint = -(abs(datapoint) >> reduce_range);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
322 } else {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
323 datapoint >>= reduce_range;
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
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
326 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
327
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
328 /* 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
329 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
330
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
331 /* 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
332 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
333
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
334 prev_x = x;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
335 prev_y = y;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
336 } else {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
337 prev_x = INVALID_DATAPOINT_POS;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
338 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
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
341 x += GRAPH_X_POSITION_SEPARATION;
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 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
344 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
345 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
346
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
347
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
348 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
349 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
350 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
351 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
352 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
353 InvalidateWindow(WC_GRAPH_LEGEND, 0);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
354 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
355
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
356 public:
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
357 virtual void OnPaint()
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
358 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
359 this->DrawWidgets();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
360
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
361 uint excluded_companies = _legend_excluded_companies;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
362
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
363 /* 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
364 for (CompanyID c = COMPANY_FIRST; c < MAX_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
365 if (!IsValidCompanyID(c)) SetBit(excluded_companies, c);
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
366 }
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
367 this->excluded_data = excluded_companies;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
368 this->num_vert_lines = 24;
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 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
371 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
372 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
373 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
374 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
375 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
376
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
377 int mo = (_cur_month / 3 - nums) * 3;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
378 int yr = _cur_year;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
379 while (mo < 0) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
380 yr--;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
381 mo += 12;
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 this->year = yr;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
385 this->month = mo;
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 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
388 for (CompanyID k = COMPANY_FIRST; k < MAX_COMPANIES; k++) {
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
389 if (IsValidCompanyID(k)) {
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
390 c = GetCompany(k);
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
391 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
392 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
393 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
394 i++;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
395 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
396 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
397 numd++;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
398 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
399
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
400 this->num_dataset = numd;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
401
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
402 this->DrawGraph();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
403 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
404
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
405 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
406 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
407 return INVALID_DATAPOINT;
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
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
410 virtual void OnClick(Point pt, int widget)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
411 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
412 /* Clicked on legend? */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
413 if (widget == 2) ShowGraphLegend();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
414 }
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
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
417 /********************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
418 /* 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
419 /********************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
420
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
421 struct OperatingProfitGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
422 OperatingProfitGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
423 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
424 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
425 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
426 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
427
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
428 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
429 {
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
430 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
431 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
432 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
433
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
434 static const Widget _operating_profit_widgets[] = {
9748
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
435 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
436 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 525, 0, 13, STR_7025_OPERATING_PROFIT_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
437 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
438 { 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
439 { 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
440 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
441
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
442 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
443 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
444 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
445 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
446 _operating_profit_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
447 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
448
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
449
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
450 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
451 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
452 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
453 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
454
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
455
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
456 /****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
457 /* 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
458 /****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
459
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
460 struct IncomeGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
461 IncomeGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
462 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
463 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
464 this->FindWindowPlacementAndResize(desc);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
465 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
466
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
467 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
468 {
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
469 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
470 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
471 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
472
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
473 static const Widget _income_graph_widgets[] = {
9748
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
474 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
475 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 525, 0, 13, STR_7022_INCOME_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
476 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
477 { 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
478 { 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
479 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
480
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
481 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
482 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
483 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
484 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
485 _income_graph_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
486 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
487
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
488 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
489 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
490 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
491 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
492
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
493 /*******************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
494 /* 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
495 /*******************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
496
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
497 struct DeliveredCargoGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
498 DeliveredCargoGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
499 BaseGraphWindow(desc, window_number, 2, 18, 104, false, STR_7024)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
500 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
501 this->FindWindowPlacementAndResize(desc);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
502 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
503
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
504 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
505 {
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
506 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
507 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
508 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
509
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
510 static const Widget _delivered_cargo_graph_widgets[] = {
9748
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
511 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
512 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 525, 0, 13, STR_7050_UNITS_OF_CARGO_DELIVERED, STR_018C_WINDOW_TITLE_DRAG_THIS},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
513 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
514 { 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
515 { 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
516 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
517
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
518 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
519 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
520 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
521 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
522 _delivered_cargo_graph_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
523 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
524
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
525 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
526 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
527 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
528 }
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 /***********************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
531 /* 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
532 /***********************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
533
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
534 struct PerformanceHistoryGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
535 PerformanceHistoryGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
536 BaseGraphWindow(desc, window_number, 2, 18, 200, false, STR_7024)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
537 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
538 this->FindWindowPlacementAndResize(desc);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
539 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
540
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
541 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
542 {
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
543 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
544 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
545
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
546 virtual void OnClick(Point pt, int widget)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
547 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
548 if (widget == 3) ShowPerformanceRatingDetail();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
549 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
550 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
551 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
552
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
553 static const Widget _performance_history_widgets[] = {
9748
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
554 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
555 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 475, 0, 13, STR_7051_COMPANY_PERFORMANCE_RATINGS, STR_018C_WINDOW_TITLE_DRAG_THIS},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
556 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
557 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 476, 525, 0, 13, STR_PERFORMANCE_DETAIL_KEY, STR_704D_SHOW_KEY_TO_GRAPHS},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
558 { 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
559 { 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
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
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
562 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
563 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
564 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
565 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
566 _performance_history_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
567 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
568
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
569 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
570 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
571 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
572 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
573
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
574 /*****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
575 /* 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
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
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
578 struct CompanyValueGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
579 CompanyValueGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
580 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
581 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
582 this->FindWindowPlacementAndResize(desc);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
583 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
584
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
585 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
586 {
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
587 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
588 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
589 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
590
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
591 static const Widget _company_value_graph_widgets[] = {
9748
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
592 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
593 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 525, 0, 13, STR_7052_COMPANY_VALUES, STR_018C_WINDOW_TITLE_DRAG_THIS},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
594 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
595 { 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
596 { 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
597 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
598
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
599 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
600 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
601 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
602 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
603 _company_value_graph_widgets,
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
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
606 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
607 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
608 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
609 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
610
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
611 /*****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
612 /* 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
613 /*****************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
614
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
615 struct PaymentRatesGraphWindow : BaseGraphWindow {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
616 PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
617 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
618 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
619 uint num_active = 0;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
620 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
621 if (GetCargo(c)->IsValid()) num_active++;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
622 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
623
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
624 /* 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
625 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
626
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
627 /* Add widgets for each cargo type */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
628 this->widget_count += num_active;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
629 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
630 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
631
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
632 /* Set the properties of each widget */
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
633 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
634 Widget *wi = &this->widget[3 + i];
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
635 wi->type = WWT_PANEL;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
636 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
637 wi->colour = COLOUR_ORANGE;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
638 wi->left = 493;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
639 wi->right = 562;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
640 wi->top = 24 + i * 8;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
641 wi->bottom = wi->top + 7;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
642 wi->data = 0;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
643 wi->tooltips = STR_7064_TOGGLE_GRAPH_FOR_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
644
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
645 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
646 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
647
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
648 this->SetDirty();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
649
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
650 this->gd_height = this->height - 38;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
651 this->num_on_x_axis = 20;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
652 this->num_vert_lines = 20;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
653 this->month = 0xFF;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
654 this->x_values_start = 10;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
655 this->x_values_increment = 10;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
656
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
657 this->FindWindowPlacementAndResize(desc);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
658 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
659
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
660 virtual void OnPaint()
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
661 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
662 this->DrawWidgets();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
663
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
664 this->excluded_data = _legend_excluded_cargo;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
665
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
666 int x = 495;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
667 int y = 24;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
668
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
669 uint i = 0;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
670 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
671 const CargoSpec *cs = GetCargo(c);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
672 if (!cs->IsValid()) continue;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
673
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
674 /* 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
675 * 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
676 * 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
677 if (i + 3 < this->widget_count) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
678 /* 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
679 * 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
680 * 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
681 * when the button is clicked */
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
682 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
683
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
684 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
685 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
686 SetDParam(0, cs->name);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
687 DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, TC_FROMSTRING);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
688 y += 8;
6203
60d5fce9d6b0 (svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents: 6192
diff changeset
689 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
690
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
691 this->colours[i] = cs->legend_colour;
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
692 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
693 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
694 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
695
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
696 i++;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
697 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
698 this->num_dataset = i;
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
699
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
700 this->DrawGraph();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
701
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
702 DrawString(2 + 46, 24 + this->gd_height + 7, STR_7062_DAYS_IN_TRANSIT, TC_FROMSTRING);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
703 DrawString(2 + 84, 24 - 9, STR_7063_PAYMENT_FOR_DELIVERING, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
704 }
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
705
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
706 virtual void OnClick(Point pt, int widget)
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
707 {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
708 if (widget >= 3) {
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
709 ToggleBit(_legend_excluded_cargo, widget - 3);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
710 this->ToggleWidgetLoweredState(widget);
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
711 this->SetDirty();
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
712 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
713 }
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
714 };
5584
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 static const Widget _cargo_payment_rates_widgets[] = {
9748
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
717 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
718 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 567, 0, 13, STR_7061_CARGO_PAYMENT_RATES, STR_018C_WINDOW_TITLE_DRAG_THIS},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
719 { 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
720 { 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
721 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
722
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
723 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
724 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
725 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
726 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
727 _cargo_payment_rates_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
728 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
729
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
730
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
731 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
732 {
9290
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
733 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
734 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
735
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
736 /************************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
737 /* 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
738 /************************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
739
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
740 static const StringID _performance_titles[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
741 STR_7066_ENGINEER,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
742 STR_7066_ENGINEER,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
743 STR_7067_TRAFFIC_MANAGER,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
744 STR_7067_TRAFFIC_MANAGER,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
745 STR_7068_TRANSPORT_COORDINATOR,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
746 STR_7068_TRANSPORT_COORDINATOR,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
747 STR_7069_ROUTE_SUPERVISOR,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
748 STR_7069_ROUTE_SUPERVISOR,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
749 STR_706A_DIRECTOR,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
750 STR_706A_DIRECTOR,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
751 STR_706B_CHIEF_EXECUTIVE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
752 STR_706B_CHIEF_EXECUTIVE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
753 STR_706C_CHAIRMAN,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
754 STR_706C_CHAIRMAN,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
755 STR_706D_PRESIDENT,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
756 STR_706E_TYCOON,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
757 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
758
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
759 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
760 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
761 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
762 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
763
9525
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
764 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
765 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
766 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
767
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
768 /**
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
769 * (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
770 */
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
771 void BuildCompanyList()
9525
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
772 {
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
773 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
774
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
775 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
776
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
777 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
778 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
779 *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
780 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
781
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
782 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
783 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
784 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
785
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
786 /** Sort the company league by performance history */
10647
592ae9307430 (svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents: 10480
diff changeset
787 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
788 {
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
789 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
790 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
791
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
792 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
793 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
794 {
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
795 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
796 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
797
9333
5236ba6c7d54 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138 <peter1138@openttd.org>
parents: 9317
diff changeset
798 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
799 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
800
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
801 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
802 {
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
803 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
804 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
805
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
806 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
807
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
808 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
809 const Company *c = this->companies[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
810 SetDParam(0, i + STR_01AC_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
811 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
812 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
813 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
814
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
815 DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, TC_FROMSTRING);
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
816 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
817 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
818 }
9525
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
819
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
820 virtual void OnTick()
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
821 {
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
822 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
823 this->SetDirty();
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
824 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
825 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
826
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
827 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
828 {
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
829 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
830 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
831 } 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
832 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
833 }
939a335c63b9 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13 <skidd13@openttd.org>
parents: 9333
diff changeset
834 }
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
835 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
836
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
837
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
838 static const Widget _company_league_widgets[] = {
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
839 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
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
840 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 387, 0, 13, STR_7053_COMPANY_LEAGUE_TABLE, STR_018C_WINDOW_TITLE_DRAG_THIS},
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
841 { WWT_STICKYBOX, RESIZE_NONE, COLOUR_GREY, 388, 399, 0, 13, STR_NULL, STR_STICKY_BUTTON},
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
842 { 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
843 { 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
844 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
845
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
846 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
847 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
848 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
849 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
850 _company_league_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
851 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
852
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
853 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
854 {
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
855 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
856 }
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 /* 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
860 /*****************************/
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
861
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
862 struct PerformanceRatingDetailWindow : Window {
9747
f2744bf096d6 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas <belugas@openttd.org>
parents: 9659
diff changeset
863 private:
f2744bf096d6 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas <belugas@openttd.org>
parents: 9659
diff changeset
864 enum PerformanteRatingWidgets {
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
865 PRW_COMPANY_FIRST = 13,
10477
20da0dd3f897 (svn r14732) -Codechange: replace some magic number with less magic constants and use the proper type for a few variables.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
866 PRW_COMPANY_LAST = PRW_COMPANY_FIRST + MAX_COMPANIES - 1,
9747
f2744bf096d6 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas <belugas@openttd.org>
parents: 9659
diff changeset
867 };
f2744bf096d6 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas <belugas@openttd.org>
parents: 9659
diff changeset
868
f2744bf096d6 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas <belugas@openttd.org>
parents: 9659
diff changeset
869 public:
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
870 static CompanyID company;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
871 int timeout;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
872
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
873 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
874 {
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
875 /* 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
876 for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; 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
877 this->SetWidgetDisabledState(i + PRW_COMPANY_FIRST, !IsValidCompanyID(i));
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
878 }
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
879
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
880 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
881
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
882 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
883
8d0747f9b5af (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium <rubidium@openttd.org>
parents: 9289
diff changeset
884 this->FindWindowPlacementAndResize(desc);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
885 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
886
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
887 void UpdateCompanyStats()
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
888 {
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
889 /* 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
890 * (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
891 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
892 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
893 UpdateCompanyRatingAndValue(c, false);
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
894 }
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
895
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
896 this->timeout = DAY_TICKS * 5;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
897
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
898 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
899
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
900 virtual void OnPaint()
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
901 {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
902 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
903 uint16 y = 27;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
904 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
905 int colour_done, colour_notdone;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
906
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
907 /* 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
908 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
909
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
910 /* Check if the currently selected company is still 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
911 if (company == INVALID_COMPANY || !IsValidCompanyID(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
912 if (company != INVALID_COMPANY) {
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
913 /* 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
914 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
915 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
916 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
917
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
918 company = INVALID_COMPANY;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
919 }
5946
1dc5b0b8fe69 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents: 5893
diff changeset
920
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
921 for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; 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
922 if (IsValidCompanyID(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
923 /* 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
924 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
925 this->SetDirty();
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
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 company = i;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
928 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
929 }
1dc5b0b8fe69 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents: 5893
diff changeset
930 }
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
931 }
5946
1dc5b0b8fe69 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents: 5893
diff changeset
932
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
933 /* 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
934 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
935
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
936 /* 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
937 for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; 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
938 if (!IsValidCompanyID(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
939 /* 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
940 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
941 /* 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
942 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
943
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
944 /* We need a repaint */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
945 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
946 }
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
947 continue;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
948 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
949
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
950 /* 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
951 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
952 /* 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
953 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
954 /* We need a repaint */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
955 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
956 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
957
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
958 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
959 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
960 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
961
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
962 /* 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
963 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
964 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
965
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
966 /* Draw all the score parts */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
967 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
968 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
969 int needed = _score_info[i].needed;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
970 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
971
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
972 y += 20;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
973 /* SCORE_TOTAL has his own rulez ;) */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
974 if (i == SCORE_TOTAL) {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
975 needed = total_score;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
976 score = SCORE_MAX;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
977 } else {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
978 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
979 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
980
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
981 DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, TC_FROMSTRING);
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
982
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
983 /* Draw the score */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
984 SetDParam(0, score);
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
985 DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, TC_FROMSTRING);
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
986
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
987 /* Calculate the %-bar */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
988 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
989
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
990 /* SCORE_LOAN is inversed */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
991 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
992
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
993 /* 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
994 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
995 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
996
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
997 /* Calculate the % */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
998 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
999
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1000 /* SCORE_LOAN is inversed */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1001 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
1002
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1003 /* Draw it */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1004 SetDParam(0, x);
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1005 DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING);
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1006
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1007 /* SCORE_LOAN is inversed */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1008 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
1009
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1010 /* Draw the amount we have against what is needed
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1011 * For some of them it is in currency format */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1012 SetDParam(0, val);
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1013 SetDParam(1, needed);
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1014 switch (i) {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1015 case SCORE_MIN_PROFIT:
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1016 case SCORE_MIN_INCOME:
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1017 case SCORE_MAX_INCOME:
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1018 case SCORE_MONEY:
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1019 case SCORE_LOAN:
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1020 DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, TC_FROMSTRING);
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1021 break;
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1022 default:
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1023 DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, TC_FROMSTRING);
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1024 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1025 }
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1026 }
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
1027
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1028 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
1029 {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1030 /* 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
1031 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
1032 /* Is it no on disable? */
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1033 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
1034 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
1035 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
1036 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
1037 this->SetDirty();
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 }
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1040 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1041
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1042 virtual void OnTick()
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1043 {
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1044 if (_pause_game != 0) 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
1045
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
1046 /* 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
1047 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
1048 this->UpdateCompanyStats();
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1049 this->SetDirty();
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1050 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1051 }
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1052 };
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1053
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
1054 CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY;
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1055
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1056
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1057 static const Widget _performance_rating_detail_widgets[] = {
9748
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
1058 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
1059 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 298, 0, 13, STR_PERFORMANCE_DETAIL, STR_018C_WINDOW_TITLE_DRAG_THIS},
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
1060 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 14, 40, 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
1061
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
1062 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 41, 60, 0x0, STR_PERFORMANCE_DETAIL_VEHICLES_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
1063 { 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
1064 { 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
1065 { 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
1066 { 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
1067 { 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
1068 { 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
1069 { 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
1070 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 201, 220, 0x0, STR_PERFORMANCE_DETAIL_LOAN_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
1071 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 221, 240, 0x0, STR_PERFORMANCE_DETAIL_TOTAL_TIP},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1072
9748
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
1073 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 38, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
1074 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 39, 75, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
1075 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 76, 112, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
1076 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 113, 149, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
1077 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 150, 186, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
1078 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 187, 223, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
1079 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 224, 260, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
21aeba858939 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas <belugas@openttd.org>
parents: 9747
diff changeset
1080 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 261, 297, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
1081 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 38, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
1082 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 39, 75, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
1083 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 76, 112, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
1084 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 113, 149, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
1085 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 150, 186, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
1086 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 187, 223, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
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
1087 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 224, 260, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_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
1088 { 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
1089 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1090
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1091 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
1092 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
1093 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
1094 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1095 _performance_rating_detail_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1096 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1097
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6203
diff changeset
1098 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
1099 {
9255
e12e58b72aa0 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
1100 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
1101 }