author | Tero Marttila <terom@fixme.fi> |
Fri, 18 Jul 2008 21:28:42 +0300 | |
changeset 11175 | 020c61e39c94 |
parent 10967 | fb9a80b89ea4 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10429
1b99254f9607
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8905
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 | 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 | 7 |
#include "gui.h" |
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
8 |
#include "window_gui.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8720
diff
changeset
|
9 |
#include "player_base.h" |
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8720
diff
changeset
|
10 |
#include "player_gui.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8610
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" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8603
diff
changeset
|
14 |
#include "strings_func.h" |
8626
440dfcd14c4a
(svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents:
8617
diff
changeset
|
15 |
#include "core/alloc_func.hpp" |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
16 |
#include "window_func.h" |
8636
2b158acb649c
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8627
diff
changeset
|
17 |
#include "date_func.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8675
diff
changeset
|
18 |
#include "gfx_func.h" |
10967
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
19 |
#include "sortlist_type.h" |
5291
5e4d9ab3cc0f
(svn r7444) -Codechange: Use one (global) cargo-colours array for drawing cargo-colours. Change Food
Darkvater
parents:
5247
diff
changeset
|
20 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
21 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
22 |
#include "table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
23 |
|
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
|
24 |
/* 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
|
25 |
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
|
26 |
static uint _legend_excluded_cargo; |
0 | 27 |
|
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
|
28 |
/* Apparently these don't play well with enums. */ |
8905
a6974b6041d9
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
rubidium
parents:
8760
diff
changeset
|
29 |
static const OverflowSafeInt64 INVALID_DATAPOINT(INT64_MAX); // Value used for a datapoint that shouldn't be drawn. |
8259
127e5d73637d
(svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
rubidium
parents:
8016
diff
changeset
|
30 |
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
|
31 |
|
0 | 32 |
/****************/ |
33 |
/* GRAPH LEGEND */ |
|
34 |
/****************/ |
|
35 |
||
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
36 |
struct GraphLegendWindow : Window { |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
37 |
GraphLegendWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
38 |
{ |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
39 |
for (uint i = 3; i < this->widget_count; i++) { |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
40 |
if (!HasBit(_legend_excluded_players, i - 3)) this->LowerWidget(i); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
41 |
} |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
42 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
43 |
this->FindWindowPlacementAndResize(desc); |
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
44 |
} |
6529
c53737959606
(svn r8989) -Fix: more indenting and variable scoping
peter1138
parents:
6518
diff
changeset
|
45 |
|
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
46 |
virtual void OnPaint() |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
47 |
{ |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
48 |
const Player *p; |
6529
c53737959606
(svn r8989) -Fix: more indenting and variable scoping
peter1138
parents:
6518
diff
changeset
|
49 |
|
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
50 |
FOR_ALL_PLAYERS(p) { |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
51 |
if (p->is_active) continue; |
6529
c53737959606
(svn r8989) -Fix: more indenting and variable scoping
peter1138
parents:
6518
diff
changeset
|
52 |
|
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
53 |
SetBit(_legend_excluded_players, p->index); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
54 |
this->RaiseWidget(p->index + 3); |
0 | 55 |
} |
56 |
||
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
57 |
this->DrawWidgets(); |
6529
c53737959606
(svn r8989) -Fix: more indenting and variable scoping
peter1138
parents:
6518
diff
changeset
|
58 |
|
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
59 |
FOR_ALL_PLAYERS(p) { |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
60 |
if (!p->is_active) continue; |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
61 |
|
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
62 |
DrawPlayerIcon(p->index, 4, 18 + p->index * 12); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
63 |
|
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
64 |
SetDParam(0, p->index); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
65 |
SetDParam(1, p->index); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
66 |
DrawString(21, 17 + p->index * 12, STR_7021, HasBit(_legend_excluded_players, p->index) ? TC_BLACK : TC_WHITE); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
67 |
} |
0 | 68 |
} |
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
69 |
|
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
70 |
virtual void OnClick(Point pt, int widget) |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
71 |
{ |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
72 |
if (!IsInsideMM(widget, 3, 11)) return; |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
73 |
|
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
74 |
ToggleBit(_legend_excluded_players, widget - 3); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
75 |
this->ToggleWidgetLoweredState(widget); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
76 |
this->SetDirty(); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
77 |
InvalidateWindow(WC_INCOME_GRAPH, 0); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
78 |
InvalidateWindow(WC_OPERATING_PROFIT, 0); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
79 |
InvalidateWindow(WC_DELIVERED_CARGO, 0); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
80 |
InvalidateWindow(WC_PERFORMANCE_HISTORY, 0); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
81 |
InvalidateWindow(WC_COMPANY_VALUE, 0); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
82 |
} |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
83 |
}; |
0 | 84 |
|
85 |
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
|
86 |
{ 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
|
87 |
{ 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
|
88 |
{ 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
|
89 |
{ 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
|
90 |
{ 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
|
91 |
{ 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
|
92 |
{ 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
|
93 |
{ 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
|
94 |
{ 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
|
95 |
{ 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
|
96 |
{ 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
|
97 |
{ WIDGETS_END}, |
0 | 98 |
}; |
99 |
||
100 |
static const WindowDesc _graph_legend_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
101 |
WDP_AUTO, WDP_AUTO, 250, 114, 250, 114, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6063
diff
changeset
|
102 |
WC_GRAPH_LEGEND, WC_NONE, |
0 | 103 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
104 |
_graph_legend_widgets, |
|
105 |
}; |
|
106 |
||
6573 | 107 |
static void ShowGraphLegend() |
0 | 108 |
{ |
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
109 |
AllocateWindowDescFront<GraphLegendWindow>(&_graph_legend_desc, 0); |
0 | 110 |
} |
111 |
||
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
112 |
/******************/ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
113 |
/* BASE OF GRAPHS */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
114 |
/*****************/ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
115 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
116 |
struct BaseGraphWindow : Window { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
117 |
protected: |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
118 |
enum { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
119 |
GRAPH_MAX_DATASETS = 32, |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
120 |
GRAPH_AXIS_LABEL_COLOUR = TC_BLACK, |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
121 |
GRAPH_AXIS_LINE_COLOUR = 215, |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
122 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
123 |
GRAPH_X_POSITION_BEGINNING = 44, ///< Start the graph 44 pixels from gd_left |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
124 |
GRAPH_X_POSITION_SEPARATION = 22, ///< There are 22 pixels between each X value |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
125 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
126 |
GRAPH_NUM_LINES_Y = 9, ///< How many horizontal lines to draw. |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
127 |
/* 9 is convenient as that means the distance between them is the gd_height of the graph / 8, |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
128 |
* which is the same |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
129 |
* as height >> 3. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
130 |
}; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
131 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
132 |
uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed. |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
133 |
byte num_dataset; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
134 |
byte num_on_x_axis; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
135 |
bool has_negative_values; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
136 |
byte num_vert_lines; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
137 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
138 |
/* The starting month and year that values are plotted against. If month is |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
139 |
* 0xFF, use x_values_start and x_values_increment below instead. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
140 |
byte month; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
141 |
Year year; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
142 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
143 |
/* These values are used if the graph is being plotted against values |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
144 |
* rather than the dates specified by month and year. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
145 |
uint16 x_values_start; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
146 |
uint16 x_values_increment; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
147 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
148 |
int gd_left, gd_top; ///< Where to start drawing the graph, in pixels. |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
149 |
uint gd_height; ///< The height of the graph in pixels. |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
150 |
StringID format_str_y_axis; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
151 |
byte colors[GRAPH_MAX_DATASETS]; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
152 |
OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
153 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
154 |
void DrawGraph() const |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
155 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
156 |
uint x, y; ///< Reused whenever x and y coordinates are needed. |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
157 |
OverflowSafeInt64 highest_value; ///< Highest value to be drawn. |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
158 |
int x_axis_offset; ///< Distance from the top of the graph to the x axis. |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
159 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
160 |
/* the colors and cost array of GraphDrawer must accomodate |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
161 |
* both values for cargo and players. So if any are higher, quit */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
162 |
assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_PLAYERS); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
163 |
assert(this->num_vert_lines > 0); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
164 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
165 |
byte grid_colour = _colour_gradient[14][4]; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
166 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
167 |
/* The coordinates of the opposite edges of the graph. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
168 |
int bottom = this->gd_top + this->gd_height - 1; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
169 |
int right = this->gd_left + GRAPH_X_POSITION_BEGINNING + this->num_vert_lines * GRAPH_X_POSITION_SEPARATION - 1; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
170 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
171 |
/* Draw the vertical grid lines. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
172 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
173 |
/* Don't draw the first line, as that's where the axis will be. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
174 |
x = this->gd_left + GRAPH_X_POSITION_BEGINNING + GRAPH_X_POSITION_SEPARATION; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
175 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
176 |
for (int i = 0; i < this->num_vert_lines; i++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
177 |
GfxFillRect(x, this->gd_top, x, bottom, grid_colour); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
178 |
x += GRAPH_X_POSITION_SEPARATION; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
179 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
180 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
181 |
/* Draw the horizontal grid lines. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
182 |
x = this->gd_left + GRAPH_X_POSITION_BEGINNING; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
183 |
y = this->gd_height + this->gd_top; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
184 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
185 |
for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
186 |
GfxFillRect(x, y, right, y, grid_colour); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
187 |
y -= (this->gd_height / (GRAPH_NUM_LINES_Y - 1)); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
188 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
189 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
190 |
/* Draw the y axis. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
191 |
GfxFillRect(x, this->gd_top, x, bottom, GRAPH_AXIS_LINE_COLOUR); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
192 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
193 |
/* Find the distance from the gd_top of the graph to the x axis. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
194 |
x_axis_offset = this->gd_height; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
195 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
196 |
/* The graph is currently symmetrical about the x axis. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
197 |
if (this->has_negative_values) x_axis_offset /= 2; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
198 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
199 |
/* Draw the x axis. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
200 |
y = x_axis_offset + this->gd_top; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
201 |
GfxFillRect(x, y, right, y, GRAPH_AXIS_LINE_COLOUR); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
202 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
203 |
/* Find the largest value that will be drawn. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
204 |
if (this->num_on_x_axis == 0) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
205 |
return; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
206 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
207 |
assert(this->num_on_x_axis > 0); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
208 |
assert(this->num_dataset > 0); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
209 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
210 |
/* Start of with a value of twice the gd_height of the graph in pixels. It's a |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
211 |
* bit arbitrary, but it makes the cargo payment graph look a little nicer, |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
212 |
* and prevents division by zero when calculating where the datapoint |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
213 |
* should be drawn. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
214 |
highest_value = x_axis_offset * 2; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
215 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
216 |
for (int i = 0; i < this->num_dataset; i++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
217 |
if (!HasBit(this->excluded_data, i)) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
218 |
for (int j = 0; j < this->num_on_x_axis; j++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
219 |
OverflowSafeInt64 datapoint = this->cost[i][j]; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
220 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
221 |
if (datapoint != INVALID_DATAPOINT) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
222 |
/* For now, if the graph has negative values the scaling is |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
223 |
* symmetrical about the x axis, so take the absolute value |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
224 |
* of each data point. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
225 |
highest_value = max(highest_value, abs(datapoint)); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
226 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
227 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
228 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
229 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
230 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
231 |
/* Round up highest_value so that it will divide cleanly into the number of |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
232 |
* axis labels used. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
233 |
int round_val = highest_value % (GRAPH_NUM_LINES_Y - 1); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
234 |
if (round_val != 0) highest_value += (GRAPH_NUM_LINES_Y - 1 - round_val); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
235 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
236 |
/* draw text strings on the y axis */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
237 |
int64 y_label = highest_value; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
238 |
int64 y_label_separation = highest_value / (GRAPH_NUM_LINES_Y - 1); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
239 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
240 |
/* If there are negative values, the graph goes from highest_value to |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
241 |
* -highest_value, not highest_value to 0. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
242 |
if (this->has_negative_values) y_label_separation *= 2; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
243 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
244 |
x = this->gd_left + GRAPH_X_POSITION_BEGINNING + 1; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
245 |
y = this->gd_top - 3; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
246 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
247 |
for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
248 |
SetDParam(0, this->format_str_y_axis); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
249 |
SetDParam(1, y_label); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
250 |
DrawStringRightAligned(x, y, STR_0170, GRAPH_AXIS_LABEL_COLOUR); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
251 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
252 |
y_label -= y_label_separation; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
253 |
y += (this->gd_height / (GRAPH_NUM_LINES_Y - 1)); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
254 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
255 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
256 |
/* draw strings on the x axis */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
257 |
if (this->month != 0xFF) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
258 |
x = this->gd_left + GRAPH_X_POSITION_BEGINNING; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
259 |
y = this->gd_top + this->gd_height + 1; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
260 |
byte month = this->month; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
261 |
Year year = this->year; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
262 |
for (int i = 0; i < this->num_on_x_axis; i++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
263 |
SetDParam(0, month + STR_0162_JAN); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
264 |
SetDParam(1, month + STR_0162_JAN + 2); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
265 |
SetDParam(2, year); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
266 |
DrawString(x, y, month == 0 ? STR_016F : STR_016E, GRAPH_AXIS_LABEL_COLOUR); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
267 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
268 |
month += 3; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
269 |
if (month >= 12) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
270 |
month = 0; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
271 |
year++; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
272 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
273 |
x += GRAPH_X_POSITION_SEPARATION; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
274 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
275 |
} else { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
276 |
/* Draw the label under the data point rather than on the grid line. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
277 |
x = this->gd_left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2) + 1; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
278 |
y = this->gd_top + this->gd_height + 1; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
279 |
uint16 label = this->x_values_start; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
280 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
281 |
for (int i = 0; i < this->num_on_x_axis; i++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
282 |
SetDParam(0, label); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
283 |
DrawStringCentered(x, y, STR_01CB, GRAPH_AXIS_LABEL_COLOUR); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
284 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
285 |
label += this->x_values_increment; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
286 |
x += GRAPH_X_POSITION_SEPARATION; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
287 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
288 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
289 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
290 |
/* draw lines and dots */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
291 |
for (int i = 0; i < this->num_dataset; i++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
292 |
if (!HasBit(this->excluded_data, i)) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
293 |
/* Centre the dot between the grid lines. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
294 |
x = this->gd_left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
295 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
296 |
byte color = this->colors[i]; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
297 |
uint prev_x = INVALID_DATAPOINT_POS; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
298 |
uint prev_y = INVALID_DATAPOINT_POS; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
299 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
300 |
for (int j = 0; j < this->num_on_x_axis; j++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
301 |
OverflowSafeInt64 datapoint = this->cost[i][j]; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
302 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
303 |
if (datapoint != INVALID_DATAPOINT) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
304 |
/* |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
305 |
* Check whether we need to reduce the 'accuracy' of the |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
306 |
* datapoint value and the highest value to splut overflows. |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
307 |
* And when 'drawing' 'one million' or 'one million and one' |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
308 |
* there is no significant difference, so the least |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
309 |
* significant bits can just be removed. |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
310 |
* |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
311 |
* If there are more bits needed than would fit in a 32 bits |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
312 |
* integer, so at about 31 bits because of the sign bit, the |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
313 |
* least significant bits are removed. |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
314 |
*/ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
315 |
int mult_range = FindLastBit(x_axis_offset) + FindLastBit(abs(datapoint)); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
316 |
int reduce_range = max(mult_range - 31, 0); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
317 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
318 |
/* Handle negative values differently (don't shift sign) */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
319 |
if (datapoint < 0) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
320 |
datapoint = -(abs(datapoint) >> reduce_range); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
321 |
} else { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
322 |
datapoint >>= reduce_range; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
323 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
324 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
325 |
y = this->gd_top + x_axis_offset - (x_axis_offset * datapoint) / (highest_value >> reduce_range); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
326 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
327 |
/* Draw the point. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
328 |
GfxFillRect(x - 1, y - 1, x + 1, y + 1, color); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
329 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
330 |
/* Draw the line connected to the previous point. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
331 |
if (prev_x != INVALID_DATAPOINT_POS) GfxDrawLine(prev_x, prev_y, x, y, color); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
332 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
333 |
prev_x = x; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
334 |
prev_y = y; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
335 |
} else { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
336 |
prev_x = INVALID_DATAPOINT_POS; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
337 |
prev_y = INVALID_DATAPOINT_POS; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
338 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
339 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
340 |
x += GRAPH_X_POSITION_SEPARATION; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
341 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
342 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
343 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
344 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
345 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
346 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
347 |
BaseGraphWindow(const WindowDesc *desc, WindowNumber window_number, int left, |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
348 |
int top, int height, bool has_negative_values, StringID format_str_y_axis) : |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
349 |
Window(desc, window_number), has_negative_values(has_negative_values), |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
350 |
gd_left(left), gd_top(top), gd_height(height), format_str_y_axis(format_str_y_axis) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
351 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
352 |
InvalidateWindow(WC_GRAPH_LEGEND, 0); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
353 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
354 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
355 |
public: |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
356 |
virtual void OnPaint() |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
357 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
358 |
this->DrawWidgets(); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
359 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
360 |
uint excluded_players = _legend_excluded_players; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
361 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
362 |
/* Exclude the players which aren't valid */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
363 |
const Player* p; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
364 |
FOR_ALL_PLAYERS(p) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
365 |
if (!p->is_active) SetBit(excluded_players, p->index); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
366 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
367 |
this->excluded_data = excluded_players; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
368 |
this->num_vert_lines = 24; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
369 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
370 |
byte nums = 0; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
371 |
FOR_ALL_PLAYERS(p) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
372 |
if (p->is_active) nums = max(nums, p->num_valid_stat_ent); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
373 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
374 |
this->num_on_x_axis = min(nums, 24); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
375 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
376 |
int mo = (_cur_month / 3 - nums) * 3; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
377 |
int yr = _cur_year; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
378 |
while (mo < 0) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
379 |
yr--; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
380 |
mo += 12; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
381 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
382 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
383 |
this->year = yr; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
384 |
this->month = mo; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
385 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
386 |
int numd = 0; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
387 |
FOR_ALL_PLAYERS(p) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
388 |
if (p->is_active) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
389 |
this->colors[numd] = _colour_gradient[p->player_color][6]; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
390 |
for (int j = this->num_on_x_axis, i = 0; --j >= 0;) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
391 |
this->cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : GetGraphData(p, j); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
392 |
i++; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
393 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
394 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
395 |
numd++; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
396 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
397 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
398 |
this->num_dataset = numd; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
399 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
400 |
this->DrawGraph(); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
401 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
402 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
403 |
virtual OverflowSafeInt64 GetGraphData(const Player *p, int j) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
404 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
405 |
return INVALID_DATAPOINT; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
406 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
407 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
408 |
virtual void OnClick(Point pt, int widget) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
409 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
410 |
/* Clicked on legend? */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
411 |
if (widget == 2) ShowGraphLegend(); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
412 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
413 |
}; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
414 |
|
0 | 415 |
/********************/ |
416 |
/* OPERATING PROFIT */ |
|
417 |
/********************/ |
|
418 |
||
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
419 |
struct OperatingProfitGraphWindow : BaseGraphWindow { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
420 |
OperatingProfitGraphWindow(const WindowDesc *desc, WindowNumber window_number) : |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
421 |
BaseGraphWindow(desc, window_number, 2, 18, 136, true, STR_CURRCOMPACT) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
422 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
423 |
this->FindWindowPlacementAndResize(desc); |
0 | 424 |
} |
425 |
||
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
426 |
virtual OverflowSafeInt64 GetGraphData(const Player *p, int j) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
427 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
428 |
return p->old_economy[j].income + p->old_economy[j].expenses; |
0 | 429 |
} |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
430 |
}; |
0 | 431 |
|
432 |
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
|
433 |
{ 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
|
434 |
{ 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
|
435 |
{ 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
|
436 |
{ 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
|
437 |
{ WIDGETS_END}, |
0 | 438 |
}; |
439 |
||
440 |
static const WindowDesc _operating_profit_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
441 |
WDP_AUTO, WDP_AUTO, 576, 174, 576, 174, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6063
diff
changeset
|
442 |
WC_OPERATING_PROFIT, WC_NONE, |
0 | 443 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
444 |
_operating_profit_widgets, |
|
445 |
}; |
|
446 |
||
447 |
||
6573 | 448 |
void ShowOperatingProfitGraph() |
0 | 449 |
{ |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
450 |
AllocateWindowDescFront<OperatingProfitGraphWindow>(&_operating_profit_desc, 0); |
0 | 451 |
} |
452 |
||
453 |
||
454 |
/****************/ |
|
455 |
/* INCOME GRAPH */ |
|
456 |
/****************/ |
|
457 |
||
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
458 |
struct IncomeGraphWindow : BaseGraphWindow { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
459 |
IncomeGraphWindow(const WindowDesc *desc, WindowNumber window_number) : |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
460 |
BaseGraphWindow(desc, window_number, 2, 18, 104, false, STR_CURRCOMPACT) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
461 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
462 |
this->FindWindowPlacementAndResize(desc); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
463 |
} |
6529
c53737959606
(svn r8989) -Fix: more indenting and variable scoping
peter1138
parents:
6518
diff
changeset
|
464 |
|
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
465 |
virtual OverflowSafeInt64 GetGraphData(const Player *p, int j) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
466 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
467 |
return p->old_economy[j].income; |
0 | 468 |
} |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
469 |
}; |
0 | 470 |
|
471 |
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
|
472 |
{ 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
|
473 |
{ 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
|
474 |
{ 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
|
475 |
{ 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
|
476 |
{ WIDGETS_END}, |
0 | 477 |
}; |
478 |
||
479 |
static const WindowDesc _income_graph_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
480 |
WDP_AUTO, WDP_AUTO, 576, 142, 576, 142, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6063
diff
changeset
|
481 |
WC_INCOME_GRAPH, WC_NONE, |
0 | 482 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
483 |
_income_graph_widgets, |
|
484 |
}; |
|
485 |
||
6573 | 486 |
void ShowIncomeGraph() |
0 | 487 |
{ |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
488 |
AllocateWindowDescFront<IncomeGraphWindow>(&_income_graph_desc, 0); |
0 | 489 |
} |
490 |
||
491 |
/*******************/ |
|
492 |
/* DELIVERED CARGO */ |
|
493 |
/*******************/ |
|
494 |
||
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
495 |
struct DeliveredCargoGraphWindow : BaseGraphWindow { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
496 |
DeliveredCargoGraphWindow(const WindowDesc *desc, WindowNumber window_number) : |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
497 |
BaseGraphWindow(desc, window_number, 2, 18, 104, false, STR_7024) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
498 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
499 |
this->FindWindowPlacementAndResize(desc); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
500 |
} |
6529
c53737959606
(svn r8989) -Fix: more indenting and variable scoping
peter1138
parents:
6518
diff
changeset
|
501 |
|
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
502 |
virtual OverflowSafeInt64 GetGraphData(const Player *p, int j) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
503 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
504 |
return p->old_economy[j].delivered_cargo; |
0 | 505 |
} |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
506 |
}; |
0 | 507 |
|
508 |
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
|
509 |
{ 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
|
510 |
{ 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
|
511 |
{ 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
|
512 |
{ 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
|
513 |
{ WIDGETS_END}, |
0 | 514 |
}; |
515 |
||
516 |
static const WindowDesc _delivered_cargo_graph_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
517 |
WDP_AUTO, WDP_AUTO, 576, 142, 576, 142, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6063
diff
changeset
|
518 |
WC_DELIVERED_CARGO, WC_NONE, |
0 | 519 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
520 |
_delivered_cargo_graph_widgets, |
|
521 |
}; |
|
522 |
||
6573 | 523 |
void ShowDeliveredCargoGraph() |
0 | 524 |
{ |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
525 |
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
|
526 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
527 |
|
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
|
528 |
/***********************/ |
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 |
/* 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
|
530 |
/***********************/ |
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
|
531 |
|
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
532 |
struct PerformanceHistoryGraphWindow : BaseGraphWindow { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
533 |
PerformanceHistoryGraphWindow(const WindowDesc *desc, WindowNumber window_number) : |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
534 |
BaseGraphWindow(desc, window_number, 2, 18, 200, false, STR_7024) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
535 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
536 |
this->FindWindowPlacementAndResize(desc); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
537 |
} |
6529
c53737959606
(svn r8989) -Fix: more indenting and variable scoping
peter1138
parents:
6518
diff
changeset
|
538 |
|
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
539 |
virtual OverflowSafeInt64 GetGraphData(const Player *p, int j) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
540 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
541 |
return p->old_economy[j].performance_history; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
542 |
} |
6529
c53737959606
(svn r8989) -Fix: more indenting and variable scoping
peter1138
parents:
6518
diff
changeset
|
543 |
|
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
544 |
virtual void OnClick(Point pt, int widget) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
545 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
546 |
if (widget == 3) ShowPerformanceRatingDetail(); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
547 |
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
|
548 |
} |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
549 |
}; |
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
|
550 |
|
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
|
551 |
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
|
552 |
{ 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
|
553 |
{ 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
|
554 |
{ 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
|
555 |
{ 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
|
556 |
{ 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
|
557 |
{ 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
|
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 |
|
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
|
560 |
static const WindowDesc _performance_history_desc = { |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
561 |
WDP_AUTO, WDP_AUTO, 576, 238, 576, 238, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6063
diff
changeset
|
562 |
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
|
563 |
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
|
564 |
_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
|
565 |
}; |
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
|
566 |
|
6573 | 567 |
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
|
568 |
{ |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
569 |
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
|
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 |
/*****************/ |
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 |
/* 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
|
574 |
/*****************/ |
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
|
575 |
|
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
576 |
struct CompanyValueGraphWindow : BaseGraphWindow { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
577 |
CompanyValueGraphWindow(const WindowDesc *desc, WindowNumber window_number) : |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
578 |
BaseGraphWindow(desc, window_number, 2, 18, 200, false, STR_CURRCOMPACT) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
579 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
580 |
this->FindWindowPlacementAndResize(desc); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
581 |
} |
6529
c53737959606
(svn r8989) -Fix: more indenting and variable scoping
peter1138
parents:
6518
diff
changeset
|
582 |
|
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
583 |
virtual OverflowSafeInt64 GetGraphData(const Player *p, int j) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
584 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
585 |
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
|
586 |
} |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
587 |
}; |
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
|
588 |
|
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
|
589 |
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
|
590 |
{ 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
|
591 |
{ 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
|
592 |
{ 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
|
593 |
{ 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
|
594 |
{ 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
|
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 |
|
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
|
597 |
static const WindowDesc _company_value_graph_desc = { |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
598 |
WDP_AUTO, WDP_AUTO, 576, 238, 576, 238, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6063
diff
changeset
|
599 |
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
|
600 |
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
|
601 |
_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
|
602 |
}; |
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
|
603 |
|
6573 | 604 |
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
|
605 |
{ |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
606 |
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
|
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 |
/*****************/ |
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 |
/* 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
|
611 |
/*****************/ |
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
|
612 |
|
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
613 |
struct PaymentRatesGraphWindow : BaseGraphWindow { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
614 |
PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) : |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
615 |
BaseGraphWindow(desc, window_number, 2, 24, 200, false, STR_CURRCOMPACT) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
616 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
617 |
uint num_active = 0; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
618 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
619 |
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
|
620 |
} |
6529
c53737959606
(svn r8989) -Fix: more indenting and variable scoping
peter1138
parents:
6518
diff
changeset
|
621 |
|
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
622 |
/* Resize the window to fit the cargo types */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
623 |
ResizeWindow(this, 0, max(num_active, 12U) * 8); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
624 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
625 |
/* Add widgets for each cargo type */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
626 |
this->widget_count += num_active; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
627 |
this->widget = ReallocT(this->widget, this->widget_count + 1); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
628 |
this->widget[this->widget_count].type = WWT_LAST; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
629 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
630 |
/* Set the properties of each widget */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
631 |
for (uint i = 0; i != num_active; i++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
632 |
Widget *wi = &this->widget[3 + i]; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
633 |
wi->type = WWT_PANEL; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
634 |
wi->display_flags = RESIZE_NONE; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
635 |
wi->color = 12; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
636 |
wi->left = 493; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
637 |
wi->right = 562; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
638 |
wi->top = 24 + i * 8; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
639 |
wi->bottom = wi->top + 7; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
640 |
wi->data = 0; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
641 |
wi->tooltips = STR_7064_TOGGLE_GRAPH_FOR_CARGO; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
642 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
643 |
if (!HasBit(_legend_excluded_cargo, i)) this->LowerWidget(i + 3); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
644 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
645 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
646 |
this->SetDirty(); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
647 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
648 |
this->gd_height = this->height - 38; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
649 |
this->num_on_x_axis = 20; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
650 |
this->num_vert_lines = 20; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
651 |
this->month = 0xFF; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
652 |
this->x_values_start = 10; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
653 |
this->x_values_increment = 10; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
654 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
655 |
this->FindWindowPlacementAndResize(desc); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
656 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
657 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
658 |
virtual void OnPaint() |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
659 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
660 |
this->DrawWidgets(); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
661 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
662 |
this->excluded_data = _legend_excluded_cargo; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
663 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
664 |
int x = 495; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
665 |
int y = 24; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
666 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
667 |
uint i = 0; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
668 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
669 |
const CargoSpec *cs = GetCargo(c); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
670 |
if (!cs->IsValid()) continue; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
671 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
672 |
/* Only draw labels for widgets that exist. If the widget doesn't |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
673 |
* exist then the local player has used the climate cheat or |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
674 |
* changed the NewGRF configuration with this window open. */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
675 |
if (i + 3 < this->widget_count) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
676 |
/* Since the buttons have no text, no images, |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
677 |
* both the text and the colored box have to be manually painted. |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
678 |
* clk_dif will move one pixel down and one pixel to the right |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
679 |
* when the button is clicked */ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
680 |
byte clk_dif = this->IsWidgetLowered(i + 3) ? 1 : 0; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
681 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
682 |
GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
683 |
GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
684 |
SetDParam(0, cs->name); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
685 |
DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, TC_FROMSTRING); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
686 |
y += 8; |
6529
c53737959606
(svn r8989) -Fix: more indenting and variable scoping
peter1138
parents:
6518
diff
changeset
|
687 |
} |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
688 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
689 |
this->colors[i] = cs->legend_colour; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
690 |
for (uint j = 0; j != 20; j++) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
691 |
this->cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 6 + 6, c); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
692 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
693 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
694 |
i++; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
695 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
696 |
this->num_dataset = i; |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
697 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
698 |
this->DrawGraph(); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
699 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
700 |
DrawString(2 + 46, 24 + this->gd_height + 7, STR_7062_DAYS_IN_TRANSIT, TC_FROMSTRING); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
701 |
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
|
702 |
} |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
703 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
704 |
virtual void OnClick(Point pt, int widget) |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
705 |
{ |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
706 |
if (widget >= 3) { |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
707 |
ToggleBit(_legend_excluded_cargo, widget - 3); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
708 |
this->ToggleWidgetLoweredState(widget); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
709 |
this->SetDirty(); |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
710 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
711 |
} |
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
712 |
}; |
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
|
713 |
|
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
|
714 |
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
|
715 |
{ 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
|
716 |
{ 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
|
717 |
{ 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
|
718 |
{ 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
|
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 |
|
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
|
721 |
static const WindowDesc _cargo_payment_rates_desc = { |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
722 |
WDP_AUTO, WDP_AUTO, 568, 46, 568, 46, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6063
diff
changeset
|
723 |
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
|
724 |
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
|
725 |
_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
|
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 |
|
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
|
728 |
|
6573 | 729 |
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
|
730 |
{ |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
731 |
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
|
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 |
/************************/ |
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 |
/* 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
|
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 |
|
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 |
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
|
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_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
|
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_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
|
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_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
|
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_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
|
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_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
|
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_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
|
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_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
|
753 |
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
|
754 |
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
|
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 |
|
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 |
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
|
758 |
{ |
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 |
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
|
760 |
} |
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
|
761 |
|
10967
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
762 |
class CompanyLeagueWindow : public Window { |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
763 |
private: |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
764 |
GUIList<const Player*> players; |
2656
796b75ba15e3
(svn r3198) Rewrite the company league drawing routine for better readability
tron
parents:
2639
diff
changeset
|
765 |
|
10967
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
766 |
/** |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
767 |
* (Re)Build the company league list |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
768 |
*/ |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
769 |
void BuildPlayerList() |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
770 |
{ |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
771 |
if (!this->players.NeedRebuild()) return; |
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
|
772 |
|
10967
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
773 |
this->players.Clear(); |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
774 |
|
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
775 |
const Player *p; |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
776 |
FOR_ALL_PLAYERS(p) { |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
777 |
if (p->is_active) { |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
778 |
*this->players.Append() = p; |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
779 |
} |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
780 |
} |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
781 |
|
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
782 |
this->players.Compact(); |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
783 |
this->players.RebuildDone(); |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
784 |
} |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
785 |
|
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
786 |
/** Sort the company league by performance history */ |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
787 |
static int CDECL PerformanceSorter(const Player* const *p1, const Player* const *p2) |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
788 |
{ |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
789 |
return (*p2)->old_economy[1].performance_history - (*p1)->old_economy[1].performance_history; |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
790 |
} |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
791 |
|
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
792 |
public: |
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
793 |
CompanyLeagueWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
794 |
{ |
10967
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
795 |
this->players.ForceRebuild(); |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
796 |
this->players.NeedResort(); |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
797 |
|
10681
3aa3de4d448b
(svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents:
10641
diff
changeset
|
798 |
this->FindWindowPlacementAndResize(desc); |
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
799 |
} |
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
|
800 |
|
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
801 |
virtual void OnPaint() |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
802 |
{ |
10967
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
803 |
this->BuildPlayerList(); |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
804 |
this->players.Sort(&PerformanceSorter); |
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
|
805 |
|
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
806 |
this->DrawWidgets(); |
2656
796b75ba15e3
(svn r3198) Rewrite the company league drawing routine for better readability
tron
parents:
2639
diff
changeset
|
807 |
|
10967
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
808 |
for (uint i = 0; i != this->players.Length(); i++) { |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
809 |
const Player *p = this->players[i]; |
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
810 |
SetDParam(0, i + STR_01AC_1ST); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
811 |
SetDParam(1, p->index); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
812 |
SetDParam(2, p->index); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
813 |
SetDParam(3, GetPerformanceTitleFromValue(p->old_economy[1].performance_history)); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
814 |
|
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
815 |
DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, TC_FROMSTRING); |
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
816 |
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
|
817 |
} |
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
|
818 |
} |
10967
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
819 |
|
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
820 |
virtual void OnTick() |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
821 |
{ |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
822 |
if (this->players.NeedResort()) { |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
823 |
this->SetDirty(); |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
824 |
} |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
825 |
} |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
826 |
|
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
827 |
virtual void OnInvalidateData(int data) |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
828 |
{ |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
829 |
if (data == 0) { |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
830 |
this->players.ForceRebuild(); |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
831 |
} else { |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
832 |
this->players.ForceResort(); |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
833 |
} |
fb9a80b89ea4
(svn r13521) -Codechange: Use GUIList sorting instead of poll & sort for CompanyLeagueWindow
skidd13
parents:
10681
diff
changeset
|
834 |
} |
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
835 |
}; |
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
|
836 |
|
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
|
837 |
|
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
|
838 |
static const Widget _company_league_widgets[] = { |
2869
5cf9acd29edd
(svn r3417) - Make company league table window pinnable.
peter1138
parents:
2725
diff
changeset
|
839 |
{ 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
|
840 |
{ 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
|
841 |
{ 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
|
842 |
{ 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
|
843 |
{ 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
|
844 |
}; |
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
|
845 |
|
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
|
846 |
static const WindowDesc _company_league_desc = { |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
847 |
WDP_AUTO, WDP_AUTO, 400, 97, 400, 97, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6063
diff
changeset
|
848 |
WC_COMPANY_LEAGUE, WC_NONE, |
2869
5cf9acd29edd
(svn r3417) - Make company league table window pinnable.
peter1138
parents:
2725
diff
changeset
|
849 |
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
|
850 |
_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
|
851 |
}; |
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
|
852 |
|
6573 | 853 |
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
|
854 |
{ |
10611
19de4d762169
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium
parents:
10595
diff
changeset
|
855 |
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
|
856 |
} |
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
|
857 |
|
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
858 |
/*****************************/ |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
859 |
/* PERFORMANCE RATING DETAIL */ |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
860 |
/*****************************/ |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
861 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
862 |
struct PerformanceRatingDetailWindow : Window { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
863 |
static PlayerID player; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
864 |
int timeout; |
6197
4ee36c52e467
(svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents:
6144
diff
changeset
|
865 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
866 |
PerformanceRatingDetailWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
867 |
{ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
868 |
/* Disable the players who are not active */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
869 |
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
870 |
this->SetWidgetDisabledState(i + 13, !GetPlayer(i)->is_active); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
871 |
} |
6197
4ee36c52e467
(svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents:
6144
diff
changeset
|
872 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
873 |
this->UpdatePlayerStats(); |
6197
4ee36c52e467
(svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents:
6144
diff
changeset
|
874 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
875 |
if (player != INVALID_PLAYER) this->LowerWidget(player + 13); |
10612
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
876 |
|
bc9b5cae8f95
(svn r13156) -Codechange: make classes of the GraphWindows.
rubidium
parents:
10611
diff
changeset
|
877 |
this->FindWindowPlacementAndResize(desc); |
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
878 |
} |
3027
43ffdf4d6a1f
(svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents:
2952
diff
changeset
|
879 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
880 |
void UpdatePlayerStats() |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
881 |
{ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
882 |
/* Update all player stats with the current data |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
883 |
* (this is because _score_info is not saved to a savegame) */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
884 |
Player *p; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
885 |
FOR_ALL_PLAYERS(p) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
886 |
if (p->is_active) UpdateCompanyRatingAndValue(p, false); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
887 |
} |
3027
43ffdf4d6a1f
(svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents:
2952
diff
changeset
|
888 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
889 |
this->timeout = DAY_TICKS * 5; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
890 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
891 |
} |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
892 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
893 |
virtual void OnPaint() |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
894 |
{ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
895 |
byte x; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
896 |
uint16 y = 14; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
897 |
int total_score = 0; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
898 |
int color_done, color_notdone; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
899 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
900 |
/* Draw standard stuff */ |
10595
7957c71b0dfe
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
10577
diff
changeset
|
901 |
this->DrawWidgets(); |
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
902 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
903 |
/* Check if the currently selected player is still active. */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
904 |
if (player == INVALID_PLAYER || !GetPlayer(player)->is_active) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
905 |
if (player != INVALID_PLAYER) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
906 |
/* Raise and disable the widget for the previous selection. */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
907 |
this->RaiseWidget(player + 13); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
908 |
this->DisableWidget(player + 13); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
909 |
this->SetDirty(); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
910 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
911 |
player = INVALID_PLAYER; |
3027
43ffdf4d6a1f
(svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents:
2952
diff
changeset
|
912 |
} |
43ffdf4d6a1f
(svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents:
2952
diff
changeset
|
913 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
914 |
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
915 |
if (GetPlayer(i)->is_active) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
916 |
/* Lower the widget corresponding to this player. */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
917 |
this->LowerWidget(i + 13); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
918 |
this->SetDirty(); |
3027
43ffdf4d6a1f
(svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents:
2952
diff
changeset
|
919 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
920 |
player = i; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
921 |
break; |
3027
43ffdf4d6a1f
(svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents:
2952
diff
changeset
|
922 |
} |
43ffdf4d6a1f
(svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents:
2952
diff
changeset
|
923 |
} |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
924 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
925 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
926 |
/* If there are no active players, don't display anything else. */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
927 |
if (player == INVALID_PLAYER) return; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
928 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
929 |
/* Paint the player icons */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
930 |
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
931 |
if (!GetPlayer(i)->is_active) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
932 |
/* Check if we have the player as an active player */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
933 |
if (!this->IsWidgetDisabled(i + 13)) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
934 |
/* Bah, player gone :( */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
935 |
this->DisableWidget(i + 13); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
936 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
937 |
/* We need a repaint */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
938 |
this->SetDirty(); |
3027
43ffdf4d6a1f
(svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents:
2952
diff
changeset
|
939 |
} |
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
940 |
continue; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3027
diff
changeset
|
941 |
} |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
942 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
943 |
/* Check if we have the player marked as inactive */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
944 |
if (this->IsWidgetDisabled(i + 13)) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
945 |
/* New player! Yippie :p */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
946 |
this->EnableWidget(i + 13); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
947 |
/* We need a repaint */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
948 |
this->SetDirty(); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
949 |
} |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
950 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
951 |
x = (i == player) ? 1 : 0; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
952 |
DrawPlayerIcon(i, i * 37 + 13 + x, 16 + x); |
3027
43ffdf4d6a1f
(svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents:
2952
diff
changeset
|
953 |
} |
43ffdf4d6a1f
(svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents:
2952
diff
changeset
|
954 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
955 |
/* The colors used to show how the progress is going */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
956 |
color_done = _colour_gradient[COLOUR_GREEN][4]; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
957 |
color_notdone = _colour_gradient[COLOUR_RED][4]; |
8675
5ff307aa5048
(svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138
parents:
8636
diff
changeset
|
958 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
959 |
/* Draw all the score parts */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
960 |
for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
961 |
int val = _score_part[player][i]; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
962 |
int needed = _score_info[i].needed; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
963 |
int score = _score_info[i].score; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3027
diff
changeset
|
964 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
965 |
y += 20; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
966 |
/* SCORE_TOTAL has his own rulez ;) */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
967 |
if (i == SCORE_TOTAL) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
968 |
needed = total_score; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
969 |
score = SCORE_MAX; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
970 |
} else { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
971 |
total_score += score; |
3027
43ffdf4d6a1f
(svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents:
2952
diff
changeset
|
972 |
} |
43ffdf4d6a1f
(svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents:
2952
diff
changeset
|
973 |
|
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
974 |
DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, TC_FROMSTRING); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
975 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
976 |
/* Draw the score */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
977 |
SetDParam(0, score); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
978 |
DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, TC_FROMSTRING); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
979 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
980 |
/* Calculate the %-bar */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
981 |
x = Clamp(val, 0, needed) * 50 / needed; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
982 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
983 |
/* SCORE_LOAN is inversed */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
984 |
if (val < 0 && i == SCORE_LOAN) x = 0; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
985 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
986 |
/* Draw the bar */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
987 |
if (x != 0) GfxFillRect(112, y - 2, 112 + x, y + 10, color_done); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
988 |
if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
989 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
990 |
/* Calculate the % */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
991 |
x = Clamp(val, 0, needed) * 100 / needed; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
992 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
993 |
/* SCORE_LOAN is inversed */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
994 |
if (val < 0 && i == SCORE_LOAN) x = 0; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
995 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
996 |
/* Draw it */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
997 |
SetDParam(0, x); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
998 |
DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
999 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1000 |
/* SCORE_LOAN is inversed */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1001 |
if (i == SCORE_LOAN) val = needed - val; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1002 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1003 |
/* Draw the amount we have against what is needed |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1004 |
* For some of them it is in currency format */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1005 |
SetDParam(0, val); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1006 |
SetDParam(1, needed); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1007 |
switch (i) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1008 |
case SCORE_MIN_PROFIT: |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1009 |
case SCORE_MIN_INCOME: |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1010 |
case SCORE_MAX_INCOME: |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1011 |
case SCORE_MONEY: |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1012 |
case SCORE_LOAN: |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1013 |
DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, TC_FROMSTRING); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1014 |
break; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1015 |
default: |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1016 |
DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, TC_FROMSTRING); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1017 |
} |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1018 |
} |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
1019 |
} |
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1020 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1021 |
virtual void OnClick(Point pt, int widget) |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1022 |
{ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1023 |
/* Check which button is clicked */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1024 |
if (IsInsideMM(widget, 13, 21)) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1025 |
/* Is it no on disable? */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1026 |
if (!this->IsWidgetDisabled(widget)) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1027 |
this->RaiseWidget(player + 13); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1028 |
player = (PlayerID)(widget - 13); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1029 |
this->LowerWidget(player + 13); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1030 |
this->SetDirty(); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1031 |
} |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1032 |
} |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1033 |
} |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1034 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1035 |
virtual void OnTick() |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1036 |
{ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1037 |
if (_pause_game != 0) return; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1038 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1039 |
/* Update the player score every 5 days */ |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1040 |
if (--this->timeout == 0) { |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1041 |
this->UpdatePlayerStats(); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1042 |
this->SetDirty(); |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1043 |
} |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1044 |
} |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1045 |
}; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1046 |
|
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1047 |
PlayerID PerformanceRatingDetailWindow::player = INVALID_PLAYER; |
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1048 |
|
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
1049 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
1050 |
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
|
1051 |
{ 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
|
1052 |
{ 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
|
1053 |
{ 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
|
1054 |
|
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1055 |
{ 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
|
1056 |
{ 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
|
1057 |
{ 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
|
1058 |
{ 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
|
1059 |
{ 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
|
1060 |
{ 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
|
1061 |
{ 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
|
1062 |
{ 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
|
1063 |
{ 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
|
1064 |
{ 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
|
1065 |
|
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1066 |
{ 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
|
1067 |
{ 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
|
1068 |
{ 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
|
1069 |
{ 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
|
1070 |
{ 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
|
1071 |
{ 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
|
1072 |
{ 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
|
1073 |
{ 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
|
1074 |
{ WIDGETS_END}, |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
1075 |
}; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
1076 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
1077 |
static const WindowDesc _performance_rating_detail_desc = { |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
1078 |
WDP_AUTO, WDP_AUTO, 299, 228, 299, 228, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6063
diff
changeset
|
1079 |
WC_PERFORMANCE_DETAIL, WC_NONE, |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
1080 |
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
|
1081 |
_performance_rating_detail_widgets, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
1082 |
}; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
1083 |
|
6573 | 1084 |
void ShowPerformanceRatingDetail() |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
1085 |
{ |
10577
77661b325257
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium
parents:
10462
diff
changeset
|
1086 |
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
|
1087 |
} |