src/graph_gui.cpp
author glx
Fri, 13 Jun 2008 15:43:39 +0000
branchnoai
changeset 10955 56b381e5253f
parent 10715 6bdf79ffb022
child 11044 097ea3e7ec56
permissions -rw-r--r--
(svn r13509) [NoAI] -Sync: with trunk r13472:13508.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
10455
22c441f5adf9 (svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents: 9724
diff changeset
     3
/** @file graph_gui.cpp GUI that shows performance graphs. */
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6417
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (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"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
     8
#include "window_gui.h"
9724
b39bc69bb2f2 (svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents: 9723
diff changeset
     9
#include "player_base.h"
b39bc69bb2f2 (svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents: 9723
diff changeset
    10
#include "player_gui.h"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    11
#include "economy_func.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2135
diff changeset
    12
#include "variables.h"
6417
26acff62d001 (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: 6197
diff changeset
    13
#include "cargotype.h"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    14
#include "strings_func.h"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    15
#include "core/alloc_func.hpp"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    16
#include "window_func.h"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    17
#include "date_func.h"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    18
#include "gfx_func.h"
5291
5e4d9ab3cc0f (svn r7444) -Codechange: Use one (global) cargo-colours array for drawing cargo-colours. Change Food
Darkvater
parents: 5247
diff changeset
    19
9724
b39bc69bb2f2 (svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents: 9723
diff changeset
    20
#include "table/strings.h"
b39bc69bb2f2 (svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents: 9723
diff changeset
    21
#include "table/sprites.h"
b39bc69bb2f2 (svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents: 9723
diff changeset
    22
6057
8f1388f239b3 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 6056
diff changeset
    23
/* Bitmasks of player and cargo indices that shouldn't be drawn. */
8f1388f239b3 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 6056
diff changeset
    24
static uint _legend_excluded_players;
8f1388f239b3 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 6056
diff changeset
    25
static uint _legend_excluded_cargo;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
6056
879b00467368 (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: 6055
diff changeset
    27
/* Apparently these don't play well with enums. */
9724
b39bc69bb2f2 (svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents: 9723
diff changeset
    28
static const OverflowSafeInt64 INVALID_DATAPOINT(INT64_MAX); // Value used for a datapoint that shouldn't be drawn.
9722
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 9703
diff changeset
    29
static const uint INVALID_DATAPOINT_POS = UINT_MAX;  // Used to determine if the previous point was drawn.
6056
879b00467368 (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: 6055
diff changeset
    30
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
/* GRAPH LEGEND */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    35
struct GraphLegendWindow : Window {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    36
	GraphLegendWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    37
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    38
		for (uint i = 3; i < this->widget_count; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    39
			if (!HasBit(_legend_excluded_players, i - 3)) this->LowerWidget(i);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    42
		this->FindWindowPlacementAndResize(desc);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    43
	}
6529
c53737959606 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6518
diff changeset
    44
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    45
	virtual void OnPaint()
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    46
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    47
		const Player *p;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    48
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    49
		FOR_ALL_PLAYERS(p) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    50
			if (p->is_active) continue;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    51
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    52
			SetBit(_legend_excluded_players, p->index);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    53
			this->RaiseWidget(p->index + 3);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    54
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    55
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    56
		this->DrawWidgets();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    57
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    58
		FOR_ALL_PLAYERS(p) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    59
			if (!p->is_active) continue;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    60
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    61
			DrawPlayerIcon(p->index, 4, 18 + p->index * 12);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    62
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    63
			SetDParam(0, p->index);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    64
			SetDParam(1, p->index);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    65
			DrawString(21, 17 + p->index * 12, STR_7021, HasBit(_legend_excluded_players, p->index) ? TC_BLACK : TC_WHITE);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    66
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
	}
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    68
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    69
	virtual void OnClick(Point pt, int widget)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    70
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    71
		if (!IsInsideMM(widget, 3, 11)) return;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    72
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    73
		ToggleBit(_legend_excluded_players, widget - 3);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    74
		this->ToggleWidgetLoweredState(widget);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    75
		this->SetDirty();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    76
		InvalidateWindow(WC_INCOME_GRAPH, 0);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    77
		InvalidateWindow(WC_OPERATING_PROFIT, 0);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    78
		InvalidateWindow(WC_DELIVERED_CARGO, 0);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    79
		InvalidateWindow(WC_PERFORMANCE_HISTORY, 0);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    80
		InvalidateWindow(WC_COMPANY_VALUE, 0);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    81
	}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
    82
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
static const Widget _graph_legend_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
    85
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
    86
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   249,     0,    13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
    87
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   249,    14,   113, 0x0,                            STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
    88
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    16,    27, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
    89
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    28,    39, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
    90
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    40,    51, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
    91
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    52,    63, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
    92
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    64,    75, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
    93
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    76,    87, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
    94
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    88,    99, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
    95
{      WWT_PANEL,   RESIZE_NONE,    14,     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
    96
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
static const WindowDesc _graph_legend_desc = {
9694
e72987579514 (svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents: 9686
diff changeset
   100
	WDP_AUTO, WDP_AUTO, 250, 114, 250, 114,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6063
diff changeset
   101
	WC_GRAPH_LEGEND, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
	_graph_legend_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6529
diff changeset
   106
static void ShowGraphLegend()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
{
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   108
	AllocateWindowDescFront<GraphLegendWindow>(&_graph_legend_desc, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   111
/******************/
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   112
/* BASE OF GRAPHS */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   113
/*****************/
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   114
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   115
struct BaseGraphWindow : Window {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   116
protected:
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   117
	enum {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   118
		GRAPH_MAX_DATASETS = 32,
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   119
		GRAPH_AXIS_LABEL_COLOUR = TC_BLACK,
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   120
		GRAPH_AXIS_LINE_COLOUR  = 215,
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   121
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   122
		GRAPH_X_POSITION_BEGINNING  = 44,  ///< Start the graph 44 pixels from gd_left
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   123
		GRAPH_X_POSITION_SEPARATION = 22,  ///< There are 22 pixels between each X value
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   124
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   125
		GRAPH_NUM_LINES_Y = 9, ///< How many horizontal lines to draw.
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   126
		/* 9 is convenient as that means the distance between them is the gd_height of the graph / 8,
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   127
		* which is the same
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   128
		* as height >> 3. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   129
	};
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   130
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   131
	uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed.
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   132
	byte num_dataset;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   133
	byte num_on_x_axis;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   134
	bool has_negative_values;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   135
	byte num_vert_lines;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   136
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   137
	/* The starting month and year that values are plotted against. If month is
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   138
	 * 0xFF, use x_values_start and x_values_increment below instead. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   139
	byte month;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   140
	Year year;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   141
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   142
	/* These values are used if the graph is being plotted against values
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   143
	 * rather than the dates specified by month and year. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   144
	uint16 x_values_start;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   145
	uint16 x_values_increment;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   146
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   147
	int gd_left, gd_top;  ///< Where to start drawing the graph, in pixels.
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   148
	uint gd_height;    ///< The height of the graph in pixels.
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   149
	StringID format_str_y_axis;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   150
	byte colors[GRAPH_MAX_DATASETS];
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   151
	OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   152
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   153
	void DrawGraph() const
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   154
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   155
		uint x, y;                       ///< Reused whenever x and y coordinates are needed.
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   156
		OverflowSafeInt64 highest_value; ///< Highest value to be drawn.
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   157
		int x_axis_offset;               ///< Distance from the top of the graph to the x axis.
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   158
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   159
		/* the colors and cost array of GraphDrawer must accomodate
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   160
		* both values for cargo and players. So if any are higher, quit */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   161
		assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_PLAYERS);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   162
		assert(this->num_vert_lines > 0);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   163
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   164
		byte grid_colour = _colour_gradient[14][4];
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   165
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   166
		/* The coordinates of the opposite edges of the graph. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   167
		int bottom = this->gd_top + this->gd_height - 1;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   168
		int right  = this->gd_left + GRAPH_X_POSITION_BEGINNING + this->num_vert_lines * GRAPH_X_POSITION_SEPARATION - 1;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   169
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   170
		/* Draw the vertical grid lines. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   171
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   172
		/* Don't draw the first line, as that's where the axis will be. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   173
		x = this->gd_left + GRAPH_X_POSITION_BEGINNING + GRAPH_X_POSITION_SEPARATION;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   174
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   175
		for (int i = 0; i < this->num_vert_lines; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   176
			GfxFillRect(x, this->gd_top, x, bottom, grid_colour);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   177
			x += GRAPH_X_POSITION_SEPARATION;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   178
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   179
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   180
		/* Draw the horizontal grid lines. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   181
		x = this->gd_left + GRAPH_X_POSITION_BEGINNING;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   182
		y = this->gd_height + this->gd_top;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   183
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   184
		for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   185
			GfxFillRect(x, y, right, y, grid_colour);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   186
			y -= (this->gd_height / (GRAPH_NUM_LINES_Y - 1));
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   187
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   188
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   189
		/* Draw the y axis. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   190
		GfxFillRect(x, this->gd_top, x, bottom, GRAPH_AXIS_LINE_COLOUR);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   191
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   192
		/* Find the distance from the gd_top of the graph to the x axis. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   193
		x_axis_offset = this->gd_height;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   194
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   195
		/* The graph is currently symmetrical about the x axis. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   196
		if (this->has_negative_values) x_axis_offset /= 2;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   197
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   198
		/* Draw the x axis. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   199
		y = x_axis_offset + this->gd_top;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   200
		GfxFillRect(x, y, right, y, GRAPH_AXIS_LINE_COLOUR);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   201
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   202
		/* Find the largest value that will be drawn. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   203
		if (this->num_on_x_axis == 0)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   204
			return;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   205
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   206
		assert(this->num_on_x_axis > 0);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   207
		assert(this->num_dataset > 0);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   208
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   209
		/* Start of with a value of twice the gd_height of the graph in pixels. It's a
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   210
		* bit arbitrary, but it makes the cargo payment graph look a little nicer,
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   211
		* and prevents division by zero when calculating where the datapoint
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   212
		* should be drawn. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   213
		highest_value = x_axis_offset * 2;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   214
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   215
		for (int i = 0; i < this->num_dataset; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   216
			if (!HasBit(this->excluded_data, i)) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   217
				for (int j = 0; j < this->num_on_x_axis; j++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   218
					OverflowSafeInt64 datapoint = this->cost[i][j];
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   219
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   220
					if (datapoint != INVALID_DATAPOINT) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   221
						/* For now, if the graph has negative values the scaling is
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   222
						* symmetrical about the x axis, so take the absolute value
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   223
						* of each data point. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   224
						highest_value = max(highest_value, abs(datapoint));
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   225
					}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   226
				}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   227
			}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   228
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   229
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   230
		/* Round up highest_value so that it will divide cleanly into the number of
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   231
		* axis labels used. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   232
		int round_val = highest_value % (GRAPH_NUM_LINES_Y - 1);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   233
		if (round_val != 0) highest_value += (GRAPH_NUM_LINES_Y - 1 - round_val);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   234
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   235
		/* draw text strings on the y axis */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   236
		int64 y_label = highest_value;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   237
		int64 y_label_separation = highest_value / (GRAPH_NUM_LINES_Y - 1);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   238
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   239
		/* If there are negative values, the graph goes from highest_value to
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   240
		* -highest_value, not highest_value to 0. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   241
		if (this->has_negative_values) y_label_separation *= 2;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   242
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   243
		x = this->gd_left + GRAPH_X_POSITION_BEGINNING + 1;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   244
		y = this->gd_top - 3;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   245
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   246
		for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   247
			SetDParam(0, this->format_str_y_axis);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   248
			SetDParam(1, y_label);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   249
			DrawStringRightAligned(x, y, STR_0170, GRAPH_AXIS_LABEL_COLOUR);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   250
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   251
			y_label -= y_label_separation;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   252
			y += (this->gd_height / (GRAPH_NUM_LINES_Y - 1));
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   253
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   254
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   255
		/* draw strings on the x axis */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   256
		if (this->month != 0xFF) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   257
			x = this->gd_left + GRAPH_X_POSITION_BEGINNING;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   258
			y = this->gd_top + this->gd_height + 1;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   259
			byte month = this->month;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   260
			Year year  = this->year;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   261
			for (int i = 0; i < this->num_on_x_axis; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   262
				SetDParam(0, month + STR_0162_JAN);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   263
				SetDParam(1, month + STR_0162_JAN + 2);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   264
				SetDParam(2, year);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   265
				DrawString(x, y, month == 0 ? STR_016F : STR_016E, GRAPH_AXIS_LABEL_COLOUR);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   266
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   267
				month += 3;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   268
				if (month >= 12) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   269
					month = 0;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   270
					year++;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   271
				}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   272
				x += GRAPH_X_POSITION_SEPARATION;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   273
			}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   274
		} else {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   275
			/* Draw the label under the data point rather than on the grid line. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   276
			x = this->gd_left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2) + 1;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   277
			y = this->gd_top + this->gd_height + 1;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   278
			uint16 label = this->x_values_start;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   279
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   280
			for (int i = 0; i < this->num_on_x_axis; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   281
				SetDParam(0, label);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   282
				DrawStringCentered(x, y, STR_01CB, GRAPH_AXIS_LABEL_COLOUR);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   283
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   284
				label += this->x_values_increment;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   285
				x += GRAPH_X_POSITION_SEPARATION;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   286
			}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   287
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   288
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   289
		/* draw lines and dots */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   290
		for (int i = 0; i < this->num_dataset; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   291
			if (!HasBit(this->excluded_data, i)) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   292
				/* Centre the dot between the grid lines. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   293
				x = this->gd_left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   294
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   295
				byte color  = this->colors[i];
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   296
				uint prev_x = INVALID_DATAPOINT_POS;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   297
				uint prev_y = INVALID_DATAPOINT_POS;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   298
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   299
				for (int j = 0; j < this->num_on_x_axis; j++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   300
					OverflowSafeInt64 datapoint = this->cost[i][j];
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   301
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   302
					if (datapoint != INVALID_DATAPOINT) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   303
						/*
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   304
						* Check whether we need to reduce the 'accuracy' of the
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   305
						* datapoint value and the highest value to splut overflows.
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   306
						* And when 'drawing' 'one million' or 'one million and one'
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   307
						* there is no significant difference, so the least
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   308
						* significant bits can just be removed.
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   309
						*
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   310
						* If there are more bits needed than would fit in a 32 bits
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   311
						* integer, so at about 31 bits because of the sign bit, the
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   312
						* least significant bits are removed.
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   313
						*/
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   314
						int mult_range = FindLastBit(x_axis_offset) + FindLastBit(abs(datapoint));
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   315
						int reduce_range = max(mult_range - 31, 0);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   316
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   317
						/* Handle negative values differently (don't shift sign) */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   318
						if (datapoint < 0) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   319
							datapoint = -(abs(datapoint) >> reduce_range);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   320
						} else {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   321
							datapoint >>= reduce_range;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   322
						}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   323
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   324
						y = this->gd_top + x_axis_offset - (x_axis_offset * datapoint) / (highest_value >> reduce_range);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   325
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   326
						/* Draw the point. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   327
						GfxFillRect(x - 1, y - 1, x + 1, y + 1, color);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   328
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   329
						/* Draw the line connected to the previous point. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   330
						if (prev_x != INVALID_DATAPOINT_POS) GfxDrawLine(prev_x, prev_y, x, y, color);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   331
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   332
						prev_x = x;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   333
						prev_y = y;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   334
					} else {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   335
						prev_x = INVALID_DATAPOINT_POS;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   336
						prev_y = INVALID_DATAPOINT_POS;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   337
					}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   338
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   339
					x += GRAPH_X_POSITION_SEPARATION;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   340
				}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   341
			}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   342
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   343
	}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   344
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   345
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   346
	BaseGraphWindow(const WindowDesc *desc, WindowNumber window_number, int left,
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   347
									int top, int height, bool has_negative_values, StringID format_str_y_axis) :
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   348
			Window(desc, window_number), has_negative_values(has_negative_values),
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   349
			gd_left(left), gd_top(top), gd_height(height), format_str_y_axis(format_str_y_axis)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   350
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   351
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   352
	}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   353
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   354
public:
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   355
	virtual void OnPaint()
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   356
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   357
		this->DrawWidgets();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   358
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   359
		uint excluded_players = _legend_excluded_players;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   360
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   361
		/* Exclude the players which aren't valid */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   362
		const Player* p;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   363
		FOR_ALL_PLAYERS(p) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   364
			if (!p->is_active) SetBit(excluded_players, p->index);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   365
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   366
		this->excluded_data = excluded_players;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   367
		this->num_vert_lines = 24;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   368
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   369
		byte nums = 0;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   370
		FOR_ALL_PLAYERS(p) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   371
			if (p->is_active) nums = max(nums, p->num_valid_stat_ent);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   372
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   373
		this->num_on_x_axis = min(nums, 24);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   374
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   375
		int mo = (_cur_month / 3 - nums) * 3;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   376
		int yr = _cur_year;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   377
		while (mo < 0) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   378
			yr--;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   379
			mo += 12;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   380
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   381
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   382
		this->year = yr;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   383
		this->month = mo;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   384
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   385
		int numd = 0;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   386
		FOR_ALL_PLAYERS(p) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   387
			if (p->is_active) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   388
				this->colors[numd] = _colour_gradient[p->player_color][6];
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   389
				for (int j = this->num_on_x_axis, i = 0; --j >= 0;) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   390
					this->cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : GetGraphData(p, j);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   391
					i++;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   392
				}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   393
			}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   394
			numd++;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   395
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   396
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   397
		this->num_dataset = numd;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   398
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   399
		this->DrawGraph();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   400
	}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   401
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   402
	virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   403
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   404
		return INVALID_DATAPOINT;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   405
	}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   406
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   407
	virtual void OnClick(Point pt, int widget)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   408
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   409
		/* Clicked on legend? */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   410
		if (widget == 2) ShowGraphLegend();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   411
	}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   412
};
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   413
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
/********************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
/* OPERATING PROFIT */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
/********************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   418
struct OperatingProfitGraphWindow : BaseGraphWindow {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   419
	OperatingProfitGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   420
			BaseGraphWindow(desc, window_number, 2, 18, 136, true, STR_CURRCOMPACT)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   421
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   422
		this->FindWindowPlacementAndResize(desc);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   425
	virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   426
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   427
		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
   428
	}
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   429
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
static const Widget _operating_profit_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   432
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   433
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7025_OPERATING_PROFIT_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   434
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,                    STR_704D_SHOW_KEY_TO_GRAPHS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   435
{      WWT_PANEL,   RESIZE_NONE,    14,     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
   436
{   WIDGETS_END},
0
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
static const WindowDesc _operating_profit_desc = {
9694
e72987579514 (svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents: 9686
diff changeset
   440
	WDP_AUTO, WDP_AUTO, 576, 174, 576, 174,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6063
diff changeset
   441
	WC_OPERATING_PROFIT, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
	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
   443
	_operating_profit_widgets,
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6529
diff changeset
   447
void ShowOperatingProfitGraph()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
{
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   449
	AllocateWindowDescFront<OperatingProfitGraphWindow>(&_operating_profit_desc, 0);
0
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
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
/* INCOME GRAPH */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   457
struct IncomeGraphWindow : BaseGraphWindow {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   458
	IncomeGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   459
			BaseGraphWindow(desc, window_number, 2, 18, 104, false, STR_CURRCOMPACT)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   460
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   461
		this->FindWindowPlacementAndResize(desc);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   462
	}
6529
c53737959606 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6518
diff changeset
   463
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   464
	virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   465
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   466
		return p->old_economy[j].income;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
	}
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   468
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
static const Widget _income_graph_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   471
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   472
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7022_INCOME_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   473
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,          STR_704D_SHOW_KEY_TO_GRAPHS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   474
{      WWT_PANEL,   RESIZE_NONE,    14,     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
   475
{   WIDGETS_END},
0
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
static const WindowDesc _income_graph_desc = {
9694
e72987579514 (svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents: 9686
diff changeset
   479
	WDP_AUTO, WDP_AUTO, 576, 142, 576, 142,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6063
diff changeset
   480
	WC_INCOME_GRAPH, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
	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
   482
	_income_graph_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6529
diff changeset
   485
void ShowIncomeGraph()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   486
{
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   487
	AllocateWindowDescFront<IncomeGraphWindow>(&_income_graph_desc, 0);
0
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
/*******************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
/* DELIVERED CARGO */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   492
/*******************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   493
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   494
struct DeliveredCargoGraphWindow : BaseGraphWindow {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   495
	DeliveredCargoGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   496
			BaseGraphWindow(desc, window_number, 2, 18, 104, false, STR_7024)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   497
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   498
		this->FindWindowPlacementAndResize(desc);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   499
	}
6529
c53737959606 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6518
diff changeset
   500
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   501
	virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   502
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   503
		return p->old_economy[j].delivered_cargo;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
	}
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   505
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
static const Widget _delivered_cargo_graph_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   508
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   509
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7050_UNITS_OF_CARGO_DELIVERED, STR_018C_WINDOW_TITLE_DRAG_THIS},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   510
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,                      STR_704D_SHOW_KEY_TO_GRAPHS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   511
{      WWT_PANEL,   RESIZE_NONE,    14,     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
   512
{   WIDGETS_END},
0
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
static const WindowDesc _delivered_cargo_graph_desc = {
9694
e72987579514 (svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents: 9686
diff changeset
   516
	WDP_AUTO, WDP_AUTO, 576, 142, 576, 142,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6063
diff changeset
   517
	WC_DELIVERED_CARGO, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
	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
   519
	_delivered_cargo_graph_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6529
diff changeset
   522
void ShowDeliveredCargoGraph()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   523
{
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   524
	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
   525
}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   526
1086
9d00ef71146e (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
/***********************/
9d00ef71146e (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
/* PERFORMANCE HISTORY */
9d00ef71146e (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
/***********************/
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   530
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   531
struct PerformanceHistoryGraphWindow : BaseGraphWindow {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   532
	PerformanceHistoryGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   533
			BaseGraphWindow(desc, window_number, 2, 18, 200, false, STR_7024)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   534
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   535
		this->FindWindowPlacementAndResize(desc);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   536
	}
6529
c53737959606 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6518
diff changeset
   537
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   538
	virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   539
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   540
		return p->old_economy[j].performance_history;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   541
	}
6529
c53737959606 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6518
diff changeset
   542
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   543
	virtual void OnClick(Point pt, int widget)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   544
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   545
		if (widget == 3) ShowPerformanceRatingDetail();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   546
		this->BaseGraphWindow::OnClick(pt, widget);
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   547
	}
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   548
};
1086
9d00ef71146e (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
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   550
static const Widget _performance_history_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   551
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                             STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   552
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   475,     0,    13, STR_7051_COMPANY_PERFORMANCE_RATINGS, STR_018C_WINDOW_TITLE_DRAG_THIS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   553
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,                         STR_704D_SHOW_KEY_TO_GRAPHS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   554
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   476,   525,     0,    13, STR_PERFORMANCE_DETAIL_KEY,           STR_704D_SHOW_KEY_TO_GRAPHS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   555
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   575,    14,   237, 0x0,                                  STR_NULL},
1086
9d00ef71146e (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
{   WIDGETS_END},
9d00ef71146e (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
};
9d00ef71146e (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
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   559
static const WindowDesc _performance_history_desc = {
9694
e72987579514 (svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents: 9686
diff changeset
   560
	WDP_AUTO, WDP_AUTO, 576, 238, 576, 238,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6063
diff changeset
   561
	WC_PERFORMANCE_HISTORY, WC_NONE,
1086
9d00ef71146e (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
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
9d00ef71146e (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
	_performance_history_widgets,
9d00ef71146e (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
};
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   565
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6529
diff changeset
   566
void ShowPerformanceHistoryGraph()
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   567
{
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   568
	AllocateWindowDescFront<PerformanceHistoryGraphWindow>(&_performance_history_desc, 0);
1086
9d00ef71146e (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
}
9d00ef71146e (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
9d00ef71146e (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
/*****************/
9d00ef71146e (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
/* COMPANY VALUE */
9d00ef71146e (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
/*****************/
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   574
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   575
struct CompanyValueGraphWindow : BaseGraphWindow {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   576
	CompanyValueGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   577
			BaseGraphWindow(desc, window_number, 2, 18, 200, false, STR_CURRCOMPACT)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   578
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   579
		this->FindWindowPlacementAndResize(desc);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   580
	}
6529
c53737959606 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6518
diff changeset
   581
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   582
	virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   583
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   584
		return p->old_economy[j].company_value;
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   585
	}
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   586
};
1086
9d00ef71146e (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
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   588
static const Widget _company_value_graph_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   589
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   590
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7052_COMPANY_VALUES, STR_018C_WINDOW_TITLE_DRAG_THIS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   591
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,            STR_704D_SHOW_KEY_TO_GRAPHS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   592
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   575,    14,   237, 0x0,                     STR_NULL},
1086
9d00ef71146e (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
{   WIDGETS_END},
9d00ef71146e (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
};
9d00ef71146e (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
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   596
static const WindowDesc _company_value_graph_desc = {
9694
e72987579514 (svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents: 9686
diff changeset
   597
	WDP_AUTO, WDP_AUTO, 576, 238, 576, 238,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6063
diff changeset
   598
	WC_COMPANY_VALUE, WC_NONE,
1086
9d00ef71146e (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
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
9d00ef71146e (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
	_company_value_graph_widgets,
9d00ef71146e (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
};
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   602
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6529
diff changeset
   603
void ShowCompanyValueGraph()
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   604
{
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   605
	AllocateWindowDescFront<CompanyValueGraphWindow>(&_company_value_graph_desc, 0);
1086
9d00ef71146e (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
}
9d00ef71146e (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
9d00ef71146e (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
/*****************/
9d00ef71146e (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
/* PAYMENT RATES */
9d00ef71146e (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
/*****************/
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   611
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   612
struct PaymentRatesGraphWindow : BaseGraphWindow {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   613
	PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   614
			BaseGraphWindow(desc, window_number, 2, 24, 200, false, STR_CURRCOMPACT)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   615
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   616
		uint num_active = 0;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   617
		for (CargoID c = 0; c < NUM_CARGO; c++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   618
			if (GetCargo(c)->IsValid()) num_active++;
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   619
		}
6529
c53737959606 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6518
diff changeset
   620
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   621
		/* Resize the window to fit the cargo types */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   622
		ResizeWindow(this, 0, max(num_active, 12U) * 8);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   623
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   624
		/* Add widgets for each cargo type */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   625
		this->widget_count += num_active;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   626
		this->widget = ReallocT(this->widget, this->widget_count + 1);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   627
		this->widget[this->widget_count].type = WWT_LAST;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   628
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   629
		/* Set the properties of each widget */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   630
		for (uint i = 0; i != num_active; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   631
			Widget *wi = &this->widget[3 + i];
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   632
			wi->type     = WWT_PANEL;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   633
			wi->display_flags = RESIZE_NONE;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   634
			wi->color    = 12;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   635
			wi->left     = 493;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   636
			wi->right    = 562;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   637
			wi->top      = 24 + i * 8;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   638
			wi->bottom   = wi->top + 7;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   639
			wi->data     = 0;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   640
			wi->tooltips = STR_7064_TOGGLE_GRAPH_FOR_CARGO;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   641
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   642
			if (!HasBit(_legend_excluded_cargo, i)) this->LowerWidget(i + 3);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   643
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   644
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   645
		this->SetDirty();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   646
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   647
		this->gd_height = this->height - 38;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   648
		this->num_on_x_axis = 20;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   649
		this->num_vert_lines = 20;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   650
		this->month = 0xFF;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   651
		this->x_values_start     = 10;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   652
		this->x_values_increment = 10;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   653
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   654
		this->FindWindowPlacementAndResize(desc);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   655
	}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   656
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   657
	virtual void OnPaint()
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   658
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   659
		this->DrawWidgets();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   660
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   661
		this->excluded_data = _legend_excluded_cargo;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   662
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   663
		int x = 495;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   664
		int y = 24;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   665
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   666
		uint i = 0;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   667
		for (CargoID c = 0; c < NUM_CARGO; c++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   668
			const CargoSpec *cs = GetCargo(c);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   669
			if (!cs->IsValid()) continue;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   670
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   671
			/* Only draw labels for widgets that exist. If the widget doesn't
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   672
				* exist then the local player has used the climate cheat or
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   673
				* changed the NewGRF configuration with this window open. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   674
			if (i + 3 < this->widget_count) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   675
				/* Since the buttons have no text, no images,
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   676
					* both the text and the colored box have to be manually painted.
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   677
					* clk_dif will move one pixel down and one pixel to the right
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   678
					* when the button is clicked */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   679
				byte clk_dif = this->IsWidgetLowered(i + 3) ? 1 : 0;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   680
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   681
				GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   682
				GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   683
				SetDParam(0, cs->name);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   684
				DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, TC_FROMSTRING);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   685
				y += 8;
6529
c53737959606 (svn r8989) -Fix: more indenting and variable scoping
peter1138
parents: 6518
diff changeset
   686
			}
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   687
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   688
			this->colors[i] = cs->legend_colour;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   689
			for (uint j = 0; j != 20; j++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   690
				this->cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 6 + 6, c);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   691
			}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   692
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   693
			i++;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   694
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   695
		this->num_dataset = i;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   696
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   697
		this->DrawGraph();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   698
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   699
		DrawString(2 + 46, 24 + this->gd_height + 7, STR_7062_DAYS_IN_TRANSIT, TC_FROMSTRING);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   700
		DrawString(2 + 84, 24 - 9, STR_7063_PAYMENT_FOR_DELIVERING, TC_FROMSTRING);
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   701
	}
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   702
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   703
	virtual void OnClick(Point pt, int widget)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   704
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   705
		if (widget >= 3) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   706
			ToggleBit(_legend_excluded_cargo, widget - 3);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   707
			this->ToggleWidgetLoweredState(widget);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   708
			this->SetDirty();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   709
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   710
	}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   711
};
1086
9d00ef71146e (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
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   713
static const Widget _cargo_payment_rates_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   714
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   715
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   567,     0,    13, STR_7061_CARGO_PAYMENT_RATES, STR_018C_WINDOW_TITLE_DRAG_THIS},
6518
c7ac357020e3 (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6505
diff changeset
   716
{      WWT_PANEL, RESIZE_BOTTOM,    14,     0,   567,    14,    45, 0x0,                          STR_NULL},
1086
9d00ef71146e (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
{   WIDGETS_END},
9d00ef71146e (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
};
9d00ef71146e (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
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   720
static const WindowDesc _cargo_payment_rates_desc = {
9694
e72987579514 (svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents: 9686
diff changeset
   721
	WDP_AUTO, WDP_AUTO, 568, 46, 568, 46,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6063
diff changeset
   722
	WC_PAYMENT_RATES, WC_NONE,
1086
9d00ef71146e (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
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
9d00ef71146e (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
	_cargo_payment_rates_widgets,
9d00ef71146e (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
};
9d00ef71146e (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
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   727
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6529
diff changeset
   728
void ShowCargoPaymentRates()
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   729
{
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   730
	AllocateWindowDescFront<PaymentRatesGraphWindow>(&_cargo_payment_rates_desc, 0);
1086
9d00ef71146e (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
}
9d00ef71146e (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
9d00ef71146e (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
/************************/
9d00ef71146e (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
/* COMPANY LEAGUE TABLE */
9d00ef71146e (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
/************************/
9d00ef71146e (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
9d00ef71146e (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
static const StringID _performance_titles[] = {
9d00ef71146e (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,
9d00ef71146e (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_7066_ENGINEER,
9d00ef71146e (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,
9d00ef71146e (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_7067_TRAFFIC_MANAGER,
9d00ef71146e (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,
9d00ef71146e (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_7068_TRANSPORT_COORDINATOR,
9d00ef71146e (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,
9d00ef71146e (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_7069_ROUTE_SUPERVISOR,
9d00ef71146e (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,
9d00ef71146e (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_706A_DIRECTOR,
9d00ef71146e (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,
9d00ef71146e (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_706B_CHIEF_EXECUTIVE,
9d00ef71146e (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,
9d00ef71146e (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_706C_CHAIRMAN,
9d00ef71146e (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_706D_PRESIDENT,
9d00ef71146e (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
	STR_706E_TYCOON,
9d00ef71146e (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
};
9d00ef71146e (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
9d00ef71146e (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
static inline StringID GetPerformanceTitleFromValue(uint value)
9d00ef71146e (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
{
9d00ef71146e (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
	return _performance_titles[minu(value, 1000) >> 6];
9d00ef71146e (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
}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   760
2656
796b75ba15e3 (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   761
static int CDECL PerfHistComp(const void* elem1, const void* elem2)
796b75ba15e3 (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   762
{
796b75ba15e3 (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   763
	const Player* p1 = *(const Player* const*)elem1;
796b75ba15e3 (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   764
	const Player* p2 = *(const Player* const*)elem2;
796b75ba15e3 (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   765
796b75ba15e3 (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   766
	return p2->old_economy[1].performance_history - p1->old_economy[1].performance_history;
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   767
}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   768
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   769
struct CompanyLeagueWindow : Window {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   770
	CompanyLeagueWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   771
	{
10715
6bdf79ffb022 (svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents: 10645
diff changeset
   772
		this->FindWindowPlacementAndResize(desc);
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   773
	}
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   774
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   775
	virtual void OnPaint()
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   776
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   777
		const Player *plist[MAX_PLAYERS];
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   778
		const Player *p;
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   779
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   780
		this->DrawWidgets();
2656
796b75ba15e3 (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   781
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   782
		uint pl_num = 0;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   783
		FOR_ALL_PLAYERS(p) if (p->is_active) plist[pl_num++] = p;
2656
796b75ba15e3 (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   784
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   785
		qsort((void*)plist, pl_num, sizeof(*plist), PerfHistComp);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   786
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   787
		for (uint i = 0; i != pl_num; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   788
			p = plist[i];
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   789
			SetDParam(0, i + STR_01AC_1ST);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   790
			SetDParam(1, p->index);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   791
			SetDParam(2, p->index);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   792
			SetDParam(3, GetPerformanceTitleFromValue(p->old_economy[1].performance_history));
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   793
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   794
			DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, TC_FROMSTRING);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   795
			DrawPlayerIcon(p->index, 27, 16 + i * 10);
2656
796b75ba15e3 (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   796
		}
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   797
	}
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   798
};
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   799
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   800
9d00ef71146e (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
static const Widget _company_league_widgets[] = {
2869
5cf9acd29edd (svn r3417) - Make company league table window pinnable.
peter1138
parents: 2725
diff changeset
   802
{   WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,  0, 13, STR_00C5,                      STR_018B_CLOSE_WINDOW},
5cf9acd29edd (svn r3417) - Make company league table window pinnable.
peter1138
parents: 2725
diff changeset
   803
{    WWT_CAPTION, RESIZE_NONE, 14,  11, 387,  0, 13, STR_7053_COMPANY_LEAGUE_TABLE, STR_018C_WINDOW_TITLE_DRAG_THIS},
5cf9acd29edd (svn r3417) - Make company league table window pinnable.
peter1138
parents: 2725
diff changeset
   804
{  WWT_STICKYBOX, RESIZE_NONE, 14, 388, 399,  0, 13, STR_NULL,                      STR_STICKY_BUTTON},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   805
{      WWT_PANEL, RESIZE_NONE, 14,   0, 399, 14, 96, 0x0,                           STR_NULL},
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   806
{   WIDGETS_END},
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   807
};
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   808
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   809
static const WindowDesc _company_league_desc = {
9694
e72987579514 (svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents: 9686
diff changeset
   810
	WDP_AUTO, WDP_AUTO, 400, 97, 400, 97,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6063
diff changeset
   811
	WC_COMPANY_LEAGUE, WC_NONE,
2869
5cf9acd29edd (svn r3417) - Make company league table window pinnable.
peter1138
parents: 2725
diff changeset
   812
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   813
	_company_league_widgets,
9d00ef71146e (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
};
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   815
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6529
diff changeset
   816
void ShowCompanyLeagueTable()
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   817
{
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   818
	AllocateWindowDescFront<CompanyLeagueWindow>(&_company_league_desc, 0);
1086
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   819
}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   820
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   821
/*****************************/
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   822
/* PERFORMANCE RATING DETAIL */
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   823
/*****************************/
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   824
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   825
struct PerformanceRatingDetailWindow : Window {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   826
	static PlayerID player;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   827
	int timeout;
6197
4ee36c52e467 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 6144
diff changeset
   828
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   829
	PerformanceRatingDetailWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   830
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   831
		/* Disable the players who are not active */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   832
		for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   833
			this->SetWidgetDisabledState(i + 13, !GetPlayer(i)->is_active);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   834
		}
6197
4ee36c52e467 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 6144
diff changeset
   835
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   836
		this->UpdatePlayerStats();
6197
4ee36c52e467 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 6144
diff changeset
   837
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   838
		if (player != INVALID_PLAYER) this->LowerWidget(player + 13);
3027
43ffdf4d6a1f (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   839
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   840
		this->FindWindowPlacementAndResize(desc);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   841
	}
3027
43ffdf4d6a1f (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   842
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   843
	void UpdatePlayerStats()
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   844
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   845
		/* Update all player stats with the current data
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   846
		 * (this is because _score_info is not saved to a savegame) */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   847
		Player *p;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   848
		FOR_ALL_PLAYERS(p) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   849
			if (p->is_active) UpdateCompanyRatingAndValue(p, false);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   850
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   851
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   852
		this->timeout = DAY_TICKS * 5;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   853
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   854
	}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   855
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   856
	virtual void OnPaint()
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   857
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   858
		byte x;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   859
		uint16 y = 14;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   860
		int total_score = 0;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   861
		int color_done, color_notdone;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   862
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   863
		/* Draw standard stuff */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   864
		this->DrawWidgets();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   865
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   866
		/* Check if the currently selected player is still active. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   867
		if (player == INVALID_PLAYER || !GetPlayer(player)->is_active) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   868
			if (player != INVALID_PLAYER) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   869
				/* Raise and disable the widget for the previous selection. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   870
				this->RaiseWidget(player + 13);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   871
				this->DisableWidget(player + 13);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   872
				this->SetDirty();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   873
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   874
				player = INVALID_PLAYER;
3027
43ffdf4d6a1f (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   875
			}
43ffdf4d6a1f (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   876
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   877
			for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   878
				if (GetPlayer(i)->is_active) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   879
					/* Lower the widget corresponding to this player. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   880
					this->LowerWidget(i + 13);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   881
					this->SetDirty();
3027
43ffdf4d6a1f (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   882
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   883
					player = i;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   884
					break;
3027
43ffdf4d6a1f (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   885
				}
43ffdf4d6a1f (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   886
			}
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   887
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   888
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   889
		/* If there are no active players, don't display anything else. */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   890
		if (player == INVALID_PLAYER) return;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   891
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   892
		/* Paint the player icons */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   893
		for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   894
			if (!GetPlayer(i)->is_active) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   895
				/* Check if we have the player as an active player */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   896
				if (!this->IsWidgetDisabled(i + 13)) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   897
					/* Bah, player gone :( */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   898
					this->DisableWidget(i + 13);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   899
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   900
					/* We need a repaint */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   901
					this->SetDirty();
3027
43ffdf4d6a1f (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   902
				}
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   903
				continue;
3033
e4f7c60a1742 (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
   904
			}
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   905
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   906
			/* Check if we have the player marked as inactive */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   907
			if (this->IsWidgetDisabled(i + 13)) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   908
				/* New player! Yippie :p */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   909
				this->EnableWidget(i + 13);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   910
				/* We need a repaint */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   911
				this->SetDirty();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   912
			}
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   913
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   914
			x = (i == player) ? 1 : 0;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   915
			DrawPlayerIcon(i, i * 37 + 13 + x, 16 + x);
3027
43ffdf4d6a1f (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   916
		}
43ffdf4d6a1f (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   917
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   918
		/* The colors used to show how the progress is going */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   919
		color_done = _colour_gradient[COLOUR_GREEN][4];
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   920
		color_notdone = _colour_gradient[COLOUR_RED][4];
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
   921
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   922
		/* Draw all the score parts */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   923
		for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   924
			int val    = _score_part[player][i];
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   925
			int needed = _score_info[i].needed;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   926
			int score  = _score_info[i].score;
3033
e4f7c60a1742 (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
   927
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   928
			y += 20;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   929
			/* SCORE_TOTAL has his own rulez ;) */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   930
			if (i == SCORE_TOTAL) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   931
				needed = total_score;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   932
				score = SCORE_MAX;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   933
			} else {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   934
				total_score += score;
3027
43ffdf4d6a1f (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   935
			}
43ffdf4d6a1f (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   936
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   937
			DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, TC_FROMSTRING);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   938
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   939
			/* Draw the score */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   940
			SetDParam(0, score);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   941
			DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, TC_FROMSTRING);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   942
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   943
			/* Calculate the %-bar */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   944
			x = Clamp(val, 0, needed) * 50 / needed;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   945
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   946
			/* SCORE_LOAN is inversed */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   947
			if (val < 0 && i == SCORE_LOAN) x = 0;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   948
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   949
			/* Draw the bar */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   950
			if (x !=  0) GfxFillRect(112,     y - 2, 112 + x,  y + 10, color_done);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   951
			if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   952
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   953
			/* Calculate the % */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   954
			x = Clamp(val, 0, needed) * 100 / needed;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   955
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   956
			/* SCORE_LOAN is inversed */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   957
			if (val < 0 && i == SCORE_LOAN) x = 0;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   958
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   959
			/* Draw it */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   960
			SetDParam(0, x);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   961
			DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   962
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   963
			/* SCORE_LOAN is inversed */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   964
			if (i == SCORE_LOAN) val = needed - val;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   965
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   966
			/* Draw the amount we have against what is needed
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   967
				* For some of them it is in currency format */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   968
			SetDParam(0, val);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   969
			SetDParam(1, needed);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   970
			switch (i) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   971
				case SCORE_MIN_PROFIT:
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   972
				case SCORE_MIN_INCOME:
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   973
				case SCORE_MAX_INCOME:
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   974
				case SCORE_MONEY:
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   975
				case SCORE_LOAN:
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   976
					DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, TC_FROMSTRING);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   977
					break;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   978
				default:
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   979
					DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, TC_FROMSTRING);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   980
			}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   981
		}
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   982
	}
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   983
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   984
	virtual void OnClick(Point pt, int widget)
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   985
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   986
		/* Check which button is clicked */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   987
		if (IsInsideMM(widget, 13, 21)) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   988
			/* Is it no on disable? */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   989
			if (!this->IsWidgetDisabled(widget)) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   990
				this->RaiseWidget(player + 13);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   991
				player = (PlayerID)(widget - 13);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   992
				this->LowerWidget(player + 13);
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   993
				this->SetDirty();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   994
			}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   995
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   996
	}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   997
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   998
	virtual void OnTick()
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
   999
	{
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1000
		if (_pause_game != 0) return;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1001
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1002
		/* Update the player score every 5 days */
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1003
		if (--this->timeout == 0) {
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1004
			this->UpdatePlayerStats();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1005
			this->SetDirty();
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1006
		}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1007
	}
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1008
};
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1009
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1010
PlayerID PerformanceRatingDetailWindow::player = INVALID_PLAYER;
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1011
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1012
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1013
static const Widget _performance_rating_detail_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
  1014
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
  1015
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   298,     0,    13, STR_PERFORMANCE_DETAIL, STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1016
{      WWT_PANEL,   RESIZE_NONE,    14,     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
  1017
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1018
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    28,    47, 0x0,                    STR_PERFORMANCE_DETAIL_VEHICLES_TIP},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1019
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    48,    67, 0x0,                    STR_PERFORMANCE_DETAIL_STATIONS_TIP},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1020
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    68,    87, 0x0,                    STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1021
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    88,   107, 0x0,                    STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1022
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   108,   127, 0x0,                    STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1023
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   128,   147, 0x0,                    STR_PERFORMANCE_DETAIL_DELIVERED_TIP},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1024
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   148,   167, 0x0,                    STR_PERFORMANCE_DETAIL_CARGO_TIP},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1025
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   168,   187, 0x0,                    STR_PERFORMANCE_DETAIL_MONEY_TIP},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1026
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   188,   207, 0x0,                    STR_PERFORMANCE_DETAIL_LOAN_TIP},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1027
{      WWT_PANEL,   RESIZE_NONE,    14,     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
  1028
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1029
{      WWT_PANEL,   RESIZE_NONE,    14,     2,    38,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1030
{      WWT_PANEL,   RESIZE_NONE,    14,    39,    75,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1031
{      WWT_PANEL,   RESIZE_NONE,    14,    76,   112,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1032
{      WWT_PANEL,   RESIZE_NONE,    14,   113,   149,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1033
{      WWT_PANEL,   RESIZE_NONE,    14,   150,   186,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1034
{      WWT_PANEL,   RESIZE_NONE,    14,   187,   223,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1035
{      WWT_PANEL,   RESIZE_NONE,    14,   224,   260,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1036
{      WWT_PANEL,   RESIZE_NONE,    14,   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
  1037
{   WIDGETS_END},
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1038
};
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1039
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1040
static const WindowDesc _performance_rating_detail_desc = {
9694
e72987579514 (svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents: 9686
diff changeset
  1041
	WDP_AUTO, WDP_AUTO, 299, 228, 299, 228,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6063
diff changeset
  1042
	WC_PERFORMANCE_DETAIL, WC_NONE,
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1043
	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
  1044
	_performance_rating_detail_widgets,
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1045
};
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1046
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6529
diff changeset
  1047
void ShowPerformanceRatingDetail()
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1048
{
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10513
diff changeset
  1049
	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
  1050
}