Mercurial > hg > openttd
annotate src/graph_gui.cpp @ 9289:c052caf473db draft
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 18 May 2008 09:39:40 +0000 (2008-05-18) |
parents | 72a6d2e60834 |
children | 8d0747f9b5af |
rev | line source |
---|---|
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2 |
9111
d48433370037
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents:
8409
diff
changeset
|
3 /** @file graph_gui.cpp GUI that shows performance graphs. */ |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6091
diff
changeset
|
4 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
5 #include "stdafx.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
6 #include "openttd.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
7 #include "gui.h" |
8107
f65cf2bc3255
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents:
8106
diff
changeset
|
8 #include "window_gui.h" |
8254
7d580c9c41fb
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents:
8224
diff
changeset
|
9 #include "player_base.h" |
7d580c9c41fb
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents:
8224
diff
changeset
|
10 #include "player_gui.h" |
8116
9cc845deddfe
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents:
8114
diff
changeset
|
11 #include "economy_func.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
12 #include "variables.h" |
6091
17ebeb5a2c37
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138 <peter1138@openttd.org>
parents:
5946
diff
changeset
|
13 #include "cargotype.h" |
8114
2d6af5d7a142
(svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
8107
diff
changeset
|
14 #include "strings_func.h" |
8130
0586823afe39
(svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium <rubidium@openttd.org>
parents:
8121
diff
changeset
|
15 #include "core/alloc_func.hpp" |
8131
e300ac8001ae
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents:
8130
diff
changeset
|
16 #include "window_func.h" |
8140
fb8a05d579da
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents:
8131
diff
changeset
|
17 #include "date_func.h" |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8179
diff
changeset
|
18 #include "gfx_func.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
19 |
8264
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
20 #include "table/strings.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
21 #include "table/sprites.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
22 |
5806
4f5e2ea123e8
(svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros <maedhros@openttd.org>
parents:
5805
diff
changeset
|
23 /* Bitmasks of player and cargo indices that shouldn't be drawn. */ |
4f5e2ea123e8
(svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros <maedhros@openttd.org>
parents:
5805
diff
changeset
|
24 static uint _legend_excluded_players; |
4f5e2ea123e8
(svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros <maedhros@openttd.org>
parents:
5805
diff
changeset
|
25 static uint _legend_excluded_cargo; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
26 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
27 /************************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
28 /* GENERIC GRAPH DRAWER */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
29 /************************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
30 |
5768
cb58a39476fd
(svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros <maedhros@openttd.org>
parents:
5766
diff
changeset
|
31 enum { |
6463
0315af802158
(svn r9638) -Feature: Increase cargo types from 12 to 32 and enable newcargo flag in NewGRF loader.
peter1138 <peter1138@openttd.org>
parents:
6372
diff
changeset
|
32 GRAPH_MAX_DATASETS = 32, |
7824
7ae5bda4e8dd
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents:
7763
diff
changeset
|
33 GRAPH_AXIS_LABEL_COLOUR = TC_BLACK, |
5768
cb58a39476fd
(svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros <maedhros@openttd.org>
parents:
5766
diff
changeset
|
34 GRAPH_AXIS_LINE_COLOUR = 215, |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
35 |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6091
diff
changeset
|
36 GRAPH_X_POSITION_BEGINNING = 44, ///< Start the graph 44 pixels from gw->left |
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6091
diff
changeset
|
37 GRAPH_X_POSITION_SEPARATION = 22, ///< There are 22 pixels between each X value |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
38 |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6091
diff
changeset
|
39 GRAPH_NUM_LINES_Y = 9, ///< How many horizontal lines to draw. |
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6091
diff
changeset
|
40 /* 9 is convenient as that means the distance between them is the height of the graph / 8, |
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6091
diff
changeset
|
41 * which is the same |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
42 * as height >> 3. */ |
5768
cb58a39476fd
(svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros <maedhros@openttd.org>
parents:
5766
diff
changeset
|
43 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
44 |
5805
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
45 /* Apparently these don't play well with enums. */ |
8409
7c5e4180e2b1
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
rubidium <rubidium@openttd.org>
parents:
8264
diff
changeset
|
46 static const OverflowSafeInt64 INVALID_DATAPOINT(INT64_MAX); // Value used for a datapoint that shouldn't be drawn. |
7763
b66a3cb83e69
(svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
rubidium <rubidium@openttd.org>
parents:
7520
diff
changeset
|
47 static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the previous point was drawn. |
5805
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
48 |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
49 struct GraphDrawer { |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6091
diff
changeset
|
50 uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
51 byte num_dataset; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
52 byte num_on_x_axis; |
5807
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
53 bool has_negative_values; |
5771
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
54 byte num_vert_lines; |
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
55 |
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
56 /* The starting month and year that values are plotted against. If month is |
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
57 * 0xFF, use x_values_start and x_values_increment below instead. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
58 byte month; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
59 Year year; |
5771
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
60 |
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
61 /* These values are used if the graph is being plotted against values |
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
62 * rather than the dates specified by month and year. */ |
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
63 uint16 x_values_start; |
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
64 uint16 x_values_increment; |
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
65 |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6091
diff
changeset
|
66 int left, top; ///< Where to start drawing the graph, in pixels. |
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6091
diff
changeset
|
67 uint height; ///< The height of the graph in pixels. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
68 StringID format_str_y_axis; |
5768
cb58a39476fd
(svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros <maedhros@openttd.org>
parents:
5766
diff
changeset
|
69 byte colors[GRAPH_MAX_DATASETS]; |
8000
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
70 OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
71 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
72 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
73 static void DrawGraph(const GraphDrawer *gw) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
74 { |
7763
b66a3cb83e69
(svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
rubidium <rubidium@openttd.org>
parents:
7520
diff
changeset
|
75 uint x, y; ///< Reused whenever x and y coordinates are needed. |
b66a3cb83e69
(svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
rubidium <rubidium@openttd.org>
parents:
7520
diff
changeset
|
76 OverflowSafeInt64 highest_value; ///< Highest value to be drawn. |
b66a3cb83e69
(svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
rubidium <rubidium@openttd.org>
parents:
7520
diff
changeset
|
77 int x_axis_offset; ///< Distance from the top of the graph to the x axis. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
78 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
79 /* the colors and cost array of GraphDrawer must accomodate |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
80 * both values for cargo and players. So if any are higher, quit */ |
5768
cb58a39476fd
(svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros <maedhros@openttd.org>
parents:
5766
diff
changeset
|
81 assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_PLAYERS); |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
82 assert(gw->num_vert_lines > 0); |
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
83 |
5766
9c7c1e291514
(svn r8317) -Codechange: Remove GraphDrawer::bg_line_color since it was the same everywhere it was set.
maedhros <maedhros@openttd.org>
parents:
5761
diff
changeset
|
84 byte grid_colour = _colour_gradient[14][4]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
85 |
5807
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
86 /* The coordinates of the opposite edges of the graph. */ |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
87 int bottom = gw->top + gw->height - 1; |
5807
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
88 int right = gw->left + GRAPH_X_POSITION_BEGINNING + gw->num_vert_lines * GRAPH_X_POSITION_SEPARATION - 1; |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
89 |
5807
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
90 /* Draw the vertical grid lines. */ |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
91 |
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
92 /* Don't draw the first line, as that's where the axis will be. */ |
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
93 x = gw->left + GRAPH_X_POSITION_BEGINNING + GRAPH_X_POSITION_SEPARATION; |
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
94 |
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
95 for (int i = 0; i < gw->num_vert_lines; i++) { |
5766
9c7c1e291514
(svn r8317) -Codechange: Remove GraphDrawer::bg_line_color since it was the same everywhere it was set.
maedhros <maedhros@openttd.org>
parents:
5761
diff
changeset
|
96 GfxFillRect(x, gw->top, x, bottom, grid_colour); |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
97 x += GRAPH_X_POSITION_SEPARATION; |
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
98 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
99 |
5807
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
100 /* Draw the horizontal grid lines. */ |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
101 x = gw->left + GRAPH_X_POSITION_BEGINNING; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
102 y = gw->height + gw->top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
103 |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
104 for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) { |
5766
9c7c1e291514
(svn r8317) -Codechange: Remove GraphDrawer::bg_line_color since it was the same everywhere it was set.
maedhros <maedhros@openttd.org>
parents:
5761
diff
changeset
|
105 GfxFillRect(x, y, right, y, grid_colour); |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
106 y -= (gw->height / (GRAPH_NUM_LINES_Y - 1)); |
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
107 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
108 |
5807
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
109 /* Draw the y axis. */ |
5768
cb58a39476fd
(svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros <maedhros@openttd.org>
parents:
5766
diff
changeset
|
110 GfxFillRect(x, gw->top, x, bottom, GRAPH_AXIS_LINE_COLOUR); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
111 |
5807
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
112 /* Find the distance from the top of the graph to the x axis. */ |
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
113 x_axis_offset = gw->height; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
114 |
5807
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
115 /* The graph is currently symmetrical about the x axis. */ |
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
116 if (gw->has_negative_values) x_axis_offset /= 2; |
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
117 |
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
118 /* Draw the x axis. */ |
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
119 y = x_axis_offset + gw->top; |
5768
cb58a39476fd
(svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros <maedhros@openttd.org>
parents:
5766
diff
changeset
|
120 GfxFillRect(x, y, right, y, GRAPH_AXIS_LINE_COLOUR); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
121 |
5807
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
122 /* Find the largest value that will be drawn. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
123 if (gw->num_on_x_axis == 0) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
124 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
125 |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
126 assert(gw->num_on_x_axis > 0); |
5778
f4886921514f
(svn r8330) -Codechange: Remove num_x and num_dataset from DrawGraph.
maedhros <maedhros@openttd.org>
parents:
5777
diff
changeset
|
127 assert(gw->num_dataset > 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
128 |
5804
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
129 /* Start of with a value of twice the height of the graph in pixels. It's a |
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
130 * bit arbitrary, but it makes the cargo payment graph look a little nicer, |
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
131 * and prevents division by zero when calculating where the datapoint |
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
132 * should be drawn. */ |
5807
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
133 highest_value = x_axis_offset * 2; |
5796
54b69ef4b352
(svn r8356) -Codechange: [Graphs] Rename mx to highest_value, and fix the scaling for negative values.
maedhros <maedhros@openttd.org>
parents:
5793
diff
changeset
|
134 |
5778
f4886921514f
(svn r8330) -Codechange: Remove num_x and num_dataset from DrawGraph.
maedhros <maedhros@openttd.org>
parents:
5777
diff
changeset
|
135 for (int i = 0; i < gw->num_dataset; i++) { |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
136 if (!HasBit(gw->excluded_data, i)) { |
5791
4fd992bac142
(svn r8347) -Codechange: [Graphs] Make some more variables local to the loops they're used in, and remove some assumptions about the size of an array.
maedhros <maedhros@openttd.org>
parents:
5778
diff
changeset
|
137 for (int j = 0; j < gw->num_on_x_axis; j++) { |
8000
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
138 OverflowSafeInt64 datapoint = gw->cost[i][j]; |
5791
4fd992bac142
(svn r8347) -Codechange: [Graphs] Make some more variables local to the loops they're used in, and remove some assumptions about the size of an array.
maedhros <maedhros@openttd.org>
parents:
5778
diff
changeset
|
139 |
5805
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
140 if (datapoint != INVALID_DATAPOINT) { |
5796
54b69ef4b352
(svn r8356) -Codechange: [Graphs] Rename mx to highest_value, and fix the scaling for negative values.
maedhros <maedhros@openttd.org>
parents:
5793
diff
changeset
|
141 /* For now, if the graph has negative values the scaling is |
54b69ef4b352
(svn r8356) -Codechange: [Graphs] Rename mx to highest_value, and fix the scaling for negative values.
maedhros <maedhros@openttd.org>
parents:
5793
diff
changeset
|
142 * symmetrical about the x axis, so take the absolute value |
54b69ef4b352
(svn r8356) -Codechange: [Graphs] Rename mx to highest_value, and fix the scaling for negative values.
maedhros <maedhros@openttd.org>
parents:
5793
diff
changeset
|
143 * of each data point. */ |
7923
504d4b2ecc6c
(svn r11476) -Codechange: rename the function myabs to abs to get rid of an unneeded define
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
144 highest_value = max(highest_value, abs(datapoint)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
145 } |
5778
f4886921514f
(svn r8330) -Codechange: Remove num_x and num_dataset from DrawGraph.
maedhros <maedhros@openttd.org>
parents:
5777
diff
changeset
|
146 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
147 } |
5778
f4886921514f
(svn r8330) -Codechange: Remove num_x and num_dataset from DrawGraph.
maedhros <maedhros@openttd.org>
parents:
5777
diff
changeset
|
148 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
149 |
5804
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
150 /* Round up highest_value so that it will divide cleanly into the number of |
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
151 * axis labels used. */ |
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
152 int round_val = highest_value % (GRAPH_NUM_LINES_Y - 1); |
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
153 if (round_val != 0) highest_value += (GRAPH_NUM_LINES_Y - 1 - round_val); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
154 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
155 /* draw text strings on the y axis */ |
5804
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
156 int64 y_label = highest_value; |
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
157 int64 y_label_separation = highest_value / (GRAPH_NUM_LINES_Y - 1); |
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
158 |
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
159 /* If there are negative values, the graph goes from highest_value to |
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
160 * -highest_value, not highest_value to 0. */ |
5807
1fc48d5f47d5
(svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros <maedhros@openttd.org>
parents:
5806
diff
changeset
|
161 if (gw->has_negative_values) y_label_separation *= 2; |
5804
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
162 |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
163 x = gw->left + GRAPH_X_POSITION_BEGINNING + 1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
164 y = gw->top - 3; |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
165 |
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
166 for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
167 SetDParam(0, gw->format_str_y_axis); |
7002
fa75522e0249
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents:
6991
diff
changeset
|
168 SetDParam(1, y_label); |
5768
cb58a39476fd
(svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros <maedhros@openttd.org>
parents:
5766
diff
changeset
|
169 DrawStringRightAligned(x, y, STR_0170, GRAPH_AXIS_LABEL_COLOUR); |
5804
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
170 |
07c4b670fcda
(svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros <maedhros@openttd.org>
parents:
5796
diff
changeset
|
171 y_label -= y_label_separation; |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
172 y += (gw->height / (GRAPH_NUM_LINES_Y - 1)); |
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
173 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
174 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
175 /* draw strings on the x axis */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
176 if (gw->month != 0xFF) { |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
177 x = gw->left + GRAPH_X_POSITION_BEGINNING; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
178 y = gw->top + gw->height + 1; |
5777
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
179 byte month = gw->month; |
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
180 Year year = gw->year; |
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
181 for (int i = 0; i < gw->num_on_x_axis; i++) { |
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
182 SetDParam(0, month + STR_0162_JAN); |
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
183 SetDParam(1, month + STR_0162_JAN + 2); |
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
184 SetDParam(2, year); |
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
185 DrawString(x, y, month == 0 ? STR_016F : STR_016E, GRAPH_AXIS_LABEL_COLOUR); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
186 |
5777
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
187 month += 3; |
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
188 if (month >= 12) { |
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
189 month = 0; |
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
190 year++; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
191 } |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
192 x += GRAPH_X_POSITION_SEPARATION; |
5777
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
193 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
194 } else { |
5793
50846c721bda
(svn r8350) -Codechange: [Graphs] Use DrawStringCentered instead of a hardcoded offset to make the string appear centred.
maedhros <maedhros@openttd.org>
parents:
5791
diff
changeset
|
195 /* Draw the label under the data point rather than on the grid line. */ |
50846c721bda
(svn r8350) -Codechange: [Graphs] Use DrawStringCentered instead of a hardcoded offset to make the string appear centred.
maedhros <maedhros@openttd.org>
parents:
5791
diff
changeset
|
196 x = gw->left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2) + 1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
197 y = gw->top + gw->height + 1; |
5771
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
198 uint16 label = gw->x_values_start; |
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
199 |
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
200 for (int i = 0; i < gw->num_on_x_axis; i++) { |
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
201 SetDParam(0, label); |
5793
50846c721bda
(svn r8350) -Codechange: [Graphs] Use DrawStringCentered instead of a hardcoded offset to make the string appear centred.
maedhros <maedhros@openttd.org>
parents:
5791
diff
changeset
|
202 DrawStringCentered(x, y, STR_01CB, GRAPH_AXIS_LABEL_COLOUR); |
50846c721bda
(svn r8350) -Codechange: [Graphs] Use DrawStringCentered instead of a hardcoded offset to make the string appear centred.
maedhros <maedhros@openttd.org>
parents:
5791
diff
changeset
|
203 |
5771
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
204 label += gw->x_values_increment; |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
205 x += GRAPH_X_POSITION_SEPARATION; |
5771
ee8916154ac7
(svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros <maedhros@openttd.org>
parents:
5768
diff
changeset
|
206 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
207 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
208 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
209 /* draw lines and dots */ |
5777
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
210 for (int i = 0; i < gw->num_dataset; i++) { |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
211 if (!HasBit(gw->excluded_data, i)) { |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
212 /* Centre the dot between the grid lines. */ |
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
213 x = gw->left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2); |
5791
4fd992bac142
(svn r8347) -Codechange: [Graphs] Make some more variables local to the loops they're used in, and remove some assumptions about the size of an array.
maedhros <maedhros@openttd.org>
parents:
5778
diff
changeset
|
214 |
5805
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
215 byte color = gw->colors[i]; |
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
216 uint prev_x = INVALID_DATAPOINT_POS; |
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
217 uint prev_y = INVALID_DATAPOINT_POS; |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
218 |
5791
4fd992bac142
(svn r8347) -Codechange: [Graphs] Make some more variables local to the loops they're used in, and remove some assumptions about the size of an array.
maedhros <maedhros@openttd.org>
parents:
5778
diff
changeset
|
219 for (int j = 0; j < gw->num_on_x_axis; j++) { |
8000
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
220 OverflowSafeInt64 datapoint = gw->cost[i][j]; |
5791
4fd992bac142
(svn r8347) -Codechange: [Graphs] Make some more variables local to the loops they're used in, and remove some assumptions about the size of an array.
maedhros <maedhros@openttd.org>
parents:
5778
diff
changeset
|
221 |
5805
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
222 if (datapoint != INVALID_DATAPOINT) { |
8000
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
223 /* |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
224 * Check whether we need to reduce the 'accuracy' of the |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
225 * datapoint value and the highest value to splut overflows. |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
226 * And when 'drawing' 'one million' or 'one million and one' |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
227 * there is no significant difference, so the least |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
228 * significant bits can just be removed. |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
229 * |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
230 * If there are more bits needed than would fit in a 32 bits |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
231 * integer, so at about 31 bits because of the sign bit, the |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
232 * least significant bits are removed. |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
233 */ |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
234 int mult_range = FindLastBit(x_axis_offset) + FindLastBit(abs(datapoint)); |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
235 int reduce_range = max(mult_range - 31, 0); |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
236 |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
237 /* Handle negative values differently (don't shift sign) */ |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
238 if (datapoint < 0) { |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
239 datapoint = -(abs(datapoint) >> reduce_range); |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
240 } else { |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
241 datapoint >>= reduce_range; |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
242 } |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
243 |
e7e6c96913eb
(svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values.
rubidium <rubidium@openttd.org>
parents:
7997
diff
changeset
|
244 y = gw->top + x_axis_offset - (x_axis_offset * datapoint) / (highest_value >> reduce_range); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
245 |
5805
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
246 /* Draw the point. */ |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6463
diff
changeset
|
247 GfxFillRect(x - 1, y - 1, x + 1, y + 1, color); |
5805
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
248 |
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
249 /* Draw the line connected to the previous point. */ |
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
250 if (prev_x != INVALID_DATAPOINT_POS) GfxDrawLine(prev_x, prev_y, x, y, color); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
251 |
5805
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
252 prev_x = x; |
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
253 prev_y = y; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
254 } else { |
5805
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
255 prev_x = INVALID_DATAPOINT_POS; |
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
256 prev_y = INVALID_DATAPOINT_POS; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
257 } |
5805
b7c3a94ff74e
(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 <maedhros@openttd.org>
parents:
5804
diff
changeset
|
258 |
5776
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
259 x += GRAPH_X_POSITION_SEPARATION; |
b820f9df1f2d
(svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros <maedhros@openttd.org>
parents:
5771
diff
changeset
|
260 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
261 } |
5777
d889b4c8d326
(svn r8329) -Codechange: Remove the the horribly abused j and k variables completely, and make i local to each loop it's used in.
maedhros <maedhros@openttd.org>
parents:
5776
diff
changeset
|
262 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
263 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
264 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
265 /****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
266 /* GRAPH LEGEND */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
267 /****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
268 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
269 struct GraphLegendWindow : Window { |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
270 GraphLegendWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
271 { |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
272 for (uint i = 3; i < this->widget_count; i++) { |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
273 if (!HasBit(_legend_excluded_players, i - 3)) this->LowerWidget(i); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
274 } |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
275 } |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
276 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
277 virtual void OnPaint() |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
278 { |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
279 const Player *p; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
280 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
281 FOR_ALL_PLAYERS(p) { |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
282 if (p->is_active) continue; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
283 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
284 SetBit(_legend_excluded_players, p->index); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
285 this->RaiseWidget(p->index + 3); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
286 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
287 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
288 this->DrawWidgets(); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
289 |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
290 FOR_ALL_PLAYERS(p) { |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
291 if (!p->is_active) continue; |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
292 |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
293 DrawPlayerIcon(p->index, 4, 18 + p->index * 12); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
294 |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
295 SetDParam(0, p->index); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
296 SetDParam(1, p->index); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
297 DrawString(21, 17 + p->index * 12, STR_7021, HasBit(_legend_excluded_players, p->index) ? TC_BLACK : TC_WHITE); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
298 } |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
299 } |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
300 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
301 virtual void OnClick(Point pt, int widget) |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
302 { |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
303 if (!IsInsideMM(widget, 3, 11)) return; |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
304 |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
305 ToggleBit(_legend_excluded_players, widget - 3); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
306 this->ToggleWidgetLoweredState(widget); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
307 this->SetDirty(); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
308 InvalidateWindow(WC_INCOME_GRAPH, 0); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
309 InvalidateWindow(WC_OPERATING_PROFIT, 0); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
310 InvalidateWindow(WC_DELIVERED_CARGO, 0); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
311 InvalidateWindow(WC_PERFORMANCE_HISTORY, 0); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
312 InvalidateWindow(WC_COMPANY_VALUE, 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
313 } |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
314 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
315 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
316 static const Widget _graph_legend_widgets[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
317 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
318 { WWT_CAPTION, RESIZE_NONE, 14, 11, 249, 0, 13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
319 { WWT_PANEL, RESIZE_NONE, 14, 0, 249, 14, 113, 0x0, STR_NULL}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
320 { WWT_PANEL, RESIZE_NONE, 14, 2, 247, 16, 27, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
321 { WWT_PANEL, RESIZE_NONE, 14, 2, 247, 28, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
322 { WWT_PANEL, RESIZE_NONE, 14, 2, 247, 40, 51, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
323 { WWT_PANEL, RESIZE_NONE, 14, 2, 247, 52, 63, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
324 { WWT_PANEL, RESIZE_NONE, 14, 2, 247, 64, 75, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
325 { WWT_PANEL, RESIZE_NONE, 14, 2, 247, 76, 87, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
326 { WWT_PANEL, RESIZE_NONE, 14, 2, 247, 88, 99, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
327 { WWT_PANEL, RESIZE_NONE, 14, 2, 247, 100, 111, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
328 { WIDGETS_END}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
329 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
330 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
331 static const WindowDesc _graph_legend_desc = { |
7341
549c757023fc
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents:
7266
diff
changeset
|
332 WDP_AUTO, WDP_AUTO, 250, 114, 250, 114, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
333 WC_GRAPH_LEGEND, WC_NONE, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
334 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
335 _graph_legend_widgets, |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
336 NULL |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
337 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
338 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
339 static void ShowGraphLegend() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
340 { |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
341 AllocateWindowDescFront<GraphLegendWindow>(&_graph_legend_desc, 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
342 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
343 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
344 /********************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
345 /* OPERATING PROFIT */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
346 /********************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
347 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
348 static void SetupGraphDrawerForPlayers(GraphDrawer *gd) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
349 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
350 const Player* p; |
5806
4f5e2ea123e8
(svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros <maedhros@openttd.org>
parents:
5805
diff
changeset
|
351 uint excluded_players = _legend_excluded_players; |
5601
ca6b459bf488
(svn r8055) -Codechange: Replace the different max, dmax, maxu whatever macros by a simple template function max(), that requires two arguments of the same type. While I'm at it change a variable called "max" to "maxval" in a function that calls max().
celestar <celestar@openttd.org>
parents:
5587
diff
changeset
|
352 byte nums; |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6463
diff
changeset
|
353 int mo, yr; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
354 |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6091
diff
changeset
|
355 /* Exclude the players which aren't valid */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
356 FOR_ALL_PLAYERS(p) { |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
357 if (!p->is_active) SetBit(excluded_players, p->index); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
358 } |
5806
4f5e2ea123e8
(svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros <maedhros@openttd.org>
parents:
5805
diff
changeset
|
359 gd->excluded_data = excluded_players; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
360 gd->num_vert_lines = 24; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
361 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
362 nums = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
363 FOR_ALL_PLAYERS(p) { |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
364 if (p->is_active) nums = max(nums, p->num_valid_stat_ent); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
365 } |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
366 gd->num_on_x_axis = min(nums, 24); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
367 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
368 mo = (_cur_month / 3 - nums) * 3; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
369 yr = _cur_year; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
370 while (mo < 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
371 yr--; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
372 mo += 12; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
373 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
374 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
375 gd->year = yr; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
376 gd->month = mo; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
377 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
378 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
379 static void OperatingProfitWndProc(Window *w, WindowEvent *e) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
380 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
381 switch (e->event) { |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
382 case WE_PAINT: { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
383 GraphDrawer gd; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
384 const Player* p; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
385 |
9273
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9255
diff
changeset
|
386 w->DrawWidgets(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
387 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
388 gd.left = 2; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
389 gd.top = 18; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
390 gd.height = 136; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
391 gd.has_negative_values = true; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
392 gd.format_str_y_axis = STR_CURRCOMPACT; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
393 |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
394 SetupGraphDrawerForPlayers(&gd); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
395 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
396 int numd = 0; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
397 FOR_ALL_PLAYERS(p) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
398 if (p->is_active) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
399 gd.colors[numd] = _colour_gradient[p->player_color][6]; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
400 for (int j = gd.num_on_x_axis, i = 0; --j >= 0;) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
401 gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : (p->old_economy[j].income + p->old_economy[j].expenses); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
402 i++; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
403 } |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
404 } |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
405 numd++; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
406 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
407 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
408 gd.num_dataset = numd; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
409 |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
410 DrawGraph(&gd); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
411 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
412 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
413 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
414 case WE_CLICK: |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
415 /* Clicked on legend? */ |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
416 if (e->we.click.widget == 2) ShowGraphLegend(); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
417 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
418 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
419 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
420 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
421 static const Widget _operating_profit_widgets[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
422 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
423 { WWT_CAPTION, RESIZE_NONE, 14, 11, 525, 0, 13, STR_7025_OPERATING_PROFIT_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
424 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
425 { WWT_PANEL, RESIZE_NONE, 14, 0, 575, 14, 173, 0x0, STR_NULL}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
426 { WIDGETS_END}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
427 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
428 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
429 static const WindowDesc _operating_profit_desc = { |
7341
549c757023fc
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents:
7266
diff
changeset
|
430 WDP_AUTO, WDP_AUTO, 576, 174, 576, 174, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
431 WC_OPERATING_PROFIT, WC_NONE, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
432 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
433 _operating_profit_widgets, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
434 OperatingProfitWndProc |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
435 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
436 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
437 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
438 void ShowOperatingProfitGraph() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
439 { |
9143
00b40c2158ff
(svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
rubidium <rubidium@openttd.org>
parents:
9116
diff
changeset
|
440 if (AllocateWindowDescFront<Window>(&_operating_profit_desc, 0)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
441 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
442 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
443 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
444 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
445 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
446 /****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
447 /* INCOME GRAPH */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
448 /****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
449 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
450 static void IncomeGraphWndProc(Window *w, WindowEvent *e) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
451 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
452 switch (e->event) { |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
453 case WE_PAINT: { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
454 GraphDrawer gd; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
455 const Player* p; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
456 |
9273
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9255
diff
changeset
|
457 w->DrawWidgets(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
458 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
459 gd.left = 2; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
460 gd.top = 18; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
461 gd.height = 104; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
462 gd.has_negative_values = false; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
463 gd.format_str_y_axis = STR_CURRCOMPACT; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
464 SetupGraphDrawerForPlayers(&gd); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
465 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
466 int numd = 0; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
467 FOR_ALL_PLAYERS(p) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
468 if (p->is_active) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
469 gd.colors[numd] = _colour_gradient[p->player_color][6]; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
470 for (int j = gd.num_on_x_axis, i = 0; --j >= 0;) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
471 gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].income; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
472 i++; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
473 } |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
474 } |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
475 numd++; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
476 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
477 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
478 gd.num_dataset = numd; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
479 |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
480 DrawGraph(&gd); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
481 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
482 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
483 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
484 case WE_CLICK: |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
485 if (e->we.click.widget == 2) ShowGraphLegend(); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
486 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
487 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
488 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
489 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
490 static const Widget _income_graph_widgets[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
491 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
492 { WWT_CAPTION, RESIZE_NONE, 14, 11, 525, 0, 13, STR_7022_INCOME_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
493 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
494 { WWT_PANEL, RESIZE_NONE, 14, 0, 575, 14, 141, 0x0, STR_NULL}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
495 { WIDGETS_END}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
496 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
497 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
498 static const WindowDesc _income_graph_desc = { |
7341
549c757023fc
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents:
7266
diff
changeset
|
499 WDP_AUTO, WDP_AUTO, 576, 142, 576, 142, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
500 WC_INCOME_GRAPH, WC_NONE, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
501 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
502 _income_graph_widgets, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
503 IncomeGraphWndProc |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
504 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
505 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
506 void ShowIncomeGraph() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
507 { |
9143
00b40c2158ff
(svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
rubidium <rubidium@openttd.org>
parents:
9116
diff
changeset
|
508 if (AllocateWindowDescFront<Window>(&_income_graph_desc, 0)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
509 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
510 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
511 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
512 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
513 /*******************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
514 /* DELIVERED CARGO */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
515 /*******************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
516 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
517 static void DeliveredCargoGraphWndProc(Window *w, WindowEvent *e) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
518 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
519 switch (e->event) { |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
520 case WE_PAINT: { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
521 GraphDrawer gd; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
522 const Player* p; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
523 |
9273
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9255
diff
changeset
|
524 w->DrawWidgets(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
525 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
526 gd.left = 2; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
527 gd.top = 18; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
528 gd.height = 104; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
529 gd.has_negative_values = false; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
530 gd.format_str_y_axis = STR_7024; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
531 SetupGraphDrawerForPlayers(&gd); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
532 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
533 int numd = 0; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
534 FOR_ALL_PLAYERS(p) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
535 if (p->is_active) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
536 gd.colors[numd] = _colour_gradient[p->player_color][6]; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
537 for (int j = gd.num_on_x_axis, i = 0; --j >= 0;) { |
7763
b66a3cb83e69
(svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
rubidium <rubidium@openttd.org>
parents:
7520
diff
changeset
|
538 gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : (OverflowSafeInt64)p->old_economy[j].delivered_cargo; |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
539 i++; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
540 } |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
541 } |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
542 numd++; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
543 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
544 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
545 gd.num_dataset = numd; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
546 |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
547 DrawGraph(&gd); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
548 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
549 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
550 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
551 case WE_CLICK: |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
552 if (e->we.click.widget == 2) ShowGraphLegend(); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
553 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
554 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
555 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
556 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
557 static const Widget _delivered_cargo_graph_widgets[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
558 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
559 { WWT_CAPTION, RESIZE_NONE, 14, 11, 525, 0, 13, STR_7050_UNITS_OF_CARGO_DELIVERED, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
560 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
561 { WWT_PANEL, RESIZE_NONE, 14, 0, 575, 14, 141, 0x0, STR_NULL}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
562 { WIDGETS_END}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
563 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
564 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
565 static const WindowDesc _delivered_cargo_graph_desc = { |
7341
549c757023fc
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents:
7266
diff
changeset
|
566 WDP_AUTO, WDP_AUTO, 576, 142, 576, 142, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
567 WC_DELIVERED_CARGO, WC_NONE, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
568 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
569 _delivered_cargo_graph_widgets, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
570 DeliveredCargoGraphWndProc |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
571 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
572 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
573 void ShowDeliveredCargoGraph() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
574 { |
9143
00b40c2158ff
(svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
rubidium <rubidium@openttd.org>
parents:
9116
diff
changeset
|
575 if (AllocateWindowDescFront<Window>(&_delivered_cargo_graph_desc, 0)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
576 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
577 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
578 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
579 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
580 /***********************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
581 /* PERFORMANCE HISTORY */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
582 /***********************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
583 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
584 static void PerformanceHistoryWndProc(Window *w, WindowEvent *e) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
585 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
586 switch (e->event) { |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
587 case WE_PAINT: { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
588 GraphDrawer gd; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
589 const Player* p; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
590 |
9273
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9255
diff
changeset
|
591 w->DrawWidgets(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
592 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
593 gd.left = 2; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
594 gd.top = 18; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
595 gd.height = 200; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
596 gd.has_negative_values = false; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
597 gd.format_str_y_axis = STR_7024; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
598 SetupGraphDrawerForPlayers(&gd); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
599 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
600 int numd = 0; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
601 FOR_ALL_PLAYERS(p) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
602 if (p->is_active) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
603 gd.colors[numd] = _colour_gradient[p->player_color][6]; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
604 for (int j = gd.num_on_x_axis, i = 0; --j >= 0;) { |
7763
b66a3cb83e69
(svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
rubidium <rubidium@openttd.org>
parents:
7520
diff
changeset
|
605 gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : (OverflowSafeInt64)p->old_economy[j].performance_history; |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
606 i++; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
607 } |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
608 } |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
609 numd++; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
610 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
611 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
612 gd.num_dataset = numd; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
613 |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
614 DrawGraph(&gd); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
615 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
616 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
617 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
618 case WE_CLICK: |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
619 if (e->we.click.widget == 2) ShowGraphLegend(); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
620 if (e->we.click.widget == 3) ShowPerformanceRatingDetail(); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
621 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
622 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
623 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
624 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
625 static const Widget _performance_history_widgets[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
626 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
627 { WWT_CAPTION, RESIZE_NONE, 14, 11, 475, 0, 13, STR_7051_COMPANY_PERFORMANCE_RATINGS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
628 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
629 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 476, 525, 0, 13, STR_PERFORMANCE_DETAIL_KEY, STR_704D_SHOW_KEY_TO_GRAPHS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
630 { WWT_PANEL, RESIZE_NONE, 14, 0, 575, 14, 237, 0x0, STR_NULL}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
631 { WIDGETS_END}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
632 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
633 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
634 static const WindowDesc _performance_history_desc = { |
7341
549c757023fc
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents:
7266
diff
changeset
|
635 WDP_AUTO, WDP_AUTO, 576, 238, 576, 238, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
636 WC_PERFORMANCE_HISTORY, WC_NONE, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
637 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
638 _performance_history_widgets, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
639 PerformanceHistoryWndProc |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
640 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
641 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
642 void ShowPerformanceHistoryGraph() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
643 { |
9143
00b40c2158ff
(svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
rubidium <rubidium@openttd.org>
parents:
9116
diff
changeset
|
644 if (AllocateWindowDescFront<Window>(&_performance_history_desc, 0)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
645 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
646 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
647 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
648 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
649 /*****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
650 /* COMPANY VALUE */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
651 /*****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
652 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
653 static void CompanyValueGraphWndProc(Window *w, WindowEvent *e) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
654 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
655 switch (e->event) { |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
656 case WE_PAINT: { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
657 GraphDrawer gd; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
658 const Player* p; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
659 |
9273
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9255
diff
changeset
|
660 w->DrawWidgets(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
661 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
662 gd.left = 2; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
663 gd.top = 18; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
664 gd.height = 200; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
665 gd.has_negative_values = false; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
666 gd.format_str_y_axis = STR_CURRCOMPACT; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
667 SetupGraphDrawerForPlayers(&gd); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
668 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
669 int numd = 0; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
670 FOR_ALL_PLAYERS(p) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
671 if (p->is_active) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
672 gd.colors[numd] = _colour_gradient[p->player_color][6]; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
673 for (int j = gd.num_on_x_axis, i = 0; --j >= 0;) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
674 gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].company_value; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
675 i++; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
676 } |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
677 } |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
678 numd++; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
679 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
680 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
681 gd.num_dataset = numd; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
682 |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
683 DrawGraph(&gd); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
684 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
685 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
686 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
687 case WE_CLICK: |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
688 if (e->we.click.widget == 2) ShowGraphLegend(); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
689 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
690 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
691 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
692 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
693 static const Widget _company_value_graph_widgets[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
694 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
695 { WWT_CAPTION, RESIZE_NONE, 14, 11, 525, 0, 13, STR_7052_COMPANY_VALUES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
696 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
697 { WWT_PANEL, RESIZE_NONE, 14, 0, 575, 14, 237, 0x0, STR_NULL}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
698 { WIDGETS_END}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
699 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
700 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
701 static const WindowDesc _company_value_graph_desc = { |
7341
549c757023fc
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents:
7266
diff
changeset
|
702 WDP_AUTO, WDP_AUTO, 576, 238, 576, 238, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
703 WC_COMPANY_VALUE, WC_NONE, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
704 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
705 _company_value_graph_widgets, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
706 CompanyValueGraphWndProc |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
707 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
708 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
709 void ShowCompanyValueGraph() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
710 { |
9143
00b40c2158ff
(svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
rubidium <rubidium@openttd.org>
parents:
9116
diff
changeset
|
711 if (AllocateWindowDescFront<Window>(&_company_value_graph_desc, 0)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
712 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
713 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
714 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
715 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
716 /*****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
717 /* PAYMENT RATES */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
718 /*****************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
719 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
720 static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
721 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
722 switch (e->event) { |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
723 case WE_PAINT: { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
724 GraphDrawer gd; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
725 |
9273
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9255
diff
changeset
|
726 w->DrawWidgets(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
727 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
728 int x = 495; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
729 int y = 24; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
730 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
731 gd.excluded_data = _legend_excluded_cargo; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
732 gd.left = 2; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
733 gd.top = 24; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
734 gd.height = w->height - 38; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
735 gd.has_negative_values = false; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
736 gd.format_str_y_axis = STR_CURRCOMPACT; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
737 gd.num_on_x_axis = 20; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
738 gd.num_vert_lines = 20; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
739 gd.month = 0xFF; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
740 gd.x_values_start = 10; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
741 gd.x_values_increment = 10; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
742 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
743 uint i = 0; |
6350
8132258640be
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents:
6270
diff
changeset
|
744 for (CargoID c = 0; c < NUM_CARGO; c++) { |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
745 const CargoSpec *cs = GetCargo(c); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
746 if (!cs->IsValid()) continue; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
747 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
748 /* Only draw labels for widgets that exist. If the widget doesn't |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
749 * exist then the local player has used the climate cheat or |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
750 * changed the NewGRF configuration with this window open. */ |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
751 if (i + 3 < w->widget_count) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
752 /* Since the buttons have no text, no images, |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
753 * both the text and the colored box have to be manually painted. |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
754 * clk_dif will move one pixel down and one pixel to the right |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
755 * when the button is clicked */ |
7997
d109780d515b
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents:
7954
diff
changeset
|
756 byte clk_dif = w->IsWidgetLowered(i + 3) ? 1 : 0; |
6192
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
757 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
758 GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
759 GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
760 SetDParam(0, cs->name); |
7824
7ae5bda4e8dd
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents:
7763
diff
changeset
|
761 DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, TC_FROMSTRING); |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
762 y += 8; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
763 } |
6192
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
764 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
765 gd.colors[i] = cs->legend_colour; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
766 for (uint j = 0; j != 20; j++) { |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
767 gd.cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 6 + 6, c); |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
768 } |
6192
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
769 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
770 i++; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
771 } |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
772 gd.num_dataset = i; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
773 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
774 DrawGraph(&gd); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
775 |
7824
7ae5bda4e8dd
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents:
7763
diff
changeset
|
776 DrawString(2 + 46, 24 + gd.height + 7, STR_7062_DAYS_IN_TRANSIT, TC_FROMSTRING); |
7ae5bda4e8dd
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents:
7763
diff
changeset
|
777 DrawString(2 + 84, 24 - 9, STR_7063_PAYMENT_FOR_DELIVERING, TC_FROMSTRING); |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
778 break; |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
779 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
780 |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
781 case WE_CLICK: |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
782 if (e->we.click.widget >= 3) { |
7932
712f252f0d4d
(svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7931
diff
changeset
|
783 ToggleBit(_legend_excluded_cargo, e->we.click.widget - 3); |
7997
d109780d515b
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents:
7954
diff
changeset
|
784 w->ToggleWidgetLoweredState(e->we.click.widget); |
9116
44beb31166aa
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium <rubidium@openttd.org>
parents:
9111
diff
changeset
|
785 w->SetDirty(); |
6203
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
786 } |
60d5fce9d6b0
(svn r8989) -Fix: more indenting and variable scoping
peter1138 <peter1138@openttd.org>
parents:
6192
diff
changeset
|
787 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
788 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
789 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
790 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
791 static const Widget _cargo_payment_rates_widgets[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
792 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
793 { WWT_CAPTION, RESIZE_NONE, 14, 11, 567, 0, 13, STR_7061_CARGO_PAYMENT_RATES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
6192
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
794 { WWT_PANEL, RESIZE_BOTTOM, 14, 0, 567, 14, 45, 0x0, STR_NULL}, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
795 { WIDGETS_END}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
796 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
797 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
798 static const WindowDesc _cargo_payment_rates_desc = { |
7341
549c757023fc
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents:
7266
diff
changeset
|
799 WDP_AUTO, WDP_AUTO, 568, 46, 568, 46, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
800 WC_PAYMENT_RATES, WC_NONE, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
801 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
802 _cargo_payment_rates_widgets, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
803 CargoPaymentRatesWndProc |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
804 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
805 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
806 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
807 void ShowCargoPaymentRates() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
808 { |
9143
00b40c2158ff
(svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
rubidium <rubidium@openttd.org>
parents:
9116
diff
changeset
|
809 Window *w = AllocateWindowDescFront<Window>(&_cargo_payment_rates_desc, 0); |
6192
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
810 if (w == NULL) return; |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
811 |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
812 /* Count the number of active cargo types */ |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
813 uint num_active = 0; |
6350
8132258640be
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents:
6270
diff
changeset
|
814 for (CargoID c = 0; c < NUM_CARGO; c++) { |
6192
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
815 if (GetCargo(c)->IsValid()) num_active++; |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
816 } |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
817 |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
818 /* Resize the window to fit the cargo types */ |
6372
b530477bd247
(svn r9435) -Fix (r8972): ensure the cargo payment graph is at least 12 "items" high
peter1138 <peter1138@openttd.org>
parents:
6350
diff
changeset
|
819 ResizeWindow(w, 0, max(num_active, 12U) * 8); |
6192
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
820 |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
821 /* Add widgets for each cargo type */ |
6270
60de27078397
(svn r9079) -Codechange: add WWT_LAST widget when dynamically building cargo payment graph
peter1138 <peter1138@openttd.org>
parents:
6248
diff
changeset
|
822 w->widget_count += num_active; |
60de27078397
(svn r9079) -Codechange: add WWT_LAST widget when dynamically building cargo payment graph
peter1138 <peter1138@openttd.org>
parents:
6248
diff
changeset
|
823 w->widget = ReallocT(w->widget, w->widget_count + 1); |
60de27078397
(svn r9079) -Codechange: add WWT_LAST widget when dynamically building cargo payment graph
peter1138 <peter1138@openttd.org>
parents:
6248
diff
changeset
|
824 w->widget[w->widget_count].type = WWT_LAST; |
6192
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
825 |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
826 /* Set the properties of each widget */ |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
827 for (uint i = 0; i != num_active; i++) { |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
828 Widget *wi = &w->widget[3 + i]; |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
829 wi->type = WWT_PANEL; |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
830 wi->display_flags = RESIZE_NONE; |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
831 wi->color = 12; |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
832 wi->left = 493; |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
833 wi->right = 562; |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
834 wi->top = 24 + i * 8; |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
835 wi->bottom = wi->top + 7; |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
836 wi->data = 0; |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
837 wi->tooltips = STR_7064_TOGGLE_GRAPH_FOR_CARGO; |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
838 |
7997
d109780d515b
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents:
7954
diff
changeset
|
839 if (!HasBit(_legend_excluded_cargo, i)) w->LowerWidget(i + 3); |
6192
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
840 } |
44da08e7d3d1
(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 <peter1138@openttd.org>
parents:
6179
diff
changeset
|
841 |
9116
44beb31166aa
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium <rubidium@openttd.org>
parents:
9111
diff
changeset
|
842 w->SetDirty(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
843 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
844 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
845 /************************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
846 /* COMPANY LEAGUE TABLE */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
847 /************************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
848 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
849 static const StringID _performance_titles[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
850 STR_7066_ENGINEER, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
851 STR_7066_ENGINEER, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
852 STR_7067_TRAFFIC_MANAGER, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
853 STR_7067_TRAFFIC_MANAGER, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
854 STR_7068_TRANSPORT_COORDINATOR, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
855 STR_7068_TRANSPORT_COORDINATOR, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
856 STR_7069_ROUTE_SUPERVISOR, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
857 STR_7069_ROUTE_SUPERVISOR, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
858 STR_706A_DIRECTOR, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
859 STR_706A_DIRECTOR, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
860 STR_706B_CHIEF_EXECUTIVE, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
861 STR_706B_CHIEF_EXECUTIVE, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
862 STR_706C_CHAIRMAN, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
863 STR_706C_CHAIRMAN, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
864 STR_706D_PRESIDENT, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
865 STR_706E_TYCOON, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
866 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
867 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
868 static inline StringID GetPerformanceTitleFromValue(uint value) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
869 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
870 return _performance_titles[minu(value, 1000) >> 6]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
871 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
872 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
873 static int CDECL PerfHistComp(const void* elem1, const void* elem2) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
874 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
875 const Player* p1 = *(const Player* const*)elem1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
876 const Player* p2 = *(const Player* const*)elem2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
877 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
878 return p2->old_economy[1].performance_history - p1->old_economy[1].performance_history; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
879 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
880 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
881 struct CompanyLeagueWindow : Window { |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
882 CompanyLeagueWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
883 { |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
884 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
885 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
886 virtual void OnPaint() |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
887 { |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
888 const Player *plist[MAX_PLAYERS]; |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
889 const Player *p; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
890 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
891 this->DrawWidgets(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
892 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
893 uint pl_num = 0; |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
894 FOR_ALL_PLAYERS(p) if (p->is_active) plist[pl_num++] = p; |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
895 |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
896 qsort((void*)plist, pl_num, sizeof(*plist), PerfHistComp); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
897 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
898 for (uint i = 0; i != pl_num; i++) { |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
899 p = plist[i]; |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
900 SetDParam(0, i + STR_01AC_1ST); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
901 SetDParam(1, p->index); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
902 SetDParam(2, p->index); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
903 SetDParam(3, GetPerformanceTitleFromValue(p->old_economy[1].performance_history)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
904 |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
905 DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, TC_FROMSTRING); |
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
906 DrawPlayerIcon(p->index, 27, 16 + i * 10); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
907 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
908 } |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
909 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
910 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
911 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
912 static const Widget _company_league_widgets[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
913 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
914 { WWT_CAPTION, RESIZE_NONE, 14, 11, 387, 0, 13, STR_7053_COMPANY_LEAGUE_TABLE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
915 { WWT_STICKYBOX, RESIZE_NONE, 14, 388, 399, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
916 { WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 96, 0x0, STR_NULL}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
917 { WIDGETS_END}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
918 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
919 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
920 static const WindowDesc _company_league_desc = { |
7341
549c757023fc
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents:
7266
diff
changeset
|
921 WDP_AUTO, WDP_AUTO, 400, 97, 400, 97, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
922 WC_COMPANY_LEAGUE, WC_NONE, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
923 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
924 _company_league_widgets, |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
925 NULL |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
926 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
927 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
928 void ShowCompanyLeagueTable() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
929 { |
9289
c052caf473db
(svn r13155) -Codechange: make a window class of the company league and graph legenda windows.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
930 AllocateWindowDescFront<CompanyLeagueWindow>(&_company_league_desc, 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
931 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
932 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
933 /*****************************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
934 /* PERFORMANCE RATING DETAIL */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
935 /*****************************/ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
936 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
937 struct PerformanceRatingDetailWindow : Window { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
938 static PlayerID player; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
939 int timeout; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
940 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
941 PerformanceRatingDetailWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
942 { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
943 /* Disable the players who are not active */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
944 for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
945 this->SetWidgetDisabledState(i + 13, !GetPlayer(i)->is_active); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
946 } |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
947 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
948 this->UpdatePlayerStats(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
949 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
950 if (player != INVALID_PLAYER) this->LowerWidget(player + 13); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
951 this->SetDirty(); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
952 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
953 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
954 void UpdatePlayerStats() |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
955 { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
956 /* Update all player stats with the current data |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
957 * (this is because _score_info is not saved to a savegame) */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
958 Player *p; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
959 FOR_ALL_PLAYERS(p) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
960 if (p->is_active) UpdateCompanyRatingAndValue(p, false); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
961 } |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
962 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
963 this->timeout = DAY_TICKS * 5; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
964 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
965 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
966 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
967 virtual void OnPaint() |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
968 { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
969 byte x; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
970 uint16 y = 14; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
971 int total_score = 0; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
972 int color_done, color_notdone; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
973 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
974 /* Draw standard stuff */ |
9273
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9255
diff
changeset
|
975 this->DrawWidgets(); |
5946
1dc5b0b8fe69
(svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents:
5893
diff
changeset
|
976 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
977 /* Check if the currently selected player is still active. */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
978 if (player == INVALID_PLAYER || !GetPlayer(player)->is_active) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
979 if (player != INVALID_PLAYER) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
980 /* Raise and disable the widget for the previous selection. */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
981 this->RaiseWidget(player + 13); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
982 this->DisableWidget(player + 13); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
983 this->SetDirty(); |
5946
1dc5b0b8fe69
(svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents:
5893
diff
changeset
|
984 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
985 player = INVALID_PLAYER; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
986 } |
5946
1dc5b0b8fe69
(svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents:
5893
diff
changeset
|
987 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
988 for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
989 if (GetPlayer(i)->is_active) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
990 /* Lower the widget corresponding to this player. */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
991 this->LowerWidget(i + 13); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
992 this->SetDirty(); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
993 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
994 player = i; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
995 break; |
5946
1dc5b0b8fe69
(svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents:
5893
diff
changeset
|
996 } |
1dc5b0b8fe69
(svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents:
5893
diff
changeset
|
997 } |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
998 } |
5946
1dc5b0b8fe69
(svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents:
5893
diff
changeset
|
999 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1000 /* If there are no active players, don't display anything else. */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1001 if (player == INVALID_PLAYER) return; |
5946
1dc5b0b8fe69
(svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents:
5893
diff
changeset
|
1002 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1003 /* Paint the player icons */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1004 for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1005 if (!GetPlayer(i)->is_active) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1006 /* Check if we have the player as an active player */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1007 if (!this->IsWidgetDisabled(i + 13)) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1008 /* Bah, player gone :( */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1009 this->DisableWidget(i + 13); |
5946
1dc5b0b8fe69
(svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros <maedhros@openttd.org>
parents:
5893
diff
changeset
|
1010 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1011 /* We need a repaint */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1012 this->SetDirty(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1013 } |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1014 continue; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1015 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1016 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1017 /* Check if we have the player marked as inactive */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1018 if (this->IsWidgetDisabled(i + 13)) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1019 /* New player! Yippie :p */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1020 this->EnableWidget(i + 13); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1021 /* We need a repaint */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1022 this->SetDirty(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1023 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1024 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1025 x = (i == player) ? 1 : 0; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1026 DrawPlayerIcon(i, i * 37 + 13 + x, 16 + x); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1027 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1028 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1029 /* The colors used to show how the progress is going */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1030 color_done = _colour_gradient[COLOUR_GREEN][4]; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1031 color_notdone = _colour_gradient[COLOUR_RED][4]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1032 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1033 /* Draw all the score parts */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1034 for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1035 int val = _score_part[player][i]; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1036 int needed = _score_info[i].needed; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1037 int score = _score_info[i].score; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1038 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1039 y += 20; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1040 /* SCORE_TOTAL has his own rulez ;) */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1041 if (i == SCORE_TOTAL) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1042 needed = total_score; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1043 score = SCORE_MAX; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1044 } else { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1045 total_score += score; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1046 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1047 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1048 DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, TC_FROMSTRING); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1049 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1050 /* Draw the score */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1051 SetDParam(0, score); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1052 DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, TC_FROMSTRING); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1053 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1054 /* Calculate the %-bar */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1055 x = Clamp(val, 0, needed) * 50 / needed; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1056 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1057 /* SCORE_LOAN is inversed */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1058 if (val < 0 && i == SCORE_LOAN) x = 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1059 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1060 /* Draw the bar */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1061 if (x != 0) GfxFillRect(112, y - 2, 112 + x, y + 10, color_done); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1062 if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1063 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1064 /* Calculate the % */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1065 x = Clamp(val, 0, needed) * 100 / needed; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1066 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1067 /* SCORE_LOAN is inversed */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1068 if (val < 0 && i == SCORE_LOAN) x = 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1069 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1070 /* Draw it */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1071 SetDParam(0, x); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1072 DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1073 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1074 /* SCORE_LOAN is inversed */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1075 if (i == SCORE_LOAN) val = needed - val; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1076 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1077 /* Draw the amount we have against what is needed |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1078 * For some of them it is in currency format */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1079 SetDParam(0, val); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1080 SetDParam(1, needed); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1081 switch (i) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1082 case SCORE_MIN_PROFIT: |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1083 case SCORE_MIN_INCOME: |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1084 case SCORE_MAX_INCOME: |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1085 case SCORE_MONEY: |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1086 case SCORE_LOAN: |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1087 DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, TC_FROMSTRING); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1088 break; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1089 default: |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1090 DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, TC_FROMSTRING); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1091 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1092 } |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1093 } |
8179
a0879dc1b54d
(svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138 <peter1138@openttd.org>
parents:
8140
diff
changeset
|
1094 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1095 virtual void OnClick(Point pt, int widget) |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1096 { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1097 /* Check which button is clicked */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1098 if (IsInsideMM(widget, 13, 21)) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1099 /* Is it no on disable? */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1100 if (!this->IsWidgetDisabled(widget)) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1101 this->RaiseWidget(player + 13); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1102 player = (PlayerID)(widget - 13); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1103 this->LowerWidget(player + 13); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1104 this->SetDirty(); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1105 } |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1106 } |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1107 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1108 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1109 virtual void OnTick() |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1110 { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1111 if (_pause_game != 0) return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1112 |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1113 /* Update the player score every 5 days */ |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1114 if (--this->timeout == 0) { |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1115 this->UpdatePlayerStats(); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1116 this->SetDirty(); |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1117 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1118 } |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1119 }; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1120 |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1121 PlayerID PerformanceRatingDetailWindow::player = INVALID_PLAYER; |
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1122 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1123 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1124 static const Widget _performance_rating_detail_widgets[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1125 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1126 { WWT_CAPTION, RESIZE_NONE, 14, 11, 298, 0, 13, STR_PERFORMANCE_DETAIL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1127 { WWT_PANEL, RESIZE_NONE, 14, 0, 298, 14, 27, 0x0, STR_NULL}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1128 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1129 { WWT_PANEL, RESIZE_NONE, 14, 0, 298, 28, 47, 0x0, STR_PERFORMANCE_DETAIL_VEHICLES_TIP}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1130 { WWT_PANEL, RESIZE_NONE, 14, 0, 298, 48, 67, 0x0, STR_PERFORMANCE_DETAIL_STATIONS_TIP}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1131 { WWT_PANEL, RESIZE_NONE, 14, 0, 298, 68, 87, 0x0, STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1132 { WWT_PANEL, RESIZE_NONE, 14, 0, 298, 88, 107, 0x0, STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1133 { WWT_PANEL, RESIZE_NONE, 14, 0, 298, 108, 127, 0x0, STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1134 { WWT_PANEL, RESIZE_NONE, 14, 0, 298, 128, 147, 0x0, STR_PERFORMANCE_DETAIL_DELIVERED_TIP}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1135 { WWT_PANEL, RESIZE_NONE, 14, 0, 298, 148, 167, 0x0, STR_PERFORMANCE_DETAIL_CARGO_TIP}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1136 { WWT_PANEL, RESIZE_NONE, 14, 0, 298, 168, 187, 0x0, STR_PERFORMANCE_DETAIL_MONEY_TIP}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1137 { WWT_PANEL, RESIZE_NONE, 14, 0, 298, 188, 207, 0x0, STR_PERFORMANCE_DETAIL_LOAN_TIP}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1138 { WWT_PANEL, RESIZE_NONE, 14, 0, 298, 208, 227, 0x0, STR_PERFORMANCE_DETAIL_TOTAL_TIP}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1139 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1140 { WWT_PANEL, RESIZE_NONE, 14, 2, 38, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1141 { WWT_PANEL, RESIZE_NONE, 14, 39, 75, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1142 { WWT_PANEL, RESIZE_NONE, 14, 76, 112, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1143 { WWT_PANEL, RESIZE_NONE, 14, 113, 149, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1144 { WWT_PANEL, RESIZE_NONE, 14, 150, 186, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1145 { WWT_PANEL, RESIZE_NONE, 14, 187, 223, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1146 { WWT_PANEL, RESIZE_NONE, 14, 224, 260, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1147 { WWT_PANEL, RESIZE_NONE, 14, 261, 297, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1148 { WIDGETS_END}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1149 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1150 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1151 static const WindowDesc _performance_rating_detail_desc = { |
7341
549c757023fc
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents:
7266
diff
changeset
|
1152 WDP_AUTO, WDP_AUTO, 299, 228, 299, 228, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5812
diff
changeset
|
1153 WC_PERFORMANCE_DETAIL, WC_NONE, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1154 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1155 _performance_rating_detail_widgets, |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1156 NULL |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1157 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1158 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6203
diff
changeset
|
1159 void ShowPerformanceRatingDetail() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1160 { |
9255
e12e58b72aa0
(svn r13121) -Codechange: make a class of the PerformanceRatingDetailWindow.
rubidium <rubidium@openttd.org>
parents:
9143
diff
changeset
|
1161 AllocateWindowDescFront<PerformanceRatingDetailWindow>(&_performance_rating_detail_desc, 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1162 } |