src/graph_gui.cpp
author smatz
Wed, 24 Sep 2008 16:40:06 +0000
changeset 10184 bf4e3ff4cf16
parent 10054 69258fa808b7
child 10207 c291a21b304e
permissions -rw-r--r--
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
-Fix: close any dropdown and child windows in the Order and Timetable windows when selected order is deselected, deleted, ...
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9111
48ce04029fe4 (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
parents: 8409
diff changeset
     3
/** @file graph_gui.cpp GUI that shows performance graphs. */
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1575
diff changeset
     6
#include "openttd.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     8
#include "window_gui.h"
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
     9
#include "player_base.h"
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    10
#include "player_gui.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    11
#include "economy_func.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2135
diff changeset
    12
#include "variables.h"
6091
c8827d9ae04a (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 5946
diff changeset
    13
#include "cargotype.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8107
diff changeset
    14
#include "strings_func.h"
8130
d2eb7d04f6e1 (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8121
diff changeset
    15
#include "core/alloc_func.hpp"
8131
160939e24ed3 (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
parents: 8130
diff changeset
    16
#include "window_func.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8131
diff changeset
    17
#include "date_func.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8179
diff changeset
    18
#include "gfx_func.h"
9525
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
    19
#include "sortlist_type.h"
5291
0bd449fe7fe5 (svn r7444) -Codechange: Use one (global) cargo-colours array for drawing cargo-colours. Change Food
Darkvater
parents: 5247
diff changeset
    20
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    21
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    22
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    23
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
    24
/* Bitmasks of player and cargo indices that shouldn't be drawn. */
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
    25
static uint _legend_excluded_players;
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
    26
static uint _legend_excluded_cargo;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
5805
1e6230a16f9b (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
parents: 5804
diff changeset
    28
/* Apparently these don't play well with enums. */
8409
de295d5e2bb4 (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
parents: 8264
diff changeset
    29
static const OverflowSafeInt64 INVALID_DATAPOINT(INT64_MAX); // Value used for a datapoint that shouldn't be drawn.
7763
342e5357b592 (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
parents: 7520
diff changeset
    30
static const uint INVALID_DATAPOINT_POS = UINT_MAX;  // Used to determine if the previous point was drawn.
5805
1e6230a16f9b (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
parents: 5804
diff changeset
    31
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
/* GRAPH LEGEND */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    36
struct GraphLegendWindow : Window {
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    37
	GraphLegendWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    38
	{
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    39
		for (uint i = 3; i < this->widget_count; i++) {
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    40
			if (!HasBit(_legend_excluded_players, i - 3)) this->LowerWidget(i);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    41
		}
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
    42
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
    43
		this->FindWindowPlacementAndResize(desc);
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    44
	}
6203
861336d3e289 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6192
diff changeset
    45
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    46
	virtual void OnPaint()
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    47
	{
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
    48
		for (PlayerID p = PLAYER_FIRST; p < MAX_PLAYERS; p++) {
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
    49
			if (IsValidPlayerID(p)) continue;
6203
861336d3e289 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6192
diff changeset
    50
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
    51
			SetBit(_legend_excluded_players, p);
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
    52
			this->RaiseWidget(p + 3);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    55
		this->DrawWidgets();
6203
861336d3e289 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6192
diff changeset
    56
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
    57
		const Player *p;
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    58
		FOR_ALL_PLAYERS(p) {
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    59
			DrawPlayerIcon(p->index, 4, 18 + p->index * 12);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    60
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    61
			SetDParam(0, p->index);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    62
			SetDParam(1, p->index);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    63
			DrawString(21, 17 + p->index * 12, STR_7021, HasBit(_legend_excluded_players, p->index) ? TC_BLACK : TC_WHITE);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    64
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
	}
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    66
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    67
	virtual void OnClick(Point pt, int widget)
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    68
	{
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    69
		if (!IsInsideMM(widget, 3, 11)) return;
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    70
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    71
		ToggleBit(_legend_excluded_players, widget - 3);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    72
		this->ToggleWidgetLoweredState(widget);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    73
		this->SetDirty();
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    74
		InvalidateWindow(WC_INCOME_GRAPH, 0);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    75
		InvalidateWindow(WC_OPERATING_PROFIT, 0);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    76
		InvalidateWindow(WC_DELIVERED_CARGO, 0);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    77
		InvalidateWindow(WC_PERFORMANCE_HISTORY, 0);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    78
		InvalidateWindow(WC_COMPANY_VALUE, 0);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    79
	}
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
    80
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
static const Widget _graph_legend_widgets[] = {
9748
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
    83
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
    84
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   249,     0,    13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
    85
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   249,    14,   113, 0x0,                            STR_NULL},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
    86
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     2,   247,    16,    27, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
    87
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     2,   247,    28,    39, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
    88
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     2,   247,    40,    51, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
    89
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     2,   247,    52,    63, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
    90
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     2,   247,    64,    75, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
    91
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     2,   247,    76,    87, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
    92
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     2,   247,    88,    99, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
    93
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     2,   247,   100,   111, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 165
diff changeset
    94
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
static const WindowDesc _graph_legend_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
    98
	WDP_AUTO, WDP_AUTO, 250, 114, 250, 114,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
    99
	WC_GRAPH_LEGEND, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
	_graph_legend_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6203
diff changeset
   104
static void ShowGraphLegend()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
{
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   106
	AllocateWindowDescFront<GraphLegendWindow>(&_graph_legend_desc, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   109
/******************/
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   110
/* BASE OF GRAPHS */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   111
/*****************/
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   112
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   113
struct BaseGraphWindow : Window {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   114
protected:
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   115
	enum {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   116
		GRAPH_MAX_DATASETS = 32,
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   117
		GRAPH_AXIS_LINE_COLOUR  = 215,
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   118
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   119
		GRAPH_X_POSITION_BEGINNING  = 44,  ///< Start the graph 44 pixels from gd_left
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   120
		GRAPH_X_POSITION_SEPARATION = 22,  ///< There are 22 pixels between each X value
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   121
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   122
		GRAPH_NUM_LINES_Y = 9, ///< How many horizontal lines to draw.
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   123
		/* 9 is convenient as that means the distance between them is the gd_height of the graph / 8,
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   124
		* which is the same
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   125
		* as height >> 3. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   126
	};
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   127
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   128
	uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed.
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   129
	byte num_dataset;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   130
	byte num_on_x_axis;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   131
	bool has_negative_values;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   132
	byte num_vert_lines;
9865
31f95a144fb9 (svn r14011) -Codechange: not required to define an enum which was just the representation of another.
belugas
parents: 9850
diff changeset
   133
	static const TextColour graph_axis_label_colour = TC_BLACK; ///< colour of the graph axis label.
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   134
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   135
	/* The starting month and year that values are plotted against. If month is
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   136
	 * 0xFF, use x_values_start and x_values_increment below instead. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   137
	byte month;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   138
	Year year;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   139
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   140
	/* These values are used if the graph is being plotted against values
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   141
	 * rather than the dates specified by month and year. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   142
	uint16 x_values_start;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   143
	uint16 x_values_increment;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   144
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   145
	int gd_left, gd_top;  ///< Where to start drawing the graph, in pixels.
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   146
	uint gd_height;    ///< The height of the graph in pixels.
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   147
	StringID format_str_y_axis;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   148
	byte colors[GRAPH_MAX_DATASETS];
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   149
	OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   150
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   151
	void DrawGraph() const
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   152
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   153
		uint x, y;                       ///< Reused whenever x and y coordinates are needed.
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   154
		OverflowSafeInt64 highest_value; ///< Highest value to be drawn.
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   155
		int x_axis_offset;               ///< Distance from the top of the graph to the x axis.
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   156
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   157
		/* the colors and cost array of GraphDrawer must accomodate
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   158
		* both values for cargo and players. So if any are higher, quit */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   159
		assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_PLAYERS);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   160
		assert(this->num_vert_lines > 0);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   161
9850
61bd42a09ddd (svn r13994) -Codechange: replace a few rogue magic numbers with Colours enum values
belugas
parents: 9748
diff changeset
   162
		byte grid_colour = _colour_gradient[COLOUR_GREY][4];
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   163
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   164
		/* The coordinates of the opposite edges of the graph. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   165
		int bottom = this->gd_top + this->gd_height - 1;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   166
		int right  = this->gd_left + GRAPH_X_POSITION_BEGINNING + this->num_vert_lines * GRAPH_X_POSITION_SEPARATION - 1;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   167
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   168
		/* Draw the vertical grid lines. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   169
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   170
		/* Don't draw the first line, as that's where the axis will be. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   171
		x = this->gd_left + GRAPH_X_POSITION_BEGINNING + GRAPH_X_POSITION_SEPARATION;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   172
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   173
		for (int i = 0; i < this->num_vert_lines; i++) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   174
			GfxFillRect(x, this->gd_top, x, bottom, grid_colour);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   175
			x += GRAPH_X_POSITION_SEPARATION;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   176
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   177
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   178
		/* Draw the horizontal grid lines. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   179
		x = this->gd_left + GRAPH_X_POSITION_BEGINNING;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   180
		y = this->gd_height + this->gd_top;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   181
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   182
		for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   183
			GfxFillRect(x, y, right, y, grid_colour);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   184
			y -= (this->gd_height / (GRAPH_NUM_LINES_Y - 1));
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   185
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   186
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   187
		/* Draw the y axis. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   188
		GfxFillRect(x, this->gd_top, x, bottom, GRAPH_AXIS_LINE_COLOUR);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   189
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   190
		/* Find the distance from the gd_top of the graph to the x axis. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   191
		x_axis_offset = this->gd_height;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   192
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   193
		/* The graph is currently symmetrical about the x axis. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   194
		if (this->has_negative_values) x_axis_offset /= 2;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   195
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   196
		/* Draw the x axis. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   197
		y = x_axis_offset + this->gd_top;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   198
		GfxFillRect(x, y, right, y, GRAPH_AXIS_LINE_COLOUR);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   199
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   200
		/* Find the largest value that will be drawn. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   201
		if (this->num_on_x_axis == 0)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   202
			return;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   203
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   204
		assert(this->num_on_x_axis > 0);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   205
		assert(this->num_dataset > 0);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   206
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   207
		/* Start of with a value of twice the gd_height of the graph in pixels. It's a
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   208
		* bit arbitrary, but it makes the cargo payment graph look a little nicer,
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   209
		* and prevents division by zero when calculating where the datapoint
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   210
		* should be drawn. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   211
		highest_value = x_axis_offset * 2;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   212
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   213
		for (int i = 0; i < this->num_dataset; i++) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   214
			if (!HasBit(this->excluded_data, i)) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   215
				for (int j = 0; j < this->num_on_x_axis; j++) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   216
					OverflowSafeInt64 datapoint = this->cost[i][j];
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   217
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   218
					if (datapoint != INVALID_DATAPOINT) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   219
						/* For now, if the graph has negative values the scaling is
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   220
						* symmetrical about the x axis, so take the absolute value
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   221
						* of each data point. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   222
						highest_value = max(highest_value, abs(datapoint));
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   223
					}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   224
				}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   225
			}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   226
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   227
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   228
		/* Round up highest_value so that it will divide cleanly into the number of
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   229
		* axis labels used. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   230
		int round_val = highest_value % (GRAPH_NUM_LINES_Y - 1);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   231
		if (round_val != 0) highest_value += (GRAPH_NUM_LINES_Y - 1 - round_val);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   232
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   233
		/* draw text strings on the y axis */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   234
		int64 y_label = highest_value;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   235
		int64 y_label_separation = highest_value / (GRAPH_NUM_LINES_Y - 1);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   236
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   237
		/* If there are negative values, the graph goes from highest_value to
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   238
		* -highest_value, not highest_value to 0. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   239
		if (this->has_negative_values) y_label_separation *= 2;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   240
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   241
		x = this->gd_left + GRAPH_X_POSITION_BEGINNING + 1;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   242
		y = this->gd_top - 3;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   243
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   244
		for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   245
			SetDParam(0, this->format_str_y_axis);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   246
			SetDParam(1, y_label);
9865
31f95a144fb9 (svn r14011) -Codechange: not required to define an enum which was just the representation of another.
belugas
parents: 9850
diff changeset
   247
			DrawStringRightAligned(x, y, STR_0170, graph_axis_label_colour);
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   248
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   249
			y_label -= y_label_separation;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   250
			y += (this->gd_height / (GRAPH_NUM_LINES_Y - 1));
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   251
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   252
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   253
		/* draw strings on the x axis */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   254
		if (this->month != 0xFF) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   255
			x = this->gd_left + GRAPH_X_POSITION_BEGINNING;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   256
			y = this->gd_top + this->gd_height + 1;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   257
			byte month = this->month;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   258
			Year year  = this->year;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   259
			for (int i = 0; i < this->num_on_x_axis; i++) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   260
				SetDParam(0, month + STR_0162_JAN);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   261
				SetDParam(1, month + STR_0162_JAN + 2);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   262
				SetDParam(2, year);
9865
31f95a144fb9 (svn r14011) -Codechange: not required to define an enum which was just the representation of another.
belugas
parents: 9850
diff changeset
   263
				DrawString(x, y, month == 0 ? STR_016F : STR_016E, graph_axis_label_colour);
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   264
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   265
				month += 3;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   266
				if (month >= 12) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   267
					month = 0;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   268
					year++;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   269
				}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   270
				x += GRAPH_X_POSITION_SEPARATION;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   271
			}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   272
		} else {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   273
			/* Draw the label under the data point rather than on the grid line. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   274
			x = this->gd_left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2) + 1;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   275
			y = this->gd_top + this->gd_height + 1;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   276
			uint16 label = this->x_values_start;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   277
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   278
			for (int i = 0; i < this->num_on_x_axis; i++) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   279
				SetDParam(0, label);
9865
31f95a144fb9 (svn r14011) -Codechange: not required to define an enum which was just the representation of another.
belugas
parents: 9850
diff changeset
   280
				DrawStringCentered(x, y, STR_01CB, graph_axis_label_colour);
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   281
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   282
				label += this->x_values_increment;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   283
				x += GRAPH_X_POSITION_SEPARATION;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   284
			}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   285
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   286
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   287
		/* draw lines and dots */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   288
		for (int i = 0; i < this->num_dataset; i++) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   289
			if (!HasBit(this->excluded_data, i)) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   290
				/* Centre the dot between the grid lines. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   291
				x = this->gd_left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   292
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   293
				byte color  = this->colors[i];
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   294
				uint prev_x = INVALID_DATAPOINT_POS;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   295
				uint prev_y = INVALID_DATAPOINT_POS;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   296
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   297
				for (int j = 0; j < this->num_on_x_axis; j++) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   298
					OverflowSafeInt64 datapoint = this->cost[i][j];
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   299
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   300
					if (datapoint != INVALID_DATAPOINT) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   301
						/*
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   302
						* Check whether we need to reduce the 'accuracy' of the
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   303
						* datapoint value and the highest value to splut overflows.
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   304
						* And when 'drawing' 'one million' or 'one million and one'
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   305
						* there is no significant difference, so the least
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   306
						* significant bits can just be removed.
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   307
						*
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   308
						* If there are more bits needed than would fit in a 32 bits
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   309
						* integer, so at about 31 bits because of the sign bit, the
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   310
						* least significant bits are removed.
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   311
						*/
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   312
						int mult_range = FindLastBit(x_axis_offset) + FindLastBit(abs(datapoint));
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   313
						int reduce_range = max(mult_range - 31, 0);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   314
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   315
						/* Handle negative values differently (don't shift sign) */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   316
						if (datapoint < 0) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   317
							datapoint = -(abs(datapoint) >> reduce_range);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   318
						} else {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   319
							datapoint >>= reduce_range;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   320
						}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   321
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   322
						y = this->gd_top + x_axis_offset - (x_axis_offset * datapoint) / (highest_value >> reduce_range);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   323
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   324
						/* Draw the point. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   325
						GfxFillRect(x - 1, y - 1, x + 1, y + 1, color);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   326
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   327
						/* Draw the line connected to the previous point. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   328
						if (prev_x != INVALID_DATAPOINT_POS) GfxDrawLine(prev_x, prev_y, x, y, color);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   329
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   330
						prev_x = x;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   331
						prev_y = y;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   332
					} else {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   333
						prev_x = INVALID_DATAPOINT_POS;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   334
						prev_y = INVALID_DATAPOINT_POS;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   335
					}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   336
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   337
					x += GRAPH_X_POSITION_SEPARATION;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   338
				}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   339
			}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   340
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   341
	}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   342
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   343
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   344
	BaseGraphWindow(const WindowDesc *desc, WindowNumber window_number, int left,
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   345
									int top, int height, bool has_negative_values, StringID format_str_y_axis) :
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   346
			Window(desc, window_number), has_negative_values(has_negative_values),
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   347
			gd_left(left), gd_top(top), gd_height(height), format_str_y_axis(format_str_y_axis)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   348
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   349
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   350
	}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   351
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   352
public:
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   353
	virtual void OnPaint()
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   354
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   355
		this->DrawWidgets();
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   356
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   357
		uint excluded_players = _legend_excluded_players;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   358
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   359
		/* Exclude the players which aren't valid */
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
   360
		for (PlayerID p = PLAYER_FIRST; p < MAX_PLAYERS; p++) {
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
   361
			if (!IsValidPlayerID(p)) SetBit(excluded_players, p);
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   362
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   363
		this->excluded_data = excluded_players;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   364
		this->num_vert_lines = 24;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   365
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   366
		byte nums = 0;
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
   367
		const Player *p;
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   368
		FOR_ALL_PLAYERS(p) {
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
   369
			nums = max(nums, p->num_valid_stat_ent);
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   370
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   371
		this->num_on_x_axis = min(nums, 24);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   372
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   373
		int mo = (_cur_month / 3 - nums) * 3;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   374
		int yr = _cur_year;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   375
		while (mo < 0) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   376
			yr--;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   377
			mo += 12;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   378
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   379
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   380
		this->year = yr;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   381
		this->month = mo;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   382
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   383
		int numd = 0;
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
   384
		for (PlayerID k = PLAYER_FIRST; k < MAX_PLAYERS; k++) {
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
   385
			if (IsValidPlayerID(k)) {
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
   386
				p = GetPlayer(k);
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   387
				this->colors[numd] = _colour_gradient[p->player_color][6];
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   388
				for (int j = this->num_on_x_axis, i = 0; --j >= 0;) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   389
					this->cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : GetGraphData(p, j);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   390
					i++;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   391
				}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   392
			}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   393
			numd++;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   394
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   395
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   396
		this->num_dataset = numd;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   397
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   398
		this->DrawGraph();
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   399
	}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   400
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   401
	virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   402
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   403
		return INVALID_DATAPOINT;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   404
	}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   405
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   406
	virtual void OnClick(Point pt, int widget)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   407
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   408
		/* Clicked on legend? */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   409
		if (widget == 2) ShowGraphLegend();
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   410
	}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   411
};
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   412
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
/********************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
/* OPERATING PROFIT */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
/********************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   417
struct OperatingProfitGraphWindow : BaseGraphWindow {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   418
	OperatingProfitGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   419
			BaseGraphWindow(desc, window_number, 2, 18, 136, true, STR_CURRCOMPACT)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   420
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   421
		this->FindWindowPlacementAndResize(desc);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   424
	virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   425
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   426
		return p->old_economy[j].income + p->old_economy[j].expenses;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
	}
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   428
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
static const Widget _operating_profit_widgets[] = {
9748
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   431
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   432
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   525,     0,    13, STR_7025_OPERATING_PROFIT_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   433
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   526,   575,     0,    13, STR_704C_KEY,                    STR_704D_SHOW_KEY_TO_GRAPHS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   434
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   575,    14,   173, 0x0,                             STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 165
diff changeset
   435
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
static const WindowDesc _operating_profit_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   439
	WDP_AUTO, WDP_AUTO, 576, 174, 576, 174,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   440
	WC_OPERATING_PROFIT, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
	_operating_profit_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6203
diff changeset
   446
void ShowOperatingProfitGraph()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
{
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   448
	AllocateWindowDescFront<OperatingProfitGraphWindow>(&_operating_profit_desc, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
/* INCOME GRAPH */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   456
struct IncomeGraphWindow : BaseGraphWindow {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   457
	IncomeGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   458
			BaseGraphWindow(desc, window_number, 2, 18, 104, false, STR_CURRCOMPACT)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   459
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   460
		this->FindWindowPlacementAndResize(desc);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   461
	}
6203
861336d3e289 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6192
diff changeset
   462
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   463
	virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   464
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   465
		return p->old_economy[j].income;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
	}
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   467
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
static const Widget _income_graph_widgets[] = {
9748
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   470
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   471
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   525,     0,    13, STR_7022_INCOME_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   472
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   526,   575,     0,    13, STR_704C_KEY,          STR_704D_SHOW_KEY_TO_GRAPHS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   473
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   575,    14,   141, 0x0,                   STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 165
diff changeset
   474
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
static const WindowDesc _income_graph_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   478
	WDP_AUTO, WDP_AUTO, 576, 142, 576, 142,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   479
	WC_INCOME_GRAPH, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
	_income_graph_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6203
diff changeset
   484
void ShowIncomeGraph()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
{
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   486
	AllocateWindowDescFront<IncomeGraphWindow>(&_income_graph_desc, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   489
/*******************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   490
/* DELIVERED CARGO */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
/*******************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   492
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   493
struct DeliveredCargoGraphWindow : BaseGraphWindow {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   494
	DeliveredCargoGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   495
			BaseGraphWindow(desc, window_number, 2, 18, 104, false, STR_7024)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   496
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   497
		this->FindWindowPlacementAndResize(desc);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   498
	}
6203
861336d3e289 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6192
diff changeset
   499
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   500
	virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   501
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   502
		return p->old_economy[j].delivered_cargo;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
	}
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   504
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
static const Widget _delivered_cargo_graph_widgets[] = {
9748
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   507
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   508
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   525,     0,    13, STR_7050_UNITS_OF_CARGO_DELIVERED, STR_018C_WINDOW_TITLE_DRAG_THIS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   509
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   526,   575,     0,    13, STR_704C_KEY,                      STR_704D_SHOW_KEY_TO_GRAPHS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   510
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   575,    14,   141, 0x0,                               STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 165
diff changeset
   511
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
static const WindowDesc _delivered_cargo_graph_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   515
	WDP_AUTO, WDP_AUTO, 576, 142, 576, 142,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   516
	WC_DELIVERED_CARGO, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
	_delivered_cargo_graph_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6203
diff changeset
   521
void ShowDeliveredCargoGraph()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
{
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   523
	AllocateWindowDescFront<DeliveredCargoGraphWindow>(&_delivered_cargo_graph_desc, 0);
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   524
}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   525
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   526
/***********************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   527
/* PERFORMANCE HISTORY */
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   528
/***********************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   529
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   530
struct PerformanceHistoryGraphWindow : BaseGraphWindow {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   531
	PerformanceHistoryGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   532
			BaseGraphWindow(desc, window_number, 2, 18, 200, false, STR_7024)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   533
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   534
		this->FindWindowPlacementAndResize(desc);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   535
	}
6203
861336d3e289 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6192
diff changeset
   536
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   537
	virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   538
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   539
		return p->old_economy[j].performance_history;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   540
	}
6203
861336d3e289 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6192
diff changeset
   541
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   542
	virtual void OnClick(Point pt, int widget)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   543
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   544
		if (widget == 3) ShowPerformanceRatingDetail();
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   545
		this->BaseGraphWindow::OnClick(pt, widget);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   546
	}
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   547
};
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   548
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   549
static const Widget _performance_history_widgets[] = {
9748
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   550
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                             STR_018B_CLOSE_WINDOW},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   551
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   475,     0,    13, STR_7051_COMPANY_PERFORMANCE_RATINGS, STR_018C_WINDOW_TITLE_DRAG_THIS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   552
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   526,   575,     0,    13, STR_704C_KEY,                         STR_704D_SHOW_KEY_TO_GRAPHS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   553
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   476,   525,     0,    13, STR_PERFORMANCE_DETAIL_KEY,           STR_704D_SHOW_KEY_TO_GRAPHS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   554
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   575,    14,   237, 0x0,                                  STR_NULL},
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   555
{   WIDGETS_END},
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   556
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   557
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   558
static const WindowDesc _performance_history_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   559
	WDP_AUTO, WDP_AUTO, 576, 238, 576, 238,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   560
	WC_PERFORMANCE_HISTORY, WC_NONE,
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   561
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   562
	_performance_history_widgets,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   563
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   564
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6203
diff changeset
   565
void ShowPerformanceHistoryGraph()
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   566
{
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   567
	AllocateWindowDescFront<PerformanceHistoryGraphWindow>(&_performance_history_desc, 0);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   568
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   569
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   570
/*****************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   571
/* COMPANY VALUE */
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   572
/*****************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   573
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   574
struct CompanyValueGraphWindow : BaseGraphWindow {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   575
	CompanyValueGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   576
			BaseGraphWindow(desc, window_number, 2, 18, 200, false, STR_CURRCOMPACT)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   577
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   578
		this->FindWindowPlacementAndResize(desc);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   579
	}
6203
861336d3e289 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6192
diff changeset
   580
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   581
	virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   582
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   583
		return p->old_economy[j].company_value;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   584
	}
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   585
};
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   586
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   587
static const Widget _company_value_graph_widgets[] = {
9748
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   588
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   589
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   525,     0,    13, STR_7052_COMPANY_VALUES, STR_018C_WINDOW_TITLE_DRAG_THIS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   590
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   526,   575,     0,    13, STR_704C_KEY,            STR_704D_SHOW_KEY_TO_GRAPHS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   591
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   575,    14,   237, 0x0,                     STR_NULL},
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   592
{   WIDGETS_END},
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   593
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   594
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   595
static const WindowDesc _company_value_graph_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   596
	WDP_AUTO, WDP_AUTO, 576, 238, 576, 238,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   597
	WC_COMPANY_VALUE, WC_NONE,
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   598
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   599
	_company_value_graph_widgets,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   600
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   601
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6203
diff changeset
   602
void ShowCompanyValueGraph()
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   603
{
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   604
	AllocateWindowDescFront<CompanyValueGraphWindow>(&_company_value_graph_desc, 0);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   605
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   606
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   607
/*****************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   608
/* PAYMENT RATES */
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   609
/*****************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   610
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   611
struct PaymentRatesGraphWindow : BaseGraphWindow {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   612
	PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   613
			BaseGraphWindow(desc, window_number, 2, 24, 200, false, STR_CURRCOMPACT)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   614
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   615
		uint num_active = 0;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   616
		for (CargoID c = 0; c < NUM_CARGO; c++) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   617
			if (GetCargo(c)->IsValid()) num_active++;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   618
		}
6203
861336d3e289 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6192
diff changeset
   619
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   620
		/* Resize the window to fit the cargo types */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   621
		ResizeWindow(this, 0, max(num_active, 12U) * 8);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   622
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   623
		/* Add widgets for each cargo type */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   624
		this->widget_count += num_active;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   625
		this->widget = ReallocT(this->widget, this->widget_count + 1);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   626
		this->widget[this->widget_count].type = WWT_LAST;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   627
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   628
		/* Set the properties of each widget */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   629
		for (uint i = 0; i != num_active; i++) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   630
			Widget *wi = &this->widget[3 + i];
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   631
			wi->type     = WWT_PANEL;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   632
			wi->display_flags = RESIZE_NONE;
9748
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   633
			wi->color    = COLOUR_ORANGE;
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   634
			wi->left     = 493;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   635
			wi->right    = 562;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   636
			wi->top      = 24 + i * 8;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   637
			wi->bottom   = wi->top + 7;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   638
			wi->data     = 0;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   639
			wi->tooltips = STR_7064_TOGGLE_GRAPH_FOR_CARGO;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   640
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   641
			if (!HasBit(_legend_excluded_cargo, i)) this->LowerWidget(i + 3);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   642
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   643
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   644
		this->SetDirty();
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   645
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   646
		this->gd_height = this->height - 38;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   647
		this->num_on_x_axis = 20;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   648
		this->num_vert_lines = 20;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   649
		this->month = 0xFF;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   650
		this->x_values_start     = 10;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   651
		this->x_values_increment = 10;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   652
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   653
		this->FindWindowPlacementAndResize(desc);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   654
	}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   655
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   656
	virtual void OnPaint()
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   657
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   658
		this->DrawWidgets();
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   659
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   660
		this->excluded_data = _legend_excluded_cargo;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   661
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   662
		int x = 495;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   663
		int y = 24;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   664
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   665
		uint i = 0;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   666
		for (CargoID c = 0; c < NUM_CARGO; c++) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   667
			const CargoSpec *cs = GetCargo(c);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   668
			if (!cs->IsValid()) continue;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   669
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   670
			/* Only draw labels for widgets that exist. If the widget doesn't
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   671
				* exist then the local player has used the climate cheat or
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   672
				* changed the NewGRF configuration with this window open. */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   673
			if (i + 3 < this->widget_count) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   674
				/* Since the buttons have no text, no images,
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   675
					* both the text and the colored box have to be manually painted.
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   676
					* clk_dif will move one pixel down and one pixel to the right
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   677
					* when the button is clicked */
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   678
				byte clk_dif = this->IsWidgetLowered(i + 3) ? 1 : 0;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   679
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   680
				GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   681
				GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   682
				SetDParam(0, cs->name);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   683
				DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, TC_FROMSTRING);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   684
				y += 8;
6203
861336d3e289 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6192
diff changeset
   685
			}
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   686
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   687
			this->colors[i] = cs->legend_colour;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   688
			for (uint j = 0; j != 20; j++) {
10054
69258fa808b7 (svn r14219) -Fix (rthebeginning): 10 days != 6*2.5 days, effectively causing the payment graph to show the wrong data.
rubidium
parents: 9865
diff changeset
   689
				this->cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 4 + 4, c);
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   690
			}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   691
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   692
			i++;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   693
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   694
		this->num_dataset = i;
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   695
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   696
		this->DrawGraph();
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   697
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   698
		DrawString(2 + 46, 24 + this->gd_height + 7, STR_7062_DAYS_IN_TRANSIT, TC_FROMSTRING);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   699
		DrawString(2 + 84, 24 - 9, STR_7063_PAYMENT_FOR_DELIVERING, TC_FROMSTRING);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   700
	}
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   701
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   702
	virtual void OnClick(Point pt, int widget)
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   703
	{
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   704
		if (widget >= 3) {
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   705
			ToggleBit(_legend_excluded_cargo, widget - 3);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   706
			this->ToggleWidgetLoweredState(widget);
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   707
			this->SetDirty();
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   708
		}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   709
	}
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   710
};
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   711
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   712
static const Widget _cargo_payment_rates_widgets[] = {
9748
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   713
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   714
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   567,     0,    13, STR_7061_CARGO_PAYMENT_RATES, STR_018C_WINDOW_TITLE_DRAG_THIS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   715
{      WWT_PANEL, RESIZE_BOTTOM,  COLOUR_GREY,     0,   567,    14,    45, 0x0,                          STR_NULL},
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   716
{   WIDGETS_END},
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   717
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   718
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   719
static const WindowDesc _cargo_payment_rates_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   720
	WDP_AUTO, WDP_AUTO, 568, 46, 568, 46,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   721
	WC_PAYMENT_RATES, WC_NONE,
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   722
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   723
	_cargo_payment_rates_widgets,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   724
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   725
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   726
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6203
diff changeset
   727
void ShowCargoPaymentRates()
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   728
{
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   729
	AllocateWindowDescFront<PaymentRatesGraphWindow>(&_cargo_payment_rates_desc, 0);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   730
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   731
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   732
/************************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   733
/* COMPANY LEAGUE TABLE */
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   734
/************************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   735
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   736
static const StringID _performance_titles[] = {
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   737
	STR_7066_ENGINEER,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   738
	STR_7066_ENGINEER,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   739
	STR_7067_TRAFFIC_MANAGER,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   740
	STR_7067_TRAFFIC_MANAGER,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   741
	STR_7068_TRANSPORT_COORDINATOR,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   742
	STR_7068_TRANSPORT_COORDINATOR,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   743
	STR_7069_ROUTE_SUPERVISOR,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   744
	STR_7069_ROUTE_SUPERVISOR,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   745
	STR_706A_DIRECTOR,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   746
	STR_706A_DIRECTOR,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   747
	STR_706B_CHIEF_EXECUTIVE,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   748
	STR_706B_CHIEF_EXECUTIVE,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   749
	STR_706C_CHAIRMAN,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   750
	STR_706C_CHAIRMAN,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   751
	STR_706D_PRESIDENT,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   752
	STR_706E_TYCOON,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   753
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   754
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   755
static inline StringID GetPerformanceTitleFromValue(uint value)
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   756
{
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   757
	return _performance_titles[minu(value, 1000) >> 6];
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   758
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   759
9525
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   760
class CompanyLeagueWindow : public Window {
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   761
private:
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   762
	GUIList<const Player*> players;
2656
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   763
9525
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   764
	/**
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   765
	 * (Re)Build the company league list
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   766
	 */
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   767
	void BuildPlayerList()
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   768
	{
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   769
		if (!this->players.NeedRebuild()) return;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   770
9525
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   771
		this->players.Clear();
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   772
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   773
		const Player *p;
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   774
		FOR_ALL_PLAYERS(p) {
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
   775
			*this->players.Append() = p;
9525
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   776
		}
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   777
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   778
		this->players.Compact();
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   779
		this->players.RebuildDone();
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   780
	}
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   781
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   782
	/** Sort the company league by performance history */
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   783
	static int CDECL PerformanceSorter(const Player* const *p1, const Player* const *p2)
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   784
	{
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   785
		return (*p2)->old_economy[1].performance_history - (*p1)->old_economy[1].performance_history;
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   786
	}
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   787
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   788
public:
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   789
	CompanyLeagueWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   790
	{
9525
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   791
		this->players.ForceRebuild();
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   792
		this->players.NeedResort();
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   793
9333
2da01b3b71d8 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 9317
diff changeset
   794
		this->FindWindowPlacementAndResize(desc);
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   795
	}
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   796
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   797
	virtual void OnPaint()
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   798
	{
9525
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   799
		this->BuildPlayerList();
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   800
		this->players.Sort(&PerformanceSorter);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   801
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   802
		this->DrawWidgets();
2656
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   803
9525
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   804
		for (uint i = 0; i != this->players.Length(); i++) {
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   805
			const Player *p = this->players[i];
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   806
			SetDParam(0, i + STR_01AC_1ST);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   807
			SetDParam(1, p->index);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   808
			SetDParam(2, p->index);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   809
			SetDParam(3, GetPerformanceTitleFromValue(p->old_economy[1].performance_history));
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   810
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   811
			DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, TC_FROMSTRING);
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   812
			DrawPlayerIcon(p->index, 27, 16 + i * 10);
2656
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   813
		}
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   814
	}
9525
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   815
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   816
	virtual void OnTick()
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   817
	{
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   818
		if (this->players.NeedResort()) {
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   819
			this->SetDirty();
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   820
		}
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   821
	}
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   822
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   823
	virtual void OnInvalidateData(int data)
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   824
	{
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   825
		if (data == 0) {
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   826
			this->players.ForceRebuild();
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   827
		} else {
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   828
			this->players.ForceResort();
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   829
		}
dc9739a19016 (svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents: 9333
diff changeset
   830
	}
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   831
};
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   832
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   833
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   834
static const Widget _company_league_widgets[] = {
9748
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   835
{   WWT_CLOSEBOX, RESIZE_NONE,  COLOUR_GREY,   0,  10,  0, 13, STR_00C5,                      STR_018B_CLOSE_WINDOW},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   836
{    WWT_CAPTION, RESIZE_NONE,  COLOUR_GREY,  11, 387,  0, 13, STR_7053_COMPANY_LEAGUE_TABLE, STR_018C_WINDOW_TITLE_DRAG_THIS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   837
{  WWT_STICKYBOX, RESIZE_NONE,  COLOUR_GREY, 388, 399,  0, 13, STR_NULL,                      STR_STICKY_BUTTON},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
   838
{      WWT_PANEL, RESIZE_NONE,  COLOUR_GREY,   0, 399, 14, 96, 0x0,                           STR_NULL},
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   839
{   WIDGETS_END},
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   840
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   841
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   842
static const WindowDesc _company_league_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   843
	WDP_AUTO, WDP_AUTO, 400, 97, 400, 97,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   844
	WC_COMPANY_LEAGUE, WC_NONE,
2869
c5ed60d34909 (svn r3417) - Make company league table window pinnable.
peter1138
parents: 2725
diff changeset
   845
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   846
	_company_league_widgets,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   847
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   848
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6203
diff changeset
   849
void ShowCompanyLeagueTable()
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   850
{
9289
df7b2e2f18a1 (svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents: 9273
diff changeset
   851
	AllocateWindowDescFront<CompanyLeagueWindow>(&_company_league_desc, 0);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   852
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   853
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   854
/*****************************/
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   855
/* PERFORMANCE RATING DETAIL */
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   856
/*****************************/
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   857
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   858
struct PerformanceRatingDetailWindow : Window {
9747
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   859
private:
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   860
	enum PerformanteRatingWidgets {
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   861
		PRW_PLAYER_FIRST = 13,
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   862
		PRW_PLAYER_LAST  = 20,
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   863
	};
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   864
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   865
public:
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   866
	static PlayerID player;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   867
	int timeout;
5946
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   868
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   869
	PerformanceRatingDetailWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   870
	{
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   871
		/* Disable the players who are not active */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   872
		for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
9747
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   873
			this->SetWidgetDisabledState(i + PRW_PLAYER_FIRST, !IsValidPlayerID(i));
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   874
		}
5946
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   875
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   876
		this->UpdatePlayerStats();
5946
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   877
9747
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   878
		if (player != INVALID_PLAYER) this->LowerWidget(player + PRW_PLAYER_FIRST);
9290
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   879
c94d01616943 (svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents: 9289
diff changeset
   880
		this->FindWindowPlacementAndResize(desc);
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   881
	}
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   882
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   883
	void UpdatePlayerStats()
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   884
	{
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   885
		/* Update all player stats with the current data
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   886
		 * (this is because _score_info is not saved to a savegame) */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   887
		Player *p;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   888
		FOR_ALL_PLAYERS(p) {
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
   889
			UpdateCompanyRatingAndValue(p, false);
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   890
		}
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   891
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   892
		this->timeout = DAY_TICKS * 5;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   893
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   894
	}
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   895
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   896
	virtual void OnPaint()
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   897
	{
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   898
		byte x;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   899
		uint16 y = 14;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   900
		int total_score = 0;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   901
		int color_done, color_notdone;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   902
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   903
		/* Draw standard stuff */
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9255
diff changeset
   904
		this->DrawWidgets();
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   905
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   906
		/* Check if the currently selected player is still active. */
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
   907
		if (player == INVALID_PLAYER || !IsValidPlayerID(player)) {
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   908
			if (player != INVALID_PLAYER) {
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   909
				/* Raise and disable the widget for the previous selection. */
9747
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   910
				this->RaiseWidget(player + PRW_PLAYER_FIRST);
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   911
				this->DisableWidget(player + PRW_PLAYER_FIRST);
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   912
				this->SetDirty();
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   913
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   914
				player = INVALID_PLAYER;
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   915
			}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   916
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   917
			for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
   918
				if (IsValidPlayerID(i)) {
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   919
					/* Lower the widget corresponding to this player. */
9747
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   920
					this->LowerWidget(i + PRW_PLAYER_FIRST);
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   921
					this->SetDirty();
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   922
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   923
					player = i;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   924
					break;
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   925
				}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   926
			}
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   927
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   928
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   929
		/* If there are no active players, don't display anything else. */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   930
		if (player == INVALID_PLAYER) return;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   931
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   932
		/* Paint the player icons */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   933
		for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9525
diff changeset
   934
			if (!IsValidPlayerID(i)) {
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   935
				/* Check if we have the player as an active player */
9747
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   936
				if (!this->IsWidgetDisabled(i + PRW_PLAYER_FIRST)) {
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   937
					/* Bah, player gone :( */
9747
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   938
					this->DisableWidget(i + PRW_PLAYER_FIRST);
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   939
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   940
					/* We need a repaint */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   941
					this->SetDirty();
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   942
				}
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   943
				continue;
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
   944
			}
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   945
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   946
			/* Check if we have the player marked as inactive */
9747
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   947
			if (this->IsWidgetDisabled(i + PRW_PLAYER_FIRST)) {
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   948
				/* New player! Yippie :p */
9747
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
   949
				this->EnableWidget(i + PRW_PLAYER_FIRST);
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   950
				/* We need a repaint */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   951
				this->SetDirty();
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   952
			}
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   953
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   954
			x = (i == player) ? 1 : 0;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   955
			DrawPlayerIcon(i, i * 37 + 13 + x, 16 + x);
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   956
		}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   957
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   958
		/* The colors used to show how the progress is going */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   959
		color_done = _colour_gradient[COLOUR_GREEN][4];
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   960
		color_notdone = _colour_gradient[COLOUR_RED][4];
8179
60c4282e6de6 (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
parents: 8140
diff changeset
   961
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   962
		/* Draw all the score parts */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   963
		for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) {
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   964
			int val    = _score_part[player][i];
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   965
			int needed = _score_info[i].needed;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   966
			int score  = _score_info[i].score;
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
   967
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   968
			y += 20;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   969
			/* SCORE_TOTAL has his own rulez ;) */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   970
			if (i == SCORE_TOTAL) {
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   971
				needed = total_score;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   972
				score = SCORE_MAX;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   973
			} else {
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   974
				total_score += score;
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   975
			}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   976
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   977
			DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, TC_FROMSTRING);
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   978
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   979
			/* Draw the score */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   980
			SetDParam(0, score);
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   981
			DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, TC_FROMSTRING);
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   982
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   983
			/* Calculate the %-bar */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   984
			x = Clamp(val, 0, needed) * 50 / needed;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   985
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   986
			/* SCORE_LOAN is inversed */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   987
			if (val < 0 && i == SCORE_LOAN) x = 0;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   988
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   989
			/* Draw the bar */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   990
			if (x !=  0) GfxFillRect(112,     y - 2, 112 + x,  y + 10, color_done);
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   991
			if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone);
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   992
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   993
			/* Calculate the % */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   994
			x = Clamp(val, 0, needed) * 100 / needed;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   995
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   996
			/* SCORE_LOAN is inversed */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   997
			if (val < 0 && i == SCORE_LOAN) x = 0;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   998
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
   999
			/* Draw it */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1000
			SetDParam(0, x);
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1001
			DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING);
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1002
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1003
			/* SCORE_LOAN is inversed */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1004
			if (i == SCORE_LOAN) val = needed - val;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1005
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1006
			/* Draw the amount we have against what is needed
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1007
				* For some of them it is in currency format */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1008
			SetDParam(0, val);
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1009
			SetDParam(1, needed);
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1010
			switch (i) {
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1011
				case SCORE_MIN_PROFIT:
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1012
				case SCORE_MIN_INCOME:
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1013
				case SCORE_MAX_INCOME:
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1014
				case SCORE_MONEY:
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1015
				case SCORE_LOAN:
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1016
					DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, TC_FROMSTRING);
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1017
					break;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1018
				default:
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1019
					DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, TC_FROMSTRING);
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1020
			}
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1021
		}
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1022
	}
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1023
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1024
	virtual void OnClick(Point pt, int widget)
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1025
	{
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1026
		/* Check which button is clicked */
9747
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
  1027
		if (IsInsideMM(widget, PRW_PLAYER_FIRST, PRW_PLAYER_LAST + 1)) {
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1028
			/* Is it no on disable? */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1029
			if (!this->IsWidgetDisabled(widget)) {
9747
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
  1030
				this->RaiseWidget(player + PRW_PLAYER_FIRST);
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
  1031
				player = (PlayerID)(widget - PRW_PLAYER_FIRST);
e1a79972c171 (svn r13882) -Codechange: Replace widget numbers with appropriate enums
belugas
parents: 9659
diff changeset
  1032
				this->LowerWidget(player + PRW_PLAYER_FIRST);
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1033
				this->SetDirty();
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1034
			}
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1035
		}
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1036
	}
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1037
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1038
	virtual void OnTick()
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1039
	{
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1040
		if (_pause_game != 0) return;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1041
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1042
		/* Update the player score every 5 days */
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1043
		if (--this->timeout == 0) {
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1044
			this->UpdatePlayerStats();
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1045
			this->SetDirty();
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1046
		}
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1047
	}
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1048
};
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1049
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1050
PlayerID PerformanceRatingDetailWindow::player = INVALID_PLAYER;
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1051
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1052
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1053
static const Widget _performance_rating_detail_widgets[] = {
9748
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1054
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1055
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   298,     0,    13, STR_PERFORMANCE_DETAIL, STR_018C_WINDOW_TITLE_DRAG_THIS},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1056
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   298,    14,    27, 0x0,                    STR_NULL},
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1057
9748
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1058
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   298,    28,    47, 0x0,                    STR_PERFORMANCE_DETAIL_VEHICLES_TIP},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1059
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   298,    48,    67, 0x0,                    STR_PERFORMANCE_DETAIL_STATIONS_TIP},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1060
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   298,    68,    87, 0x0,                    STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1061
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   298,    88,   107, 0x0,                    STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1062
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   298,   108,   127, 0x0,                    STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1063
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   298,   128,   147, 0x0,                    STR_PERFORMANCE_DETAIL_DELIVERED_TIP},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1064
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   298,   148,   167, 0x0,                    STR_PERFORMANCE_DETAIL_CARGO_TIP},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1065
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   298,   168,   187, 0x0,                    STR_PERFORMANCE_DETAIL_MONEY_TIP},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1066
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   298,   188,   207, 0x0,                    STR_PERFORMANCE_DETAIL_LOAN_TIP},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1067
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   298,   208,   227, 0x0,                    STR_PERFORMANCE_DETAIL_TOTAL_TIP},
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1068
9748
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1069
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     2,    38,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1070
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,    39,    75,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1071
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,    76,   112,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1072
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,   113,   149,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1073
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,   150,   186,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1074
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,   187,   223,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1075
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,   224,   260,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9b3dd7b52b29 (svn r13883) -Codechange: Replace numbers with Colours enum on graph gui
belugas
parents: 9747
diff changeset
  1076
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,   261,   297,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 165
diff changeset
  1077
{   WIDGETS_END},
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1078
};
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1079
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1080
static const WindowDesc _performance_rating_detail_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
  1081
	WDP_AUTO, WDP_AUTO, 299, 228, 299, 228,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
  1082
	WC_PERFORMANCE_DETAIL, WC_NONE,
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1083
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1084
	_performance_rating_detail_widgets,
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1085
};
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1086
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6203
diff changeset
  1087
void ShowPerformanceRatingDetail()
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1088
{
9255
e9877474e173 (svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents: 9143
diff changeset
  1089
	AllocateWindowDescFront<PerformanceRatingDetailWindow>(&_performance_rating_detail_desc, 0);
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1090
}