author | truelight |
Wed, 25 Aug 2004 18:28:57 +0000 | |
changeset 140 | b00ce8503044 |
parent 116 | ca4332a9ec1d |
child 165 | f81fa8c27236 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
3 |
#include "window.h" |
|
4 |
#include "gui.h" |
|
5 |
#include "gfx.h" |
|
6 |
#include "player.h" |
|
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
7 |
#include "economy.h" |
0 | 8 |
|
9 |
static uint _legend_showbits; |
|
10 |
static uint _legend_cargobits; |
|
11 |
||
12 |
/************************/ |
|
13 |
/* GENERIC GRAPH DRAWER */ |
|
14 |
/************************/ |
|
15 |
||
16 |
typedef struct GraphDrawer { |
|
17 |
uint sel; |
|
18 |
byte num_dataset; |
|
19 |
byte num_on_x_axis; |
|
20 |
byte month; |
|
21 |
byte year; |
|
22 |
bool include_neg; |
|
23 |
byte num_vert_lines; |
|
24 |
uint16 unk61A; |
|
25 |
uint16 unk61C; |
|
26 |
int left, top; |
|
27 |
uint height; |
|
28 |
StringID format_str_y_axis; |
|
29 |
byte color_3, color_2, bg_line_color; |
|
30 |
byte colors[16]; |
|
31 |
uint32 cost[16][24]; |
|
32 |
} GraphDrawer; |
|
33 |
||
34 |
void DrawGraph(GraphDrawer *gw) |
|
35 |
{ |
|
36 |
||
37 |
int i,j,k; |
|
38 |
int x,y,old_x,old_y; |
|
39 |
int color; |
|
40 |
int right, bottom; |
|
41 |
int num_x, num_dataset; |
|
42 |
uint32 *row_ptr, *col_ptr; |
|
43 |
int32 mx; |
|
44 |
int adj_height; |
|
45 |
uint32 y_scaling, tmp; |
|
46 |
int32 value; |
|
47 |
int32 cur_val; |
|
48 |
uint sel; |
|
49 |
||
50 |
color = _color_list[gw->bg_line_color].window_color_1b; |
|
51 |
||
52 |
/* draw the vertical lines */ |
|
53 |
i = gw->num_vert_lines; assert(i > 0); |
|
54 |
x = gw->left + 66; |
|
55 |
bottom = gw->top + gw->height - 1; |
|
56 |
do { |
|
57 |
GfxFillRect(x, gw->top, x, bottom, color); |
|
58 |
x += 22; |
|
59 |
} while (--i); |
|
60 |
||
61 |
/* draw the horizontal lines */ |
|
62 |
i = 9; |
|
63 |
x = gw->left + 44; |
|
64 |
y = gw->height + gw->top; |
|
65 |
right = gw->left + 44 + gw->num_vert_lines*22-1; |
|
66 |
||
67 |
do { |
|
68 |
GfxFillRect(x, y, right, y, color); |
|
69 |
y -= gw->height >> 3; |
|
70 |
} while (--i); |
|
71 |
||
72 |
/* draw vertical edge line */ |
|
73 |
GfxFillRect(x, gw->top, x, bottom, gw->color_2); |
|
74 |
||
75 |
adj_height = gw->height; |
|
76 |
if (gw->include_neg) adj_height >>= 1; |
|
77 |
||
78 |
/* draw horiz edge line */ |
|
79 |
y = adj_height + gw->top; |
|
80 |
GfxFillRect(x, y, right, y, gw->color_2); |
|
81 |
||
82 |
/* find the max element */ |
|
83 |
if (gw->num_on_x_axis == 0) |
|
84 |
return; |
|
85 |
||
86 |
num_dataset = gw->num_dataset;assert(num_dataset > 0); |
|
87 |
row_ptr = gw->cost[0]; |
|
88 |
mx = 0; |
|
89 |
do { |
|
90 |
num_x = gw->num_on_x_axis;assert(num_x > 0); |
|
91 |
col_ptr = row_ptr; |
|
92 |
do { |
|
93 |
if (*col_ptr != 0x80000000) { |
|
94 |
mx = max(mx, myabs(*col_ptr)); |
|
95 |
} |
|
96 |
} while (col_ptr++, --num_x); |
|
97 |
} while (row_ptr+=24, --num_dataset); |
|
98 |
||
99 |
/* setup scaling */ |
|
100 |
y_scaling = 0x80000000; |
|
101 |
value = adj_height * 2; |
|
102 |
||
103 |
if (mx > value) { |
|
104 |
mx = (mx + 7) & ~7; |
|
105 |
y_scaling = (uint32) (((uint64) (value>>1) << 32) / mx); |
|
106 |
value = mx; |
|
107 |
} |
|
108 |
||
109 |
/* draw text strings on the y axis */ |
|
110 |
tmp = value; |
|
111 |
if (gw->include_neg) tmp >>= 1; |
|
112 |
x = gw->left + 45; |
|
113 |
y = gw->top - 3; |
|
114 |
i = 9; |
|
115 |
do { |
|
116 |
SET_DPARAM16(0, gw->format_str_y_axis); |
|
117 |
SET_DPARAM32(1, tmp); |
|
118 |
tmp -= (value >> 3); |
|
119 |
DrawStringRightAligned(x, y, STR_0170, gw->color_3); |
|
120 |
y += gw->height >> 3; |
|
121 |
} while (--i); |
|
122 |
||
123 |
/* draw strings on the x axis */ |
|
124 |
if (gw->month != 0xFF) { |
|
125 |
x = gw->left + 44; |
|
126 |
y = gw->top + gw->height + 1; |
|
127 |
j = gw->month; |
|
128 |
k = gw->year + 1920; |
|
129 |
i = gw->num_on_x_axis;assert(i>0); |
|
130 |
do { |
|
131 |
SET_DPARAM16(2, k); |
|
132 |
SET_DPARAM16(0, j + STR_0162_JAN); |
|
133 |
SET_DPARAM16(1, j + STR_0162_JAN + 2); |
|
134 |
DrawString(x, y, j == 0 ? STR_016F : STR_016E, gw->color_3); |
|
135 |
||
136 |
j += 3; |
|
137 |
if (j >= 12) { |
|
138 |
j = 0; |
|
139 |
k++; |
|
140 |
} |
|
141 |
x += 22; |
|
142 |
} while (--i); |
|
143 |
} else { |
|
144 |
x = gw->left + 52; |
|
145 |
y = gw->top + gw->height + 1; |
|
146 |
j = gw->unk61A; |
|
147 |
i = gw->num_on_x_axis;assert(i>0); |
|
148 |
do { |
|
149 |
SET_DPARAM16(0, j); |
|
150 |
DrawString(x, y, STR_01CB, gw->color_3); |
|
151 |
j += gw->unk61C; |
|
152 |
x += 22; |
|
153 |
} while (--i); |
|
154 |
} |
|
155 |
||
156 |
/* draw lines and dots */ |
|
157 |
i = 0; |
|
158 |
row_ptr = gw->cost[0]; |
|
159 |
sel = gw->sel; |
|
160 |
do { |
|
161 |
if (!(sel & 1)) { |
|
162 |
x = gw->left + 55; |
|
163 |
j = gw->num_on_x_axis;assert(j>0); |
|
164 |
col_ptr = row_ptr; |
|
165 |
color = gw->colors[i]; |
|
166 |
old_y = old_x = 0x80000000; |
|
167 |
do { |
|
168 |
cur_val = *col_ptr++; |
|
169 |
if (cur_val != (int32)0x80000000) { |
|
170 |
y = adj_height - BIGMULSS(cur_val, y_scaling >> 1, 31) + gw->top; |
|
171 |
||
172 |
GfxFillRect(x-1, y-1, x+1, y+1, color); |
|
173 |
if (old_x != 0x80000000) |
|
174 |
GfxDrawLine(old_x, old_y, x, y, color); |
|
175 |
||
176 |
old_x = x; |
|
177 |
old_y = y; |
|
178 |
} else { |
|
179 |
old_x = 0x80000000; |
|
180 |
} |
|
181 |
} while (x+=22,--j); |
|
182 |
} |
|
183 |
} while (sel>>=1,row_ptr+=24, ++i < gw->num_dataset); |
|
184 |
} |
|
185 |
||
186 |
/****************/ |
|
187 |
/* GRAPH LEGEND */ |
|
188 |
/****************/ |
|
189 |
||
190 |
void DrawPlayerIcon(int p, int x, int y) |
|
191 |
{ |
|
192 |
DrawSprite(SPRITE_PALETTE(PLAYER_SPRITE_COLOR(p) + 0x2EB), x, y); |
|
193 |
} |
|
194 |
||
195 |
static void GraphLegendWndProc(Window *w, WindowEvent *e) |
|
196 |
{ |
|
197 |
Player *p; |
|
198 |
||
199 |
switch(e->event) { |
|
200 |
case WE_PAINT: |
|
201 |
FOR_ALL_PLAYERS(p) { |
|
202 |
if (!p->is_active) |
|
203 |
SETBIT(_legend_showbits, p->index); |
|
204 |
} |
|
205 |
w->click_state = ((~_legend_showbits) << 3); |
|
206 |
DrawWindowWidgets(w); |
|
207 |
||
208 |
FOR_ALL_PLAYERS(p) { |
|
209 |
if (!p->is_active) |
|
210 |
continue; |
|
211 |
||
212 |
DrawPlayerIcon(p->index, 4, 18+p->index*12); |
|
213 |
||
214 |
SET_DPARAM16(0, p->name_1); |
|
215 |
SET_DPARAM32(1, p->name_2); |
|
2
104b2984cd3e
(svn r3) -[1005611] Player Window patch: When looking in dropdownlist for player stuff, it will say
darkvater
parents:
0
diff
changeset
|
216 |
SET_DPARAM16(2, GetPlayerNameString(p->index, 3)); |
0 | 217 |
DrawString(21,17+p->index*12,STR_7021,HASBIT(_legend_showbits, p->index) ? 0x10 : 0xC); |
218 |
} |
|
219 |
break; |
|
220 |
||
221 |
case WE_CLICK: |
|
222 |
if (IS_INT_INSIDE(e->click.widget, 3, 11)) { |
|
223 |
_legend_showbits ^= (1 << (e->click.widget-3)); |
|
224 |
SetWindowDirty(w); |
|
225 |
InvalidateWindow(WC_INCOME_GRAPH, 0); |
|
226 |
InvalidateWindow(WC_OPERATING_PROFIT, 0); |
|
227 |
InvalidateWindow(WC_DELIVERED_CARGO, 0); |
|
228 |
InvalidateWindow(WC_PERFORMANCE_HISTORY, 0); |
|
140
b00ce8503044
(svn r141) -Fix: Company-value was not updated immediatly if legend was changed
truelight
parents:
116
diff
changeset
|
229 |
InvalidateWindow(WC_COMPANY_VALUE, 0); |
0 | 230 |
} |
231 |
break; |
|
232 |
} |
|
233 |
} |
|
234 |
||
235 |
static const Widget _graph_legend_widgets[] = { |
|
236 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
237 |
{ WWT_CAPTION, 14, 11, 249, 0, 13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
238 |
{ WWT_IMGBTN, 14, 0, 249, 14, 113, 0x0}, |
|
239 |
{ WWT_IMGBTN, 14, 2, 247, 16, 27, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
|
240 |
{ WWT_IMGBTN, 14, 2, 247, 28, 39, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
|
241 |
{ WWT_IMGBTN, 14, 2, 247, 40, 51, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
|
242 |
{ WWT_IMGBTN, 14, 2, 247, 52, 63, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
|
243 |
{ WWT_IMGBTN, 14, 2, 247, 64, 75, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
|
244 |
{ WWT_IMGBTN, 14, 2, 247, 76, 87, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
|
245 |
{ WWT_IMGBTN, 14, 2, 247, 88, 99, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
|
246 |
{ WWT_IMGBTN, 14, 2, 247, 100, 111, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
|
247 |
{ WWT_LAST}, |
|
248 |
}; |
|
249 |
||
250 |
static const WindowDesc _graph_legend_desc = { |
|
251 |
-1, -1, 250, 114, |
|
252 |
WC_GRAPH_LEGEND,0, |
|
253 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
254 |
_graph_legend_widgets, |
|
255 |
GraphLegendWndProc |
|
256 |
}; |
|
257 |
||
258 |
static void ShowGraphLegend() |
|
259 |
{ |
|
260 |
AllocateWindowDescFront(&_graph_legend_desc, 0); |
|
261 |
} |
|
262 |
||
263 |
/********************/ |
|
264 |
/* OPERATING PROFIT */ |
|
265 |
/********************/ |
|
266 |
||
267 |
static void SetupGraphDrawerForPlayers(GraphDrawer *gd) |
|
268 |
{ |
|
269 |
Player *p; |
|
270 |
uint showbits = _legend_showbits; |
|
271 |
int nums; |
|
272 |
int mo,yr; |
|
273 |
||
274 |
// Exclude the players which aren't valid |
|
275 |
FOR_ALL_PLAYERS(p) { |
|
276 |
if (!p->is_active) CLRBIT(showbits,p->index); |
|
277 |
} |
|
278 |
gd->sel = showbits; |
|
279 |
gd->num_vert_lines = 24; |
|
280 |
||
281 |
nums = 0; |
|
282 |
FOR_ALL_PLAYERS(p) { |
|
283 |
if (p->is_active) nums = max(nums,p->num_valid_stat_ent); |
|
284 |
} |
|
285 |
gd->num_on_x_axis = min(nums,24); |
|
286 |
||
287 |
mo = (_cur_month/3-nums)*3; |
|
288 |
yr = _cur_year; |
|
289 |
while (mo < 0) { |
|
290 |
yr--; |
|
291 |
mo += 12; |
|
292 |
} |
|
293 |
||
294 |
gd->year = yr; |
|
295 |
gd->month = mo; |
|
296 |
} |
|
297 |
||
298 |
static void OperatingProfitWndProc(Window *w, WindowEvent *e) |
|
299 |
{ |
|
300 |
switch(e->event) { |
|
301 |
case WE_PAINT: { |
|
302 |
GraphDrawer gd; |
|
303 |
Player *p; |
|
304 |
int i,j; |
|
305 |
int numd; |
|
306 |
||
307 |
DrawWindowWidgets(w); |
|
308 |
||
309 |
gd.left = 2; |
|
310 |
gd.top = 18; |
|
311 |
gd.height = 136; |
|
312 |
gd.include_neg = true; |
|
313 |
gd.format_str_y_axis = STR_7023; |
|
314 |
gd.color_3 = 0x10; |
|
315 |
gd.color_2 = 0xD7; |
|
316 |
gd.bg_line_color = 0xE; |
|
317 |
||
318 |
SetupGraphDrawerForPlayers(&gd); |
|
319 |
||
320 |
numd = 0; |
|
321 |
FOR_ALL_PLAYERS(p) { |
|
322 |
if (!p->is_active) |
|
323 |
continue; |
|
324 |
gd.colors[numd] = _color_list[p->player_color].window_color_bgb; |
|
325 |
for(j=gd.num_on_x_axis,i=0; --j >= 0;) { |
|
326 |
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? 0x80000000 : (p->old_economy[j].income + p->old_economy[j].expenses); |
|
327 |
i++; |
|
328 |
} |
|
329 |
numd++; |
|
330 |
} |
|
331 |
gd.num_dataset=numd; |
|
332 |
||
333 |
DrawGraph(&gd); |
|
334 |
break; |
|
335 |
} |
|
336 |
||
337 |
case WE_CLICK: |
|
338 |
if (e->click.widget == 2) |
|
339 |
ShowGraphLegend(); |
|
340 |
break; |
|
341 |
} |
|
342 |
} |
|
343 |
||
344 |
static const Widget _operating_profit_widgets[] = { |
|
345 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW}, |
|
346 |
{ WWT_CAPTION, 14, 11, 525, 0, 13, STR_7025_OPERATING_PROFIT_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
347 |
{ WWT_PUSHTXTBTN, 14, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS}, |
|
348 |
{ WWT_IMGBTN, 14, 0, 575, 14, 173, 0x0}, |
|
349 |
{ WWT_LAST}, |
|
350 |
}; |
|
351 |
||
352 |
static const WindowDesc _operating_profit_desc = { |
|
353 |
-1, -1, 576, 174, |
|
354 |
WC_OPERATING_PROFIT,0, |
|
355 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
356 |
_operating_profit_widgets, |
|
357 |
OperatingProfitWndProc |
|
358 |
}; |
|
359 |
||
360 |
||
361 |
void ShowOperatingProfitGraph() |
|
362 |
{ |
|
363 |
if (AllocateWindowDescFront(&_operating_profit_desc, 0)) { |
|
364 |
InvalidateWindow(WC_GRAPH_LEGEND, 0); |
|
365 |
_legend_showbits = 0; |
|
366 |
} |
|
367 |
} |
|
368 |
||
369 |
||
370 |
/****************/ |
|
371 |
/* INCOME GRAPH */ |
|
372 |
/****************/ |
|
373 |
||
374 |
static void IncomeGraphWndProc(Window *w, WindowEvent *e) |
|
375 |
{ |
|
376 |
switch(e->event) { |
|
377 |
case WE_PAINT: { |
|
378 |
GraphDrawer gd; |
|
379 |
Player *p; |
|
380 |
int i,j; |
|
381 |
int numd; |
|
382 |
||
383 |
DrawWindowWidgets(w); |
|
384 |
||
385 |
gd.left = 2; |
|
386 |
gd.top = 18; |
|
387 |
gd.height = 104; |
|
388 |
gd.include_neg = false; |
|
389 |
gd.format_str_y_axis = STR_7023; |
|
390 |
gd.color_3 = 0x10; |
|
391 |
gd.color_2 = 0xD7; |
|
392 |
gd.bg_line_color = 0xE; |
|
393 |
SetupGraphDrawerForPlayers(&gd); |
|
394 |
||
395 |
numd = 0; |
|
396 |
FOR_ALL_PLAYERS(p) { |
|
397 |
if (!p->is_active) |
|
398 |
continue; |
|
399 |
gd.colors[numd] = _color_list[p->player_color].window_color_bgb; |
|
400 |
for(j=gd.num_on_x_axis,i=0; --j >= 0;) { |
|
401 |
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? 0x80000000 : (p->old_economy[j].income); |
|
402 |
i++; |
|
403 |
} |
|
404 |
numd++; |
|
405 |
} |
|
406 |
||
407 |
gd.num_dataset = numd; |
|
408 |
||
409 |
DrawGraph(&gd); |
|
410 |
break; |
|
411 |
} |
|
412 |
||
413 |
case WE_CLICK: |
|
414 |
if (e->click.widget == 2) |
|
415 |
ShowGraphLegend(); |
|
416 |
break; |
|
417 |
} |
|
418 |
} |
|
419 |
||
420 |
static const Widget _income_graph_widgets[] = { |
|
421 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW}, |
|
422 |
{ WWT_CAPTION, 14, 11, 525, 0, 13, STR_7022_INCOME_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
423 |
{ WWT_PUSHTXTBTN, 14, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS}, |
|
424 |
{ WWT_IMGBTN, 14, 0, 575, 14, 141, 0x0}, |
|
425 |
{ WWT_LAST}, |
|
426 |
}; |
|
427 |
||
428 |
static const WindowDesc _income_graph_desc = { |
|
429 |
-1, -1, 576, 142, |
|
430 |
WC_INCOME_GRAPH,0, |
|
431 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
432 |
_income_graph_widgets, |
|
433 |
IncomeGraphWndProc |
|
434 |
}; |
|
435 |
||
436 |
void ShowIncomeGraph() |
|
437 |
{ |
|
438 |
if (AllocateWindowDescFront(&_income_graph_desc, 0)) { |
|
439 |
InvalidateWindow(WC_GRAPH_LEGEND, 0); |
|
440 |
_legend_showbits = 0; |
|
441 |
} |
|
442 |
} |
|
443 |
||
444 |
/*******************/ |
|
445 |
/* DELIVERED CARGO */ |
|
446 |
/*******************/ |
|
447 |
||
448 |
static void DeliveredCargoGraphWndProc(Window *w, WindowEvent *e) |
|
449 |
{ |
|
450 |
switch(e->event) { |
|
451 |
case WE_PAINT: { |
|
452 |
GraphDrawer gd; |
|
453 |
Player *p; |
|
454 |
int i,j; |
|
455 |
int numd; |
|
456 |
||
457 |
DrawWindowWidgets(w); |
|
458 |
||
459 |
gd.left = 2; |
|
460 |
gd.top = 18; |
|
461 |
gd.height = 104; |
|
462 |
gd.include_neg = false; |
|
463 |
gd.format_str_y_axis = STR_7024; |
|
464 |
gd.color_3 = 0x10; |
|
465 |
gd.color_2 = 0xD7; |
|
466 |
gd.bg_line_color = 0xE; |
|
467 |
SetupGraphDrawerForPlayers(&gd); |
|
468 |
||
469 |
numd = 0; |
|
470 |
FOR_ALL_PLAYERS(p) { |
|
471 |
if (!p->is_active) |
|
472 |
continue; |
|
473 |
gd.colors[numd] = _color_list[p->player_color].window_color_bgb; |
|
474 |
for(j=gd.num_on_x_axis,i=0; --j >= 0;) { |
|
475 |
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? 0x80000000 : p->old_economy[j].delivered_cargo; |
|
476 |
i++; |
|
477 |
} |
|
478 |
numd++; |
|
479 |
} |
|
480 |
||
481 |
gd.num_dataset = numd; |
|
482 |
||
483 |
DrawGraph(&gd); |
|
484 |
break; |
|
485 |
} |
|
486 |
||
487 |
case WE_CLICK: |
|
488 |
if (e->click.widget == 2) |
|
489 |
ShowGraphLegend(); |
|
490 |
break; |
|
491 |
} |
|
492 |
} |
|
493 |
||
494 |
static const Widget _delivered_cargo_graph_widgets[] = { |
|
495 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
496 |
{ WWT_CAPTION, 14, 11, 525, 0, 13, STR_7050_UNITS_OF_CARGO_DELIVERED, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
497 |
{ WWT_PUSHTXTBTN, 14, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS}, |
|
498 |
{ WWT_IMGBTN, 14, 0, 575, 14, 141, 0x0}, |
|
499 |
{ WWT_LAST}, |
|
500 |
}; |
|
501 |
||
502 |
static const WindowDesc _delivered_cargo_graph_desc = { |
|
503 |
-1, -1, 576, 142, |
|
504 |
WC_DELIVERED_CARGO,0, |
|
505 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
506 |
_delivered_cargo_graph_widgets, |
|
507 |
DeliveredCargoGraphWndProc |
|
508 |
}; |
|
509 |
||
510 |
void ShowDeliveredCargoGraph() |
|
511 |
{ |
|
512 |
if (AllocateWindowDescFront(&_delivered_cargo_graph_desc, 0)) { |
|
513 |
InvalidateWindow(WC_GRAPH_LEGEND, 0); |
|
514 |
_legend_showbits = 0; |
|
515 |
} |
|
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
516 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
517 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
518 |
/*****************************/ |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
519 |
/* PERFORMANCE RATING DETAIL */ |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
520 |
/*****************************/ |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
521 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
522 |
static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
523 |
{ |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
524 |
switch(e->event) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
525 |
case WE_PAINT: { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
526 |
int val, needed, score, i; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
527 |
byte owner, x; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
528 |
uint16 y=14; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
529 |
int total_score = 0; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
530 |
int color_done, color_notdone; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
531 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
532 |
// Draw standard stuff |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
533 |
DrawWindowWidgets(w); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
534 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
535 |
// The player of which we check the detail performance rating |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
536 |
owner = FindFirstBit(w->click_state) - 13; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
537 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
538 |
// Paint the player icons |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
539 |
for (i=0;i<MAX_PLAYERS;i++) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
540 |
if (!DEREF_PLAYER(i)->is_active) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
541 |
// Check if we have the player as an active player |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
542 |
if (!(w->disabled_state & (1 << (i+13)))) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
543 |
// Bah, player gone :( |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
544 |
w->disabled_state += 1 << (i+13); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
545 |
// Is this player selected? If so, select first player (always save? :s) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
546 |
if (w->click_state == 1 << (i+13)) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
547 |
w->click_state = 1 << 13; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
548 |
// We need a repaint |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
549 |
SetWindowDirty(w); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
550 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
551 |
continue; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
552 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
553 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
554 |
// Check if we have the player marked as inactive |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
555 |
if ((w->disabled_state & (1 << (i+13)))) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
556 |
// New player! Yippie :p |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
557 |
w->disabled_state -= 1 << (i+13); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
558 |
// We need a repaint |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
559 |
SetWindowDirty(w); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
560 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
561 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
562 |
if (i == owner) x = 1; else x = 0; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
563 |
DrawPlayerIcon(i, i*33+11+x, 16+x); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
564 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
565 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
566 |
// The colors used to show how the progress is going |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
567 |
color_done = _color_list[6].window_color_1b; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
568 |
color_notdone = _color_list[4].window_color_1b; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
569 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
570 |
// Draw all the score parts |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
571 |
for (i=0;i<NUM_SCORE;i++) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
572 |
y += 20; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
573 |
val = _score_part[owner][i]; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
574 |
needed = score_info[i].needed; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
575 |
score = score_info[i].score; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
576 |
// SCORE_TOTAL has his own rulez ;) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
577 |
if (i == SCORE_TOTAL) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
578 |
needed = total_score; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
579 |
score = SCORE_MAX; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
580 |
} else |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
581 |
total_score += score; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
582 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
583 |
DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, 0); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
584 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
585 |
// Draw the score |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
586 |
SET_DPARAM32(0, score); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
587 |
DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
588 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
589 |
// Calculate the %-bar |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
590 |
if (val > needed) x = 50; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
591 |
else if (val == 0) x = 0; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
592 |
else x = ((val * 50) / needed); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
593 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
594 |
// SCORE_LOAN is inversed |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
595 |
if (val < 0 && i == SCORE_LOAN) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
596 |
x = 0; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
597 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
598 |
// Draw the bar |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
599 |
if (x != 0) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
600 |
GfxFillRect(112, y-2, x + 112, y+10, color_done); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
601 |
if (x != 50) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
602 |
GfxFillRect(x + 112, y-2, 50 + 112, y+10, color_notdone); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
603 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
604 |
// Calculate the % |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
605 |
if (val > needed) x = 100; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
606 |
else x = ((val * 100) / needed); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
607 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
608 |
// SCORE_LOAN is inversed |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
609 |
if (val < 0 && i == SCORE_LOAN) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
610 |
x = 0; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
611 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
612 |
// Draw it |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
613 |
SET_DPARAM32(0, x); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
614 |
DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, 0); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
615 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
616 |
// SCORE_LOAN is inversed |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
617 |
if (i == SCORE_LOAN) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
618 |
val = needed - val; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
619 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
620 |
// Draw the amount we have against what is needed |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
621 |
// For some of them it is in currency format |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
622 |
SET_DPARAM32(0, val); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
623 |
SET_DPARAM32(1, needed); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
624 |
switch (i) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
625 |
case SCORE_MIN_PROFIT: |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
626 |
case SCORE_MIN_INCOME: |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
627 |
case SCORE_MAX_INCOME: |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
628 |
case SCORE_MONEY: |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
629 |
case SCORE_LOAN: |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
630 |
DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, 0); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
631 |
break; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
632 |
default: |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
633 |
DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, 0); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
634 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
635 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
636 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
637 |
break; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
638 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
639 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
640 |
case WE_CLICK: |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
641 |
// Check which button is clicked |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
642 |
if (IS_INT_INSIDE(e->click.widget, 13, 21)) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
643 |
// Is it no on disable? |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
644 |
if ((w->disabled_state & (1 << e->click.widget)) == 0) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
645 |
w->click_state = 1 << e->click.widget; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
646 |
SetWindowDirty(w); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
647 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
648 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
649 |
break; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
650 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
651 |
case WE_CREATE: |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
652 |
{ |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
653 |
int i; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
654 |
Player *p2; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
655 |
w->hidden_state = 0; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
656 |
w->disabled_state = 0; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
657 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
658 |
// Hide the player who are not active |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
659 |
for (i=0;i<MAX_PLAYERS;i++) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
660 |
if (!DEREF_PLAYER(i)->is_active) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
661 |
w->disabled_state += 1 << (i+13); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
662 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
663 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
664 |
// Update all player stats with the current data |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
665 |
// (this is because _score_info is not saved to a savegame) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
666 |
FOR_ALL_PLAYERS(p2) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
667 |
if (p2->is_active) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
668 |
UpdateCompanyRatingAndValue(p2, false); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
669 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
670 |
w->custom[0] = 74; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
671 |
w->custom[1] = 5; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
672 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
673 |
w->click_state = 1 << 13; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
674 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
675 |
SetWindowDirty(w); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
676 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
677 |
break; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
678 |
case WE_TICK: |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
679 |
{ |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
680 |
// Update the player score every 5 days |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
681 |
if (--w->custom[0] == 0) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
682 |
w->custom[0] = 74; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
683 |
if (--w->custom[1] == 0) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
684 |
Player *p2; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
685 |
w->custom[1] = 5; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
686 |
FOR_ALL_PLAYERS(p2) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
687 |
// Skip if player is not active |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
688 |
if (p2->is_active) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
689 |
UpdateCompanyRatingAndValue(p2, false); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
690 |
SetWindowDirty(w); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
691 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
692 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
693 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
694 |
break; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
695 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
696 |
} |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
697 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
698 |
static const Widget _performance_rating_detail_widgets[] = { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
699 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
700 |
{ WWT_CAPTION, 14, 11, 266, 0, 13, STR_PERFORMANCE_DETAIL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
701 |
{ WWT_IMGBTN, 14, 0, 266, 14, 27, 0x0}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
702 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
703 |
{ WWT_IMGBTN, 14, 0, 266, 28, 47, 0x0,STR_PERFORMANCE_DETAIL_VEHICLES_TIP}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
704 |
{ WWT_IMGBTN, 14, 0, 266, 48, 67, 0x0,STR_PERFORMANCE_DETAIL_STATIONS_TIP}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
705 |
{ WWT_IMGBTN, 14, 0, 266, 68, 87, 0x0,STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
706 |
{ WWT_IMGBTN, 14, 0, 266, 88, 107, 0x0,STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
707 |
{ WWT_IMGBTN, 14, 0, 266, 108, 127, 0x0,STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
708 |
{ WWT_IMGBTN, 14, 0, 266, 128, 147, 0x0,STR_PERFORMANCE_DETAIL_DELIVERED_TIP}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
709 |
{ WWT_IMGBTN, 14, 0, 266, 148, 167, 0x0,STR_PERFORMANCE_DETAIL_CARGO_TIP}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
710 |
{ WWT_IMGBTN, 14, 0, 266, 168, 187, 0x0,STR_PERFORMANCE_DETAIL_MONEY_TIP}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
711 |
{ WWT_IMGBTN, 14, 0, 266, 188, 207, 0x0,STR_PERFORMANCE_DETAIL_LOAN_TIP}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
712 |
{ WWT_IMGBTN, 14, 0, 266, 208, 227, 0x0,STR_PERFORMANCE_DETAIL_TOTAL_TIP}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
713 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
714 |
{ WWT_IMGBTN, 14, 2, 34, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
715 |
{ WWT_IMGBTN, 14, 35, 67, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
716 |
{ WWT_IMGBTN, 14, 68, 100, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
717 |
{ WWT_IMGBTN, 14, 101, 133, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
718 |
{ WWT_IMGBTN, 14, 134, 166, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
719 |
{ WWT_IMGBTN, 14, 167, 199, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
720 |
{ WWT_IMGBTN, 14, 200, 232, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
721 |
{ WWT_IMGBTN, 14, 233, 265, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
722 |
{ WWT_LAST}, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
723 |
}; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
724 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
725 |
static const WindowDesc _performance_rating_detail_desc = { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
726 |
-1, -1, 267, 228, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
727 |
WC_PERFORMANCE_DETAIL,0, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
728 |
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
|
729 |
_performance_rating_detail_widgets, |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
730 |
PerformanceRatingDetailWndProc |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
731 |
}; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
732 |
|
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
733 |
void ShowPerformanceRatingDetail() |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
734 |
{ |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
735 |
AllocateWindowDescFront(&_performance_rating_detail_desc, 0); |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
736 |
} |
0 | 737 |
|
738 |
/***********************/ |
|
739 |
/* PERFORMANCE HISTORY */ |
|
740 |
/***********************/ |
|
741 |
||
742 |
static void PerformanceHistoryWndProc(Window *w, WindowEvent *e) |
|
743 |
{ |
|
744 |
switch(e->event) { |
|
745 |
case WE_PAINT: { |
|
746 |
GraphDrawer gd; |
|
747 |
Player *p; |
|
748 |
int i,j; |
|
749 |
int numd; |
|
750 |
||
751 |
DrawWindowWidgets(w); |
|
752 |
||
753 |
gd.left = 2; |
|
754 |
gd.top = 18; |
|
755 |
gd.height = 200; |
|
756 |
gd.include_neg = false; |
|
757 |
gd.format_str_y_axis = STR_7024; |
|
758 |
gd.color_3 = 0x10; |
|
759 |
gd.color_2 = 0xD7; |
|
760 |
gd.bg_line_color = 0xE; |
|
761 |
SetupGraphDrawerForPlayers(&gd); |
|
762 |
||
763 |
numd = 0; |
|
764 |
FOR_ALL_PLAYERS(p) { |
|
765 |
if (!p->is_active) |
|
766 |
continue; |
|
767 |
gd.colors[numd] = _color_list[p->player_color].window_color_bgb; |
|
768 |
for(j=gd.num_on_x_axis,i=0; --j >= 0;) { |
|
769 |
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? 0x80000000 : p->old_economy[j].performance_history; |
|
770 |
i++; |
|
771 |
} |
|
772 |
numd++; |
|
773 |
} |
|
774 |
gd.num_dataset = numd; |
|
775 |
||
776 |
DrawGraph(&gd); |
|
777 |
break; |
|
778 |
} |
|
779 |
||
780 |
case WE_CLICK: |
|
781 |
if (e->click.widget == 2) |
|
782 |
ShowGraphLegend(); |
|
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
783 |
if (e->click.widget == 3) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
784 |
ShowPerformanceRatingDetail(); |
0 | 785 |
break; |
786 |
} |
|
787 |
} |
|
788 |
||
789 |
static const Widget _performance_history_widgets[] = { |
|
790 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
791 |
{ WWT_CAPTION, 14, 11, 475, 0, 13, STR_7051_COMPANY_PERFORMANCE_RATINGS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
0 | 792 |
{ WWT_PUSHTXTBTN, 14, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS}, |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
57
diff
changeset
|
793 |
{ WWT_PUSHTXTBTN, 14, 476, 525, 0, 13, STR_PERFORMANCE_DETAIL_KEY, STR_704D_SHOW_KEY_TO_GRAPHS}, |
0 | 794 |
{ WWT_IMGBTN, 14, 0, 575, 14, 237, 0x0}, |
795 |
{ WWT_LAST}, |
|
796 |
}; |
|
797 |
||
798 |
static const WindowDesc _performance_history_desc = { |
|
799 |
-1, -1, 576, 238, |
|
800 |
WC_PERFORMANCE_HISTORY,0, |
|
801 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
802 |
_performance_history_widgets, |
|
803 |
PerformanceHistoryWndProc |
|
804 |
}; |
|
805 |
||
806 |
void ShowPerformanceHistoryGraph() |
|
807 |
{ |
|
808 |
if (AllocateWindowDescFront(&_performance_history_desc, 0)) { |
|
809 |
InvalidateWindow(WC_GRAPH_LEGEND, 0); |
|
810 |
_legend_showbits = 0; |
|
811 |
} |
|
812 |
} |
|
813 |
||
814 |
/*****************/ |
|
815 |
/* COMPANY VALUE */ |
|
816 |
/*****************/ |
|
817 |
||
818 |
static void CompanyValueGraphWndProc(Window *w, WindowEvent *e) |
|
819 |
{ |
|
820 |
switch(e->event) { |
|
821 |
case WE_PAINT: { |
|
822 |
GraphDrawer gd; |
|
823 |
Player *p; |
|
824 |
int i,j; |
|
825 |
int numd; |
|
826 |
||
827 |
DrawWindowWidgets(w); |
|
828 |
||
829 |
gd.left = 2; |
|
830 |
gd.top = 18; |
|
831 |
gd.height = 200; |
|
832 |
gd.include_neg = false; |
|
833 |
gd.format_str_y_axis = STR_7023; |
|
834 |
gd.color_3 = 0x10; |
|
835 |
gd.color_2 = 0xD7; |
|
836 |
gd.bg_line_color = 0xE; |
|
837 |
SetupGraphDrawerForPlayers(&gd); |
|
838 |
||
839 |
numd = 0; |
|
840 |
FOR_ALL_PLAYERS(p) { |
|
841 |
if (!p->is_active) |
|
842 |
continue; |
|
843 |
gd.colors[numd] = _color_list[p->player_color].window_color_bgb; |
|
844 |
for(j=gd.num_on_x_axis,i=0; --j >= 0;) { |
|
845 |
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? 0x80000000 : (p->old_economy[j].company_value); |
|
846 |
i++; |
|
847 |
} |
|
848 |
numd++; |
|
849 |
} |
|
850 |
gd.num_dataset = numd; |
|
851 |
||
852 |
||
853 |
DrawGraph(&gd); |
|
854 |
break; |
|
855 |
} |
|
856 |
||
857 |
case WE_CLICK: |
|
858 |
if (e->click.widget == 2) |
|
859 |
ShowGraphLegend(); |
|
860 |
break; |
|
861 |
} |
|
862 |
} |
|
863 |
||
864 |
static const Widget _company_value_graph_widgets[] = { |
|
865 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
866 |
{ WWT_CAPTION, 14, 11, 525, 0, 13, STR_7052_COMPANY_VALUES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
867 |
{ WWT_PUSHTXTBTN, 14, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS}, |
|
868 |
{ WWT_IMGBTN, 14, 0, 575, 14, 237, 0x0}, |
|
869 |
{ WWT_LAST}, |
|
870 |
}; |
|
871 |
||
872 |
static const WindowDesc _company_value_graph_desc = { |
|
873 |
-1, -1, 576, 238, |
|
874 |
WC_COMPANY_VALUE,0, |
|
875 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
876 |
_company_value_graph_widgets, |
|
877 |
CompanyValueGraphWndProc |
|
878 |
}; |
|
879 |
||
880 |
void ShowCompanyValueGraph() |
|
881 |
{ |
|
882 |
if (AllocateWindowDescFront(&_company_value_graph_desc, 0)) { |
|
883 |
InvalidateWindow(WC_GRAPH_LEGEND, 0); |
|
884 |
_legend_showbits = 0; |
|
885 |
} |
|
886 |
} |
|
887 |
||
888 |
/*****************/ |
|
889 |
/* PAYMENT RATES */ |
|
890 |
/*****************/ |
|
891 |
||
892 |
static const byte _cargo_legend_colors[12] = {152, 32, 15, 174, 208, 194, 191, 84, 184, 10, 202, 215}; |
|
893 |
||
894 |
static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e) |
|
895 |
{ |
|
896 |
switch(e->event) { |
|
897 |
case WE_PAINT: { |
|
898 |
int i, j, x, y; |
|
899 |
GraphDrawer gd; |
|
900 |
||
901 |
gd.sel = _legend_cargobits; |
|
902 |
w->click_state = (~_legend_cargobits) << 3; |
|
903 |
DrawWindowWidgets(w); |
|
904 |
||
905 |
x = 495; |
|
906 |
y = 25; |
|
907 |
||
908 |
for(i=0; i!=NUM_CARGO; i++) { |
|
909 |
GfxFillRect(x, y, x+8, y+5, 0); |
|
910 |
GfxFillRect(x+1, y+1, x+7, y+4, _cargo_legend_colors[i]); |
|
911 |
SET_DPARAM16(0, _cargoc.names_s[i]); |
|
912 |
DrawString(x+14, y, STR_7065, 0); |
|
913 |
y += 8; |
|
914 |
} |
|
915 |
||
916 |
gd.left = 2; |
|
917 |
gd.top = 24; |
|
918 |
gd.height = 104; |
|
919 |
gd.include_neg = false; |
|
920 |
gd.format_str_y_axis = STR_7023; |
|
921 |
gd.color_3 = 16; |
|
922 |
gd.color_2 = 215; |
|
923 |
gd.bg_line_color = 14; |
|
924 |
gd.num_dataset = 12; |
|
925 |
gd.num_on_x_axis = 20; |
|
926 |
gd.num_vert_lines = 20; |
|
927 |
gd.month = 0xFF; |
|
928 |
gd.unk61A = 10; |
|
929 |
gd.unk61C = 10; |
|
930 |
||
931 |
for(i=0; i!=NUM_CARGO; i++) { |
|
932 |
gd.colors[i] = _cargo_legend_colors[i]; |
|
933 |
for(j=0; j!=20; j++) { |
|
934 |
gd.cost[i][j] = GetTransportedGoodsIncome(10, 20, j*6+6,i); |
|
935 |
} |
|
936 |
} |
|
937 |
||
938 |
DrawGraph(&gd); |
|
939 |
||
940 |
DrawString(2 + 46, 24 + gd.height + 7, STR_7062_DAYS_IN_TRANSIT, 0); |
|
941 |
DrawString(2 + 84, 24 - 9, STR_7063_PAYMENT_FOR_DELIVERING, 0); |
|
942 |
} break; |
|
943 |
||
944 |
case WE_CLICK: { |
|
945 |
switch(e->click.widget) { |
|
946 |
case 3: case 4: case 5: case 6: |
|
947 |
case 7: case 8: case 9: case 10: |
|
948 |
case 11: case 12: case 13: case 14: |
|
949 |
_legend_cargobits ^= 1 << (e->click.widget - 3); |
|
950 |
SetWindowDirty(w); |
|
951 |
break; |
|
952 |
} |
|
953 |
} break; |
|
954 |
} |
|
955 |
} |
|
956 |
||
957 |
static const Widget _cargo_payment_rates_widgets[] = { |
|
958 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
959 |
{ WWT_CAPTION, 14, 11, 567, 0, 13, STR_7061_CARGO_PAYMENT_RATES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
960 |
{ WWT_PANEL, 14, 0, 567, 14, 141, 0x0, 0}, |
|
961 |
{ WWT_PANEL, 12, 493, 562, 24, 31, 0x0, STR_7064_TOGGLE_GRAPH_FOR_CARGO}, |
|
962 |
{ WWT_PANEL, 12, 493, 562, 32, 39, 0x0, STR_7064_TOGGLE_GRAPH_FOR_CARGO}, |
|
963 |
{ WWT_PANEL, 12, 493, 562, 40, 47, 0x0, STR_7064_TOGGLE_GRAPH_FOR_CARGO}, |
|
964 |
{ WWT_PANEL, 12, 493, 562, 48, 55, 0x0, STR_7064_TOGGLE_GRAPH_FOR_CARGO}, |
|
965 |
{ WWT_PANEL, 12, 493, 562, 56, 63, 0x0, STR_7064_TOGGLE_GRAPH_FOR_CARGO}, |
|
966 |
{ WWT_PANEL, 12, 493, 562, 64, 71, 0x0, STR_7064_TOGGLE_GRAPH_FOR_CARGO}, |
|
967 |
{ WWT_PANEL, 12, 493, 562, 72, 79, 0x0, STR_7064_TOGGLE_GRAPH_FOR_CARGO}, |
|
968 |
{ WWT_PANEL, 12, 493, 562, 80, 87, 0x0, STR_7064_TOGGLE_GRAPH_FOR_CARGO}, |
|
969 |
{ WWT_PANEL, 12, 493, 562, 88, 95, 0x0, STR_7064_TOGGLE_GRAPH_FOR_CARGO}, |
|
970 |
{ WWT_PANEL, 12, 493, 562, 96, 103, 0x0, STR_7064_TOGGLE_GRAPH_FOR_CARGO}, |
|
971 |
{ WWT_PANEL, 12, 493, 562, 104, 111, 0x0, STR_7064_TOGGLE_GRAPH_FOR_CARGO}, |
|
972 |
{ WWT_PANEL, 12, 493, 562, 112, 119, 0x0, STR_7064_TOGGLE_GRAPH_FOR_CARGO}, |
|
973 |
{ WWT_LAST}, |
|
974 |
}; |
|
975 |
||
976 |
static const WindowDesc _cargo_payment_rates_desc = { |
|
977 |
-1, -1, 568, 142, |
|
978 |
WC_PAYMENT_RATES,0, |
|
979 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
980 |
_cargo_payment_rates_widgets, |
|
981 |
CargoPaymentRatesWndProc |
|
982 |
}; |
|
983 |
||
984 |
||
985 |
void ShowCargoPaymentRates() |
|
986 |
{ |
|
987 |
AllocateWindowDescFront(&_cargo_payment_rates_desc, 0); |
|
988 |
} |
|
989 |
||
990 |
/************************/ |
|
991 |
/* COMPANY LEAGUE TABLE */ |
|
992 |
/************************/ |
|
993 |
||
994 |
static const StringID _performance_titles[] = { |
|
995 |
STR_7066_ENGINEER, |
|
996 |
STR_7066_ENGINEER, |
|
997 |
STR_7067_TRAFFIC_MANAGER, |
|
998 |
STR_7067_TRAFFIC_MANAGER, |
|
999 |
STR_7068_TRANSPORT_COORDINATOR, |
|
1000 |
STR_7068_TRANSPORT_COORDINATOR, |
|
1001 |
STR_7069_ROUTE_SUPERVISOR, |
|
1002 |
STR_7069_ROUTE_SUPERVISOR, |
|
1003 |
STR_706A_DIRECTOR, |
|
1004 |
STR_706A_DIRECTOR, |
|
1005 |
STR_706B_CHIEF_EXECUTIVE, |
|
1006 |
STR_706B_CHIEF_EXECUTIVE, |
|
1007 |
STR_706C_CHAIRMAN, |
|
1008 |
STR_706C_CHAIRMAN, |
|
1009 |
STR_706D_PRESIDENT, |
|
1010 |
STR_706E_TYCOON, |
|
1011 |
}; |
|
1012 |
||
1013 |
static StringID GetPerformanceTitleFromValue(uint v) |
|
1014 |
{ |
|
1015 |
return _performance_titles[minu(v, 1000) >> 6]; |
|
1016 |
} |
|
1017 |
||
1018 |
static int CDECL _perf_hist_comp(const void *elem1, const void *elem2 ) { |
|
1019 |
Player *p1 = *(Player**)elem1; |
|
1020 |
Player *p2 = *(Player**)elem2; |
|
1021 |
int32 v = p2->old_economy[1].performance_history - p1->old_economy[1].performance_history; |
|
1022 |
return (v!=0) | (v >> (sizeof(int32)*8-1)); |
|
1023 |
} |
|
1024 |
||
1025 |
static void CompanyLeagueWndProc(Window *w, WindowEvent *e) |
|
1026 |
{ |
|
1027 |
switch(e->event) { |
|
1028 |
case WE_PAINT: { |
|
1029 |
Player *p; |
|
1030 |
Player *plist[MAX_PLAYERS]; |
|
1031 |
size_t pl_num, i; |
|
1032 |
||
1033 |
DrawWindowWidgets(w); |
|
1034 |
||
1035 |
pl_num=0; |
|
1036 |
FOR_ALL_PLAYERS(p) { |
|
1037 |
if (p->is_active) |
|
1038 |
plist[pl_num++] = p; |
|
1039 |
} |
|
1040 |
assert(pl_num > 0); |
|
1041 |
||
1042 |
qsort(plist, pl_num, sizeof(Player*), _perf_hist_comp); |
|
1043 |
||
1044 |
i = 0; |
|
1045 |
do { |
|
1046 |
SET_DPARAM16(0, i + 1 + STR_01AB); |
|
1047 |
p = plist[i]; |
|
1048 |
SET_DPARAM16(1, p->name_1); |
|
1049 |
SET_DPARAM32(2, p->name_2); |
|
1050 |
||
2
104b2984cd3e
(svn r3) -[1005611] Player Window patch: When looking in dropdownlist for player stuff, it will say
darkvater
parents:
0
diff
changeset
|
1051 |
SET_DPARAM16(3, GetPlayerNameString(p->index, 4)); |
16
5ee72235b403
(svn r17) -Fix Player window fixes, Getstring id0 fixes, Finances window is now ok
darkvater
parents:
2
diff
changeset
|
1052 |
/* WARNING ugly hack! |
5ee72235b403
(svn r17) -Fix Player window fixes, Getstring id0 fixes, Finances window is now ok
darkvater
parents:
2
diff
changeset
|
1053 |
GetPlayerNameString sets up (Player #) if the player is human in an extra DPARAM16 |
5ee72235b403
(svn r17) -Fix Player window fixes, Getstring id0 fixes, Finances window is now ok
darkvater
parents:
2
diff
changeset
|
1054 |
It seems that if player is non-human, nothing is set up, so param is 0. GetString doesn't like |
5ee72235b403
(svn r17) -Fix Player window fixes, Getstring id0 fixes, Finances window is now ok
darkvater
parents:
2
diff
changeset
|
1055 |
that because there is another param after it. |
5ee72235b403
(svn r17) -Fix Player window fixes, Getstring id0 fixes, Finances window is now ok
darkvater
parents:
2
diff
changeset
|
1056 |
So we'll just shift the rating one back if player is AI and all is fine |
5ee72235b403
(svn r17) -Fix Player window fixes, Getstring id0 fixes, Finances window is now ok
darkvater
parents:
2
diff
changeset
|
1057 |
*/ |
57
8e7283026637
(svn r58) -Fix stupid bug in company league window if non-player is first
darkvater
parents:
16
diff
changeset
|
1058 |
SET_DPARAM16((IS_HUMAN_PLAYER(p->index) ? 5 : 4), GetPerformanceTitleFromValue(p->old_economy[1].performance_history)); |
0 | 1059 |
|
1060 |
DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, 0); |
|
1061 |
DrawPlayerIcon(p->index, 27, 16 + i * 10); |
|
1062 |
} while (++i != pl_num); |
|
1063 |
||
1064 |
break; |
|
1065 |
} |
|
1066 |
} |
|
1067 |
} |
|
1068 |
||
1069 |
||
1070 |
static const Widget _company_league_widgets[] = { |
|
1071 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
1072 |
{ WWT_CAPTION, 14, 11, 399, 0, 13, STR_7053_COMPANY_LEAGUE_TABLE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
1073 |
{ WWT_IMGBTN, 14, 0, 399, 14, 96, 0x0}, |
|
1074 |
{ WWT_LAST}, |
|
1075 |
}; |
|
1076 |
||
1077 |
static const WindowDesc _company_league_desc = { |
|
1078 |
-1, -1, 400, 97, |
|
1079 |
WC_COMPANY_LEAGUE,0, |
|
1080 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1081 |
_company_league_widgets, |
|
1082 |
CompanyLeagueWndProc |
|
1083 |
}; |
|
1084 |
||
1085 |
void ShowCompanyLeagueTable() |
|
1086 |
{ |
|
1087 |
AllocateWindowDescFront(&_company_league_desc,0); |
|
1088 |
} |