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