src/graph_gui.cpp
author peter1138
Fri, 02 Mar 2007 11:36:34 +0000
changeset 6192 99324280e2ad
parent 6179 d19b0137d8e4
child 6203 861336d3e289
permissions -rw-r--r--
(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.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
     3
/** @file graph_gui.cpp */
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1575
diff changeset
     6
#include "openttd.h"
507
04b5403aaf6b (svn r815) Include strings.h only in the files which need it.
tron
parents: 410
diff changeset
     7
#include "table/strings.h"
2187
a0e206ce9fbf (svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents: 2186
diff changeset
     8
#include "table/sprites.h"
2163
b17b313113a0 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     9
#include "functions.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "player.h"
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
    14
#include "economy.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2135
diff changeset
    15
#include "variables.h"
4261
28670f743746 (svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents: 3801
diff changeset
    16
#include "date.h"
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    17
#include "helpers.hpp"
6091
c8827d9ae04a (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 5946
diff changeset
    18
#include "cargotype.h"
5291
0bd449fe7fe5 (svn r7444) -Codechange: Use one (global) cargo-colours array for drawing cargo-colours. Change Food
Darkvater
parents: 5247
diff changeset
    19
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
    20
/* Bitmasks of player and cargo indices that shouldn't be drawn. */
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
    21
static uint _legend_excluded_players;
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
    22
static uint _legend_excluded_cargo;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
/************************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
/* GENERIC GRAPH DRAWER */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
/************************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
5768
dded34549c8c (svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros
parents: 5766
diff changeset
    28
enum {
dded34549c8c (svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros
parents: 5766
diff changeset
    29
	GRAPH_MAX_DATASETS = 16,
dded34549c8c (svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros
parents: 5766
diff changeset
    30
	GRAPH_AXIS_LABEL_COLOUR = 16,
dded34549c8c (svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros
parents: 5766
diff changeset
    31
	GRAPH_AXIS_LINE_COLOUR  = 215,
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    32
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
    33
	GRAPH_X_POSITION_BEGINNING  = 44,  ///< Start the graph 44 pixels from gw->left
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
    34
	GRAPH_X_POSITION_SEPARATION = 22,  ///< There are 22 pixels between each X value
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    35
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
    36
	GRAPH_NUM_LINES_Y = 9, ///< How many horizontal lines to draw.
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
    37
	/* 9 is convenient as that means the distance between them is the height of the graph / 8,
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
    38
	 * which is the same
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    39
	 * as height >> 3. */
5768
dded34549c8c (svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros
parents: 5766
diff changeset
    40
};
236
da0ae9d977e0 (svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents: 222
diff changeset
    41
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
    42
/* Apparently these don't play well with enums. */
5812
9b4a245e4fbe (svn r8374) -Fix (r8367): LLONG_MAX isn't always defined, and INT64_MAX describes the
maedhros
parents: 5807
diff changeset
    43
static const int64 INVALID_DATAPOINT     = INT64_MAX; // Value used for a datapoint that shouldn't be drawn.
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
    44
static const uint  INVALID_DATAPOINT_POS = UINT_MAX;  // Used to determine if the previous point was drawn.
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
    45
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
typedef struct GraphDrawer {
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
    47
	uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed.
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
	byte num_dataset;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
	byte num_on_x_axis;
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
    50
	bool has_negative_values;
5771
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
    51
	byte num_vert_lines;
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
    52
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
    53
	/* The starting month and year that values are plotted against. If month is
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
    54
	 * 0xFF, use x_values_start and x_values_increment below instead. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
	byte month;
4293
4b7006c1b5eb (svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents: 4286
diff changeset
    56
	Year year;
5771
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
    57
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
    58
	/* These values are used if the graph is being plotted against values
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
    59
	 * rather than the dates specified by month and year. */
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
    60
	uint16 x_values_start;
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
    61
	uint16 x_values_increment;
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
    62
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
    63
	int left, top;  ///< Where to start drawing the graph, in pixels.
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
    64
	uint height;    ///< The height of the graph in pixels.
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
	StringID format_str_y_axis;
5768
dded34549c8c (svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros
parents: 5766
diff changeset
    66
	byte colors[GRAPH_MAX_DATASETS];
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
    67
	int64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
} GraphDrawer;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2261
diff changeset
    70
static void DrawGraph(const GraphDrawer *gw)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
{
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
    72
	uint x, y;            ///< Reused whenever x and y coordinates are needed.
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
    73
	int64 highest_value;  ///< Highest value to be drawn.
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
    74
	int x_axis_offset;    ///< Distance from the top of the graph to the x axis.
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
240
f1efbac04112 (svn r241) -Fix: Trailing spaces :O
darkvater
parents: 236
diff changeset
    76
	/* the colors and cost array of GraphDrawer must accomodate
236
da0ae9d977e0 (svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents: 222
diff changeset
    77
	 * both values for cargo and players. So if any are higher, quit */
5768
dded34549c8c (svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros
parents: 5766
diff changeset
    78
	assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_PLAYERS);
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    79
	assert(gw->num_vert_lines > 0);
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    80
5766
1980eef57c7d (svn r8317) -Codechange: Remove GraphDrawer::bg_line_color since it was the same everywhere it was set.
maedhros
parents: 5761
diff changeset
    81
	byte grid_colour = _colour_gradient[14][4];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
    83
	/* The coordinates of the opposite edges of the graph. */
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    84
	int bottom = gw->top + gw->height - 1;
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
    85
	int right  = gw->left + GRAPH_X_POSITION_BEGINNING + gw->num_vert_lines * GRAPH_X_POSITION_SEPARATION - 1;
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    86
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
    87
	/* Draw the vertical grid lines. */
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    88
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    89
	/* Don't draw the first line, as that's where the axis will be. */
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    90
	x = gw->left + GRAPH_X_POSITION_BEGINNING + GRAPH_X_POSITION_SEPARATION;
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    91
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    92
	for (int i = 0; i < gw->num_vert_lines; i++) {
5766
1980eef57c7d (svn r8317) -Codechange: Remove GraphDrawer::bg_line_color since it was the same everywhere it was set.
maedhros
parents: 5761
diff changeset
    93
		GfxFillRect(x, gw->top, x, bottom, grid_colour);
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    94
		x += GRAPH_X_POSITION_SEPARATION;
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    95
	}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    96
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
    97
	/* Draw the horizontal grid lines. */
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
    98
	x = gw->left + GRAPH_X_POSITION_BEGINNING;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
	y = gw->height + gw->top;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   101
	for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) {
5766
1980eef57c7d (svn r8317) -Codechange: Remove GraphDrawer::bg_line_color since it was the same everywhere it was set.
maedhros
parents: 5761
diff changeset
   102
		GfxFillRect(x, y, right, y, grid_colour);
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   103
		y -= (gw->height / (GRAPH_NUM_LINES_Y - 1));
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   104
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   106
	/* Draw the y axis. */
5768
dded34549c8c (svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros
parents: 5766
diff changeset
   107
	GfxFillRect(x, gw->top, x, bottom, GRAPH_AXIS_LINE_COLOUR);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   109
	/* Find the distance from the top of the graph to the x axis. */
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   110
	x_axis_offset = gw->height;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   112
	/* The graph is currently symmetrical about the x axis. */
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   113
	if (gw->has_negative_values) x_axis_offset /= 2;
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   114
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   115
	/* Draw the x axis. */
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   116
	y = x_axis_offset + gw->top;
5768
dded34549c8c (svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros
parents: 5766
diff changeset
   117
	GfxFillRect(x, y, right, y, GRAPH_AXIS_LINE_COLOUR);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   119
	/* Find the largest value that will be drawn. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
	if (gw->num_on_x_axis == 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   123
	assert(gw->num_on_x_axis > 0);
5778
94301697f913 (svn r8330) -Codechange: Remove num_x and num_dataset from DrawGraph.
maedhros
parents: 5777
diff changeset
   124
	assert(gw->num_dataset > 0);
236
da0ae9d977e0 (svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents: 222
diff changeset
   125
5804
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   126
	/* Start of with a value of twice the height of the graph in pixels. It's a
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   127
	 * bit arbitrary, but it makes the cargo payment graph look a little nicer,
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   128
	 * and prevents division by zero when calculating where the datapoint
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   129
	 * should be drawn. */
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   130
	highest_value = x_axis_offset * 2;
5796
3e1a1281a9dc (svn r8356) -Codechange: [Graphs] Rename mx to highest_value, and fix the scaling for negative values.
maedhros
parents: 5793
diff changeset
   131
5778
94301697f913 (svn r8330) -Codechange: Remove num_x and num_dataset from DrawGraph.
maedhros
parents: 5777
diff changeset
   132
	for (int i = 0; i < gw->num_dataset; i++) {
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
   133
		if (!HASBIT(gw->excluded_data, i)) {
5791
7b2a5160ee31 (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
parents: 5778
diff changeset
   134
			for (int j = 0; j < gw->num_on_x_axis; j++) {
7b2a5160ee31 (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
parents: 5778
diff changeset
   135
				int64 datapoint = gw->cost[i][j];
7b2a5160ee31 (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
parents: 5778
diff changeset
   136
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   137
				if (datapoint != INVALID_DATAPOINT) {
5796
3e1a1281a9dc (svn r8356) -Codechange: [Graphs] Rename mx to highest_value, and fix the scaling for negative values.
maedhros
parents: 5793
diff changeset
   138
					/* For now, if the graph has negative values the scaling is
3e1a1281a9dc (svn r8356) -Codechange: [Graphs] Rename mx to highest_value, and fix the scaling for negative values.
maedhros
parents: 5793
diff changeset
   139
					 * symmetrical about the x axis, so take the absolute value
3e1a1281a9dc (svn r8356) -Codechange: [Graphs] Rename mx to highest_value, and fix the scaling for negative values.
maedhros
parents: 5793
diff changeset
   140
					 * of each data point. */
3e1a1281a9dc (svn r8356) -Codechange: [Graphs] Rename mx to highest_value, and fix the scaling for negative values.
maedhros
parents: 5793
diff changeset
   141
					highest_value = max(highest_value, myabs(datapoint));
236
da0ae9d977e0 (svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents: 222
diff changeset
   142
				}
5778
94301697f913 (svn r8330) -Codechange: Remove num_x and num_dataset from DrawGraph.
maedhros
parents: 5777
diff changeset
   143
			}
236
da0ae9d977e0 (svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents: 222
diff changeset
   144
		}
5778
94301697f913 (svn r8330) -Codechange: Remove num_x and num_dataset from DrawGraph.
maedhros
parents: 5777
diff changeset
   145
	}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   146
5804
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   147
	/* Round up highest_value so that it will divide cleanly into the number of
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   148
	 * axis labels used. */
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   149
	int round_val = highest_value % (GRAPH_NUM_LINES_Y - 1);
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   150
	if (round_val != 0) highest_value += (GRAPH_NUM_LINES_Y - 1 - round_val);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
	/* draw text strings on the y axis */
5804
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   153
	int64 y_label = highest_value;
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   154
	int64 y_label_separation = highest_value / (GRAPH_NUM_LINES_Y - 1);
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   155
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   156
	/* If there are negative values, the graph goes from highest_value to
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   157
	 * -highest_value, not highest_value to 0. */
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   158
	if (gw->has_negative_values) y_label_separation *= 2;
5804
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   159
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   160
	x = gw->left + GRAPH_X_POSITION_BEGINNING + 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
	y = gw->top - 3;
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   162
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   163
	for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   164
		SetDParam(0, gw->format_str_y_axis);
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   165
		SetDParam64(1, y_label);
5768
dded34549c8c (svn r8319) -Codechange: Remove the remaining colours from GraphDrawer as they're also the same everywhere.
maedhros
parents: 5766
diff changeset
   166
		DrawStringRightAligned(x, y, STR_0170, GRAPH_AXIS_LABEL_COLOUR);
5804
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   167
e5cd74217104 (svn r8366) -Codechange: [Graphs] Make the scaling code less cryptic, and fix two longstanding bugs.
maedhros
parents: 5796
diff changeset
   168
		y_label -= y_label_separation;
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   169
		y += (gw->height / (GRAPH_NUM_LINES_Y - 1));
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   170
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
	/* draw strings on the x axis */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
	if (gw->month != 0xFF) {
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   174
		x = gw->left + GRAPH_X_POSITION_BEGINNING;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
		y = gw->top + gw->height + 1;
5777
6a780a23cb59 (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
parents: 5776
diff changeset
   176
		byte month = gw->month;
6a780a23cb59 (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
parents: 5776
diff changeset
   177
		Year year  = gw->year;
6a780a23cb59 (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
parents: 5776
diff changeset
   178
		for (int i = 0; i < gw->num_on_x_axis; i++) {
6a780a23cb59 (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
parents: 5776
diff changeset
   179
			SetDParam(0, month + STR_0162_JAN);
6a780a23cb59 (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
parents: 5776
diff changeset
   180
			SetDParam(1, month + STR_0162_JAN + 2);
6a780a23cb59 (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
parents: 5776
diff changeset
   181
			SetDParam(2, year);
6a780a23cb59 (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
parents: 5776
diff changeset
   182
			DrawString(x, y, month == 0 ? STR_016F : STR_016E, GRAPH_AXIS_LABEL_COLOUR);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
5777
6a780a23cb59 (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
parents: 5776
diff changeset
   184
			month += 3;
6a780a23cb59 (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
parents: 5776
diff changeset
   185
			if (month >= 12) {
6a780a23cb59 (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
parents: 5776
diff changeset
   186
				month = 0;
6a780a23cb59 (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
parents: 5776
diff changeset
   187
				year++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
			}
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   189
			x += GRAPH_X_POSITION_SEPARATION;
5777
6a780a23cb59 (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
parents: 5776
diff changeset
   190
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
	} else {
5793
01b18d4550e2 (svn r8350) -Codechange: [Graphs] Use DrawStringCentered instead of a hardcoded offset to make the string appear centred.
maedhros
parents: 5791
diff changeset
   192
		/* Draw the label under the data point rather than on the grid line. */
01b18d4550e2 (svn r8350) -Codechange: [Graphs] Use DrawStringCentered instead of a hardcoded offset to make the string appear centred.
maedhros
parents: 5791
diff changeset
   193
		x = gw->left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2) + 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
		y = gw->top + gw->height + 1;
5771
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
   195
		uint16 label = gw->x_values_start;
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
   196
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
   197
		for (int i = 0; i < gw->num_on_x_axis; i++) {
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
   198
			SetDParam(0, label);
5793
01b18d4550e2 (svn r8350) -Codechange: [Graphs] Use DrawStringCentered instead of a hardcoded offset to make the string appear centred.
maedhros
parents: 5791
diff changeset
   199
			DrawStringCentered(x, y, STR_01CB, GRAPH_AXIS_LABEL_COLOUR);
01b18d4550e2 (svn r8350) -Codechange: [Graphs] Use DrawStringCentered instead of a hardcoded offset to make the string appear centred.
maedhros
parents: 5791
diff changeset
   200
5771
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
   201
			label += gw->x_values_increment;
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   202
			x += GRAPH_X_POSITION_SEPARATION;
5771
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
   203
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
	/* draw lines and dots */
5777
6a780a23cb59 (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
parents: 5776
diff changeset
   207
	for (int i = 0; i < gw->num_dataset; i++) {
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
   208
		if (!HASBIT(gw->excluded_data, i)) {
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   209
			/* Centre the dot between the grid lines. */
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   210
			x = gw->left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2);
5791
7b2a5160ee31 (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
parents: 5778
diff changeset
   211
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   212
			byte color  = gw->colors[i];
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   213
			uint prev_x = INVALID_DATAPOINT_POS;
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   214
			uint prev_y = INVALID_DATAPOINT_POS;
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   215
5791
7b2a5160ee31 (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
parents: 5778
diff changeset
   216
			for (int j = 0; j < gw->num_on_x_axis; j++) {
7b2a5160ee31 (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
parents: 5778
diff changeset
   217
				int64 datapoint = gw->cost[i][j];
7b2a5160ee31 (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
parents: 5778
diff changeset
   218
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   219
				if (datapoint != INVALID_DATAPOINT) {
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   220
					/* XXX: This can overflow if x_axis_offset * datapoint is
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   221
					 * too big to fit in an int64. */
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   222
					y = gw->top + x_axis_offset - (x_axis_offset * datapoint) / highest_value;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   224
					/* Draw the point. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
					GfxFillRect(x-1, y-1, x+1, y+1, color);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   227
					/* Draw the line connected to the previous point. */
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   228
					if (prev_x != INVALID_DATAPOINT_POS) GfxDrawLine(prev_x, prev_y, x, y, color);
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   229
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   230
					prev_x = x;
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   231
					prev_y = y;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
				} else {
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   233
					prev_x = INVALID_DATAPOINT_POS;
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   234
					prev_y = INVALID_DATAPOINT_POS;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
				}
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   236
5776
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   237
				x += GRAPH_X_POSITION_SEPARATION;
d36a554d7ccd (svn r8328) -Codechange: Remove some magic numbers in the graph drawing code.
maedhros
parents: 5771
diff changeset
   238
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
		}
5777
6a780a23cb59 (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
parents: 5776
diff changeset
   240
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
/* GRAPH LEGEND */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
static void GraphLegendWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
{
2475
efdcc705cb61 (svn r3001) s/Player*/const Player*/
tron
parents: 2458
diff changeset
   249
	const Player* p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   251
	switch (e->event) {
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   252
	case WE_CREATE: {
5235
2313d53f426a (svn r7355) -Codechange: replace 'for (i = 0; w->widget[i].type != WWT_TYPE; i++)'-type for loops with 'for (i = 0; i < w->widget_count; i++)'-type for loops
rubidium
parents: 5070
diff changeset
   253
		uint i;
2313d53f426a (svn r7355) -Codechange: replace 'for (i = 0; w->widget[i].type != WWT_TYPE; i++)'-type for loops with 'for (i = 0; i < w->widget_count; i++)'-type for loops
rubidium
parents: 5070
diff changeset
   254
		for (i = 3; i < w->widget_count; i++) {
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
   255
			if (!HASBIT(_legend_excluded_players, i - 3)) LowerWindowWidget(w, i);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   256
		}
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   257
		break;
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   258
	}
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   259
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
		FOR_ALL_PLAYERS(p) {
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   262
			if (!p->is_active) {
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
   263
				SETBIT(_legend_excluded_players, p->index);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   264
				RaiseWindowWidget(w, p->index + 3);
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   265
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
		FOR_ALL_PLAYERS(p) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2482
diff changeset
   270
			if (!p->is_active) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
			DrawPlayerIcon(p->index, 4, 18+p->index*12);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   274
			SetDParam(0, p->name_1);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   275
			SetDParam(1, p->name_2);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   276
			SetDParam(2, GetPlayerNameString(p->index, 3));
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
   277
			DrawString(21, 17 + p->index * 12, STR_7021, HASBIT(_legend_excluded_players, p->index) ? 0x10 : 0xC);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4444
diff changeset
   282
		if (IS_INT_INSIDE(e->we.click.widget, 3, 11)) {
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
   283
			TOGGLEBIT(_legend_excluded_players, e->we.click.widget - 3);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   284
			ToggleWidgetLoweredState(w, e->we.click.widget);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
			InvalidateWindow(WC_INCOME_GRAPH, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
			InvalidateWindow(WC_OPERATING_PROFIT, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
			InvalidateWindow(WC_DELIVERED_CARGO, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
			InvalidateWindow(WC_PERFORMANCE_HISTORY, 0);
140
b00ce8503044 (svn r141) -Fix: Company-value was not updated immediatly if legend was changed
truelight
parents: 116
diff changeset
   290
			InvalidateWindow(WC_COMPANY_VALUE, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
static const Widget _graph_legend_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   297
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   298
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   249,     0,    13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   299
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   249,    14,   113, 0x0,                            STR_NULL},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   300
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    16,    27, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   301
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    28,    39, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   302
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    40,    51, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   303
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    52,    63, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   304
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    64,    75, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   305
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    76,    87, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   306
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    88,    99, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   307
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,   100,   111, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 165
diff changeset
   308
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
static const WindowDesc _graph_legend_desc = {
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 4938
diff changeset
   312
	WDP_AUTO, WDP_AUTO, 250, 114,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   313
	WC_GRAPH_LEGEND, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
	_graph_legend_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
	GraphLegendWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1086
diff changeset
   319
static void ShowGraphLegend(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
	AllocateWindowDescFront(&_graph_legend_desc, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
/********************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
/* OPERATING PROFIT */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
/********************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
static void SetupGraphDrawerForPlayers(GraphDrawer *gd)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
{
2475
efdcc705cb61 (svn r3001) s/Player*/const Player*/
tron
parents: 2458
diff changeset
   330
	const Player* p;
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
   331
	uint excluded_players = _legend_excluded_players;
5601
d58f82901b2f (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
parents: 5587
diff changeset
   332
	byte nums;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
	int mo,yr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
   335
	/* Exclude the players which aren't valid */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
	FOR_ALL_PLAYERS(p) {
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
   337
		if (!p->is_active) SETBIT(excluded_players, p->index);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   338
	}
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
   339
	gd->excluded_data = excluded_players;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
	gd->num_vert_lines = 24;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
	nums = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
	FOR_ALL_PLAYERS(p) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
		if (p->is_active) nums = max(nums,p->num_valid_stat_ent);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
	gd->num_on_x_axis = min(nums,24);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
	mo = (_cur_month/3-nums)*3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
	yr = _cur_year;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
	while (mo < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
		yr--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
		mo += 12;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
	gd->year = yr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
	gd->month = mo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
static void OperatingProfitWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   361
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
		GraphDrawer gd;
2475
efdcc705cb61 (svn r3001) s/Player*/const Player*/
tron
parents: 2458
diff changeset
   364
		const Player* p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
		int i,j;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
		int numd;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
		DrawWindowWidgets(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   369
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
		gd.left = 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
		gd.top = 18;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
		gd.height = 136;
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   373
		gd.has_negative_values = true;
2246
f0280a92b7ce (svn r2766) Remove string and make use of the plural feature
tron
parents: 2187
diff changeset
   374
		gd.format_str_y_axis = STR_CURRCOMPACT;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   375
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
		SetupGraphDrawerForPlayers(&gd);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   378
		numd = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
		FOR_ALL_PLAYERS(p) {
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   380
			if (p->is_active) {
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4365
diff changeset
   381
				gd.colors[numd] = _colour_gradient[p->player_color][6];
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   382
				for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   383
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : (p->old_economy[j].income + p->old_economy[j].expenses);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   384
					i++;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   385
				}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   386
			}
1079
95a0d4edb544 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   387
			numd++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
		}
1085
56facccb1f3d (svn r1586) Fix: [ 1107340 ] Graphs don't show comapany info for company #8
dominik
parents: 1079
diff changeset
   389
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   390
		gd.num_dataset = numd;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
		DrawGraph(&gd);
236
da0ae9d977e0 (svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents: 222
diff changeset
   393
	}	break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4444
diff changeset
   395
		if (e->we.click.widget == 2) /* Clicked on Legend */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
			ShowGraphLegend();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
static const Widget _operating_profit_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   402
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   403
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7025_OPERATING_PROFIT_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   404
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,                    STR_704D_SHOW_KEY_TO_GRAPHS},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   405
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   575,    14,   173, 0x0,                             STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 165
diff changeset
   406
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
static const WindowDesc _operating_profit_desc = {
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 4938
diff changeset
   410
	WDP_AUTO, WDP_AUTO, 576, 174,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   411
	WC_OPERATING_PROFIT, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
	_operating_profit_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
	OperatingProfitWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1086
diff changeset
   418
void ShowOperatingProfitGraph(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   420
	if (AllocateWindowDescFront(&_operating_profit_desc, 0)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
/* INCOME GRAPH */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
static void IncomeGraphWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   432
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   434
		GraphDrawer gd;
2475
efdcc705cb61 (svn r3001) s/Player*/const Player*/
tron
parents: 2458
diff changeset
   435
		const Player* p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
		int i,j;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
		int numd;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
		gd.left = 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
		gd.top = 18;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
		gd.height = 104;
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   444
		gd.has_negative_values = false;
2246
f0280a92b7ce (svn r2766) Remove string and make use of the plural feature
tron
parents: 2187
diff changeset
   445
		gd.format_str_y_axis = STR_CURRCOMPACT;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
		SetupGraphDrawerForPlayers(&gd);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   448
		numd = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
		FOR_ALL_PLAYERS(p) {
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   450
			if (p->is_active) {
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4365
diff changeset
   451
				gd.colors[numd] = _colour_gradient[p->player_color][6];
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   452
				for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   453
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].income;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   454
					i++;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   455
				}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   456
			}
1079
95a0d4edb544 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   457
			numd++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   459
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   460
		gd.num_dataset = numd;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   461
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
		DrawGraph(&gd);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4444
diff changeset
   467
		if (e->we.click.widget == 2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
			ShowGraphLegend();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
static const Widget _income_graph_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   474
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   475
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7022_INCOME_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   476
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,          STR_704D_SHOW_KEY_TO_GRAPHS},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   477
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   575,    14,   141, 0x0,                   STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 165
diff changeset
   478
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
static const WindowDesc _income_graph_desc = {
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 4938
diff changeset
   482
	WDP_AUTO, WDP_AUTO, 576, 142,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   483
	WC_INCOME_GRAPH, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
	_income_graph_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   486
	IncomeGraphWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1086
diff changeset
   489
void ShowIncomeGraph(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   490
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
	if (AllocateWindowDescFront(&_income_graph_desc, 0)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   492
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   493
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   494
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
/*******************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
/* DELIVERED CARGO */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
/*******************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
static void DeliveredCargoGraphWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   502
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
		GraphDrawer gd;
2475
efdcc705cb61 (svn r3001) s/Player*/const Player*/
tron
parents: 2458
diff changeset
   505
		const Player* p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
		int i,j;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
		int numd;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   509
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
		gd.left = 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
		gd.top = 18;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
		gd.height = 104;
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   514
		gd.has_negative_values = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
		gd.format_str_y_axis = STR_7024;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
		SetupGraphDrawerForPlayers(&gd);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   518
		numd = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
		FOR_ALL_PLAYERS(p) {
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   520
			if (p->is_active) {
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4365
diff changeset
   521
				gd.colors[numd] = _colour_gradient[p->player_color][6];
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   522
				for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   523
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].delivered_cargo;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   524
					i++;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   525
				}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   526
			}
1079
95a0d4edb544 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   527
			numd++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   530
		gd.num_dataset = numd;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
		DrawGraph(&gd);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   533
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   534
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   535
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4444
diff changeset
   537
		if (e->we.click.widget == 2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   538
			ShowGraphLegend();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   539
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
static const Widget _delivered_cargo_graph_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   544
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   545
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7050_UNITS_OF_CARGO_DELIVERED, STR_018C_WINDOW_TITLE_DRAG_THIS},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   546
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,                      STR_704D_SHOW_KEY_TO_GRAPHS},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   547
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   575,    14,   141, 0x0,                               STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 165
diff changeset
   548
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
static const WindowDesc _delivered_cargo_graph_desc = {
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 4938
diff changeset
   552
	WDP_AUTO, WDP_AUTO, 576, 142,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   553
	WC_DELIVERED_CARGO, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
	_delivered_cargo_graph_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
	DeliveredCargoGraphWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   557
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1086
diff changeset
   559
void ShowDeliveredCargoGraph(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
	if (AllocateWindowDescFront(&_delivered_cargo_graph_desc, 0)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
	}
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   564
}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   565
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   566
/***********************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   567
/* PERFORMANCE HISTORY */
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   568
/***********************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   569
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   570
static void PerformanceHistoryWndProc(Window *w, WindowEvent *e)
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   571
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   572
	switch (e->event) {
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   573
	case WE_PAINT: {
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   574
		GraphDrawer gd;
2475
efdcc705cb61 (svn r3001) s/Player*/const Player*/
tron
parents: 2458
diff changeset
   575
		const Player* p;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   576
		int i,j;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   577
		int numd;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   578
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   579
		DrawWindowWidgets(w);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   580
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   581
		gd.left = 2;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   582
		gd.top = 18;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   583
		gd.height = 200;
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   584
		gd.has_negative_values = false;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   585
		gd.format_str_y_axis = STR_7024;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   586
		SetupGraphDrawerForPlayers(&gd);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   587
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   588
		numd = 0;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   589
		FOR_ALL_PLAYERS(p) {
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   590
			if (p->is_active) {
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4365
diff changeset
   591
				gd.colors[numd] = _colour_gradient[p->player_color][6];
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   592
				for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   593
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].performance_history;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   594
					i++;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   595
				}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   596
			}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   597
			numd++;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   598
		}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   599
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   600
		gd.num_dataset = numd;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   601
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   602
		DrawGraph(&gd);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   603
		break;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   604
	}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   605
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   606
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4444
diff changeset
   607
		if (e->we.click.widget == 2)
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   608
			ShowGraphLegend();
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4444
diff changeset
   609
		if (e->we.click.widget == 3)
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   610
			ShowPerformanceRatingDetail();
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   611
		break;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   612
	}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   613
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   614
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   615
static const Widget _performance_history_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   616
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                             STR_018B_CLOSE_WINDOW},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   617
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   475,     0,    13, STR_7051_COMPANY_PERFORMANCE_RATINGS, STR_018C_WINDOW_TITLE_DRAG_THIS},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   618
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,                         STR_704D_SHOW_KEY_TO_GRAPHS},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   619
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   476,   525,     0,    13, STR_PERFORMANCE_DETAIL_KEY,           STR_704D_SHOW_KEY_TO_GRAPHS},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   620
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   575,    14,   237, 0x0,                                  STR_NULL},
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   621
{   WIDGETS_END},
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   622
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   623
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   624
static const WindowDesc _performance_history_desc = {
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 4938
diff changeset
   625
	WDP_AUTO, WDP_AUTO, 576, 238,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   626
	WC_PERFORMANCE_HISTORY, WC_NONE,
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   627
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   628
	_performance_history_widgets,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   629
	PerformanceHistoryWndProc
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   630
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   631
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1086
diff changeset
   632
void ShowPerformanceHistoryGraph(void)
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   633
{
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   634
	if (AllocateWindowDescFront(&_performance_history_desc, 0)) {
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   635
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   636
	}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   637
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   638
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   639
/*****************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   640
/* COMPANY VALUE */
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   641
/*****************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   642
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   643
static void CompanyValueGraphWndProc(Window *w, WindowEvent *e)
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   644
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   645
	switch (e->event) {
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   646
	case WE_PAINT: {
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   647
		GraphDrawer gd;
2475
efdcc705cb61 (svn r3001) s/Player*/const Player*/
tron
parents: 2458
diff changeset
   648
		const Player* p;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   649
		int i,j;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   650
		int numd;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   651
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   652
		DrawWindowWidgets(w);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   653
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   654
		gd.left = 2;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   655
		gd.top = 18;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   656
		gd.height = 200;
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   657
		gd.has_negative_values = false;
2246
f0280a92b7ce (svn r2766) Remove string and make use of the plural feature
tron
parents: 2187
diff changeset
   658
		gd.format_str_y_axis = STR_CURRCOMPACT;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   659
		SetupGraphDrawerForPlayers(&gd);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   660
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   661
		numd = 0;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   662
		FOR_ALL_PLAYERS(p) {
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   663
			if (p->is_active) {
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4365
diff changeset
   664
				gd.colors[numd] = _colour_gradient[p->player_color][6];
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   665
				for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
5805
1e6230a16f9b (svn r8367) -Fix: [Graphs] Don't try to use the same value to mean something is invalid for both an int64 and a uint.
maedhros
parents: 5804
diff changeset
   666
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].company_value;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   667
					i++;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   668
				}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   669
			}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   670
			numd++;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   671
		}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   672
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   673
		gd.num_dataset = numd;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   674
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   675
		DrawGraph(&gd);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   676
		break;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   677
	}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   678
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   679
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4444
diff changeset
   680
		if (e->we.click.widget == 2)
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   681
			ShowGraphLegend();
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   682
		break;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   683
	}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   684
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   685
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   686
static const Widget _company_value_graph_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   687
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   688
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7052_COMPANY_VALUES, STR_018C_WINDOW_TITLE_DRAG_THIS},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   689
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,            STR_704D_SHOW_KEY_TO_GRAPHS},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   690
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   575,    14,   237, 0x0,                     STR_NULL},
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   691
{   WIDGETS_END},
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   692
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   693
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   694
static const WindowDesc _company_value_graph_desc = {
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 4938
diff changeset
   695
	WDP_AUTO, WDP_AUTO, 576, 238,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   696
	WC_COMPANY_VALUE, WC_NONE,
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   697
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   698
	_company_value_graph_widgets,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   699
	CompanyValueGraphWndProc
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   700
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   701
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1086
diff changeset
   702
void ShowCompanyValueGraph(void)
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   703
{
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   704
	if (AllocateWindowDescFront(&_company_value_graph_desc, 0)) {
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   705
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   706
	}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   707
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   708
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   709
/*****************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   710
/* PAYMENT RATES */
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   711
/*****************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   712
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   713
static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   714
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   715
	switch (e->event) {
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   716
	case WE_PAINT: {
3344
fc86351d4641 (svn r4128) - CodeChange: Add proper semantics for CargoID for such variables instead of using the general byte-type.
Darkvater
parents: 3033
diff changeset
   717
		int j, x, y;
6192
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   718
		uint i = 0;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   719
		GraphDrawer gd;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   720
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   721
		DrawWindowWidgets(w);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   722
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   723
		x = 495;
4911
bbaaba548c1c (svn r6882) -Fix r6777: Off by one drawing error for cargo buttons
Darkvater
parents: 4851
diff changeset
   724
		y = 24;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   725
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
   726
		gd.excluded_data = _legend_excluded_cargo;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   727
		gd.left = 2;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   728
		gd.top = 24;
6192
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   729
		gd.height = w->height - 38;
5807
2723bba6f958 (svn r8369) -Cleanup: [Graphs] Rename include_neg and adj_height to more descriptive names, and add some more comments.
maedhros
parents: 5806
diff changeset
   730
		gd.has_negative_values = false;
2246
f0280a92b7ce (svn r2766) Remove string and make use of the plural feature
tron
parents: 2187
diff changeset
   731
		gd.format_str_y_axis = STR_CURRCOMPACT;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   732
		gd.num_on_x_axis = 20;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   733
		gd.num_vert_lines = 20;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   734
		gd.month = 0xFF;
5771
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
   735
		gd.x_values_start     = 10;
1b62f1c3b266 (svn r8322) -Codechange: Rename unk61A and unk61C to something a little more descriptive.
maedhros
parents: 5768
diff changeset
   736
		gd.x_values_increment = 10;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   737
6192
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   738
		for (CargoID c = 0; c != NUM_CARGO; c++) {
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   739
			const CargoSpec *cs = GetCargo(c);
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   740
			if (!cs->IsValid()) continue;
4851
40e5c97799de (svn r6777) -GuiChange: When painting a lowered button on CargoPaymentsRates, displace the content of one pixel to the right and to the bottom. This will make it look like a normal button
belugas
parents: 4760
diff changeset
   741
6192
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   742
			/* Only draw labels for widgets that exist. If the widget doesn't
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   743
			 * exist then the local player has used the climate cheat or
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   744
			 * changed the NewGRF configuration with this window open. */
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   745
			if (i + 3 < w->widget_count) {
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   746
				/* Since the buttons have no text, no images,
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   747
				 * both the text and the colored box have to be manually painted.
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   748
				 * clk_dif will move one pixel down and one pixel to the right
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   749
				 * when the button is clicked */
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   750
				byte clk_dif = IsWindowWidgetLowered(w, i + 3) ? 1 : 0;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   751
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   752
				GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0);
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   753
				GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour);
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   754
				SetDParam(0, cs->name);
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   755
				DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, 0);
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   756
				y += 8;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   757
			}
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   758
6091
c8827d9ae04a (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 5946
diff changeset
   759
			gd.colors[i] = cs->legend_colour;
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   760
			for (j = 0; j != 20; j++) {
6192
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   761
				gd.cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 6 + 6, c);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   762
			}
6192
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   763
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   764
			i++;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   765
		}
6192
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   766
		gd.num_dataset = i;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   767
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   768
		DrawGraph(&gd);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   769
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   770
		DrawString(2 + 46, 24 + gd.height + 7, STR_7062_DAYS_IN_TRANSIT, 0);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   771
		DrawString(2 + 84, 24 - 9, STR_7063_PAYMENT_FOR_DELIVERING, 0);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   772
	} break;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   773
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   774
	case WE_CLICK: {
6192
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   775
		if (e->we.click.widget >= 3 && e->we.click.widget < (int)w->widget_count) {
5806
b35dcabd2e23 (svn r8368) -Cleanup: [Graphs] Rename the variables relating to whether datasets should be drawn, and use HASBIT for testing against them.
maedhros
parents: 5805
diff changeset
   776
			TOGGLEBIT(_legend_excluded_cargo, e->we.click.widget - 3);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   777
			ToggleWidgetLoweredState(w, e->we.click.widget);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   778
			SetWindowDirty(w);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   779
		}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   780
	} break;
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   781
	}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   782
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   783
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   784
static const Widget _cargo_payment_rates_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   785
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   786
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   567,     0,    13, STR_7061_CARGO_PAYMENT_RATES, STR_018C_WINDOW_TITLE_DRAG_THIS},
6192
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   787
{      WWT_PANEL, RESIZE_BOTTOM,    14,     0,   567,    14,    45, 0x0,                          STR_NULL},
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   788
{   WIDGETS_END},
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   789
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   790
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   791
static const WindowDesc _cargo_payment_rates_desc = {
6192
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   792
	WDP_AUTO, WDP_AUTO, 568, 46,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   793
	WC_PAYMENT_RATES, WC_NONE,
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   794
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   795
	_cargo_payment_rates_widgets,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   796
	CargoPaymentRatesWndProc
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   797
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   798
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   799
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1086
diff changeset
   800
void ShowCargoPaymentRates(void)
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   801
{
6192
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   802
	Window *w = AllocateWindowDescFront(&_cargo_payment_rates_desc, 0);
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   803
	if (w == NULL) return;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   804
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   805
	/* Count the number of active cargo types */
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   806
	uint num_active = 0;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   807
	for (CargoID c = 0; c != NUM_CARGO; c++) {
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   808
		if (GetCargo(c)->IsValid()) num_active++;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   809
	}
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   810
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   811
	/* Resize the window to fit the cargo types */
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   812
	ResizeWindow(w, 0, num_active * 8);
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   813
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   814
	/* Add widgets for each cargo type */
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   815
	w->widget_count = 3 + num_active;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   816
	w->widget = ReallocT(w->widget, w->widget_count);
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   817
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   818
	/* Set the properties of each widget */
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   819
	for (uint i = 0; i != num_active; i++) {
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   820
		Widget *wi = &w->widget[3 + i];
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   821
		wi->type     = WWT_PANEL;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   822
		wi->display_flags = RESIZE_NONE;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   823
		wi->color    = 12;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   824
		wi->left     = 493;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   825
		wi->right    = 562;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   826
		wi->top      = 24 + i * 8;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   827
		wi->bottom   = wi->top + 7;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   828
		wi->data     = 0;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   829
		wi->tooltips = STR_7064_TOGGLE_GRAPH_FOR_CARGO;
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   830
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   831
		if (!HASBIT(_legend_excluded_cargo, i)) LowerWindowWidget(w, i + 3);
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   832
	}
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   833
99324280e2ad (svn r8972) -Codechange: Dynamically add buttons on the cargo payment graph. This lets us remove the gaps and allow more than 12 cargo types later.
peter1138
parents: 6179
diff changeset
   834
	SetWindowDirty(w);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   835
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   836
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   837
/************************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   838
/* COMPANY LEAGUE TABLE */
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   839
/************************/
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   840
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   841
static const StringID _performance_titles[] = {
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   842
	STR_7066_ENGINEER,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   843
	STR_7066_ENGINEER,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   844
	STR_7067_TRAFFIC_MANAGER,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   845
	STR_7067_TRAFFIC_MANAGER,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   846
	STR_7068_TRANSPORT_COORDINATOR,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   847
	STR_7068_TRANSPORT_COORDINATOR,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   848
	STR_7069_ROUTE_SUPERVISOR,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   849
	STR_7069_ROUTE_SUPERVISOR,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   850
	STR_706A_DIRECTOR,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   851
	STR_706A_DIRECTOR,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   852
	STR_706B_CHIEF_EXECUTIVE,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   853
	STR_706B_CHIEF_EXECUTIVE,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   854
	STR_706C_CHAIRMAN,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   855
	STR_706C_CHAIRMAN,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   856
	STR_706D_PRESIDENT,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   857
	STR_706E_TYCOON,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   858
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   859
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   860
static inline StringID GetPerformanceTitleFromValue(uint value)
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   861
{
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   862
	return _performance_titles[minu(value, 1000) >> 6];
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   863
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   864
2656
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   865
static int CDECL PerfHistComp(const void* elem1, const void* elem2)
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   866
{
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   867
	const Player* p1 = *(const Player* const*)elem1;
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   868
	const Player* p2 = *(const Player* const*)elem2;
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   869
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   870
	return p2->old_economy[1].performance_history - p1->old_economy[1].performance_history;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   871
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   872
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   873
static void CompanyLeagueWndProc(Window *w, WindowEvent *e)
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   874
{
2482
374f6395847d (svn r3008) [ 1247535 ] Native Support for Win64 (compile&run only) (michi_cc)
Darkvater
parents: 2475
diff changeset
   875
	switch (e->event) {
2656
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   876
		case WE_PAINT: {
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   877
			const Player* plist[MAX_PLAYERS];
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   878
			const Player* p;
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   879
			uint pl_num;
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   880
			uint i;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   881
2656
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   882
			DrawWindowWidgets(w);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   883
2656
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   884
			pl_num = 0;
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   885
			FOR_ALL_PLAYERS(p) if (p->is_active) plist[pl_num++] = p;
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   886
2673
ff22d984097d (svn r3215) - Fix: warning on VS.NET 2003 complaining about constness reintroduced by revision 3192
Darkvater
parents: 2656
diff changeset
   887
			qsort((void*)plist, pl_num, sizeof(*plist), PerfHistComp);
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   888
2656
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   889
			for (i = 0; i != pl_num; i++) {
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   890
				p = plist[i];
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   891
				SetDParam(0, i + STR_01AC_1ST);
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   892
				SetDParam(1, p->name_1);
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   893
				SetDParam(2, p->name_2);
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   894
				SetDParam(3, GetPlayerNameString(p->index, 4));
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   895
				SetDParam(5, GetPerformanceTitleFromValue(p->old_economy[1].performance_history));
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   896
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   897
				DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, 0);
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   898
				DrawPlayerIcon(p->index, 27, 16 + i * 10);
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   899
			}
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   900
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   901
			break;
a27063f732cc (svn r3198) Rewrite the company league drawing routine for better readability
tron
parents: 2639
diff changeset
   902
		}
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   903
	}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   904
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   905
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   906
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   907
static const Widget _company_league_widgets[] = {
2869
c5ed60d34909 (svn r3417) - Make company league table window pinnable.
peter1138
parents: 2725
diff changeset
   908
{   WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,  0, 13, STR_00C5,                      STR_018B_CLOSE_WINDOW},
c5ed60d34909 (svn r3417) - Make company league table window pinnable.
peter1138
parents: 2725
diff changeset
   909
{    WWT_CAPTION, RESIZE_NONE, 14,  11, 387,  0, 13, STR_7053_COMPANY_LEAGUE_TABLE, STR_018C_WINDOW_TITLE_DRAG_THIS},
c5ed60d34909 (svn r3417) - Make company league table window pinnable.
peter1138
parents: 2725
diff changeset
   910
{  WWT_STICKYBOX, RESIZE_NONE, 14, 388, 399,  0, 13, STR_NULL,                      STR_STICKY_BUTTON},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   911
{      WWT_PANEL, RESIZE_NONE, 14,   0, 399, 14, 96, 0x0,                           STR_NULL},
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   912
{   WIDGETS_END},
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   913
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   914
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   915
static const WindowDesc _company_league_desc = {
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 4938
diff changeset
   916
	WDP_AUTO, WDP_AUTO, 400, 97,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
   917
	WC_COMPANY_LEAGUE, WC_NONE,
2869
c5ed60d34909 (svn r3417) - Make company league table window pinnable.
peter1138
parents: 2725
diff changeset
   918
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   919
	_company_league_widgets,
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   920
	CompanyLeagueWndProc
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   921
};
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   922
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1086
diff changeset
   923
void ShowCompanyLeagueTable(void)
1086
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   924
{
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   925
	AllocateWindowDescFront(&_company_league_desc,0);
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   926
}
adbaa5bda683 (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   927
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   928
/*****************************/
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   929
/* PERFORMANCE RATING DETAIL */
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   930
/*****************************/
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   931
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   932
static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   933
{
5946
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   934
	static PlayerID _performance_rating_detail_player = INVALID_PLAYER;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   935
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2869
diff changeset
   936
	switch (e->event) {
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   937
		case WE_PAINT: {
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   938
			byte x;
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
   939
			uint16 y = 14;
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   940
			int total_score = 0;
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   941
			int color_done, color_notdone;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   942
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
   943
			/* Draw standard stuff */
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   944
			DrawWindowWidgets(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   945
5946
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   946
			/* Check if the currently selected player is still active. */
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   947
			if (_performance_rating_detail_player == INVALID_PLAYER || !GetPlayer(_performance_rating_detail_player)->is_active) {
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   948
				if (_performance_rating_detail_player != INVALID_PLAYER) {
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   949
					/* Raise and disable the widget for the previous selection. */
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   950
					RaiseWindowWidget(w, _performance_rating_detail_player + 13);
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   951
					DisableWindowWidget(w, _performance_rating_detail_player + 13);
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   952
					SetWindowDirty(w);
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   953
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   954
					_performance_rating_detail_player = INVALID_PLAYER;
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   955
				}
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   956
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   957
				for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   958
					if (GetPlayer(i)->is_active) {
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   959
						/* Lower the widget corresponding to this player. */
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   960
						LowerWindowWidget(w, i + 13);
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   961
						SetWindowDirty(w);
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   962
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   963
						_performance_rating_detail_player = i;
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   964
						break;
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   965
					}
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   966
				}
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   967
			}
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   968
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   969
			/* If there are no active players, don't display anything else. */
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   970
			if (_performance_rating_detail_player == INVALID_PLAYER) break;
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   971
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
   972
			/* Paint the player icons */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   973
			for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   974
				if (!GetPlayer(i)->is_active) {
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
   975
					/* Check if we have the player as an active player */
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   976
					if (!IsWindowWidgetDisabled(w, i + 13)) {
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
   977
						/* Bah, player gone :( */
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   978
						DisableWindowWidget(w, i + 13);
5946
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   979
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
   980
						/* We need a repaint */
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   981
						SetWindowDirty(w);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   982
					}
5946
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
   983
					continue;
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   984
				}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   985
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
   986
				/* Check if we have the player marked as inactive */
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   987
				if (IsWindowWidgetDisabled(w, i + 13)) {
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
   988
					/* New player! Yippie :p */
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   989
					EnableWindowWidget(w, i + 13);
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
   990
					/* We need a repaint */
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   991
					SetWindowDirty(w);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   992
				}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   993
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   994
				x = (i == _performance_rating_detail_player) ? 1 : 0;
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   995
				DrawPlayerIcon(i, i * 37 + 13 + x, 16 + x);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   996
			}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
   997
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
   998
			/* The colors used to show how the progress is going */
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4365
diff changeset
   999
			color_done = _colour_gradient[COLOUR_GREEN][4];
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4365
diff changeset
  1000
			color_notdone = _colour_gradient[COLOUR_RED][4];
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1001
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1002
			/* Draw all the score parts */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1003
			for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) {
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1004
				int val    = _score_part[_performance_rating_detail_player][i];
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1005
				int needed = _score_info[i].needed;
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1006
				int score  = _score_info[i].score;
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1007
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1008
				y += 20;
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1009
				/* SCORE_TOTAL has his own rulez ;) */
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1010
				if (i == SCORE_TOTAL) {
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1011
					needed = total_score;
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1012
					score = SCORE_MAX;
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1013
				} else {
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1014
					total_score += score;
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1015
				}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1016
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1017
				DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, 0);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1018
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1019
				/* Draw the score */
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1020
				SetDParam(0, score);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1021
				DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1022
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1023
				/* Calculate the %-bar */
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1024
				if (val > needed) {
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1025
					x = 50;
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1026
				} else if (val == 0) {
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1027
					x = 0;
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1028
				} else {
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1029
					x = val * 50 / needed;
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1030
				}
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1031
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1032
				/* SCORE_LOAN is inversed */
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1033
				if (val < 0 && i == SCORE_LOAN) x = 0;
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1034
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1035
				/* Draw the bar */
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1036
				if (x !=  0) GfxFillRect(112,     y - 2, 112 + x,  y + 10, color_done);
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1037
				if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone);
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1038
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1039
				/* Calculate the % */
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1040
				x = (val <= needed) ? val * 100 / needed : 100;
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1041
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1042
				/* SCORE_LOAN is inversed */
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1043
				if (val < 0 && i == SCORE_LOAN) x = 0;
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1044
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1045
				/* Draw it */
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1046
				SetDParam(0, x);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1047
				DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, 0);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1048
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1049
				/* SCORE_LOAN is inversed */
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1050
				if (i == SCORE_LOAN) val = needed - val;
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1051
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1052
				/* Draw the amount we have against what is needed
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1053
				 * For some of them it is in currency format */
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1054
				SetDParam(0, val);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1055
				SetDParam(1, needed);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1056
				switch (i) {
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1057
					case SCORE_MIN_PROFIT:
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1058
					case SCORE_MIN_INCOME:
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1059
					case SCORE_MAX_INCOME:
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1060
					case SCORE_MONEY:
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1061
					case SCORE_LOAN:
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1062
						DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, 0);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1063
						break;
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1064
					default:
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1065
						DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, 0);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1066
				}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1067
			}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1068
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1069
			break;
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1070
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1071
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1072
		case WE_CLICK:
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1073
			/* Check which button is clicked */
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4444
diff changeset
  1074
			if (IS_INT_INSIDE(e->we.click.widget, 13, 21)) {
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1075
				/* Is it no on disable? */
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
  1076
				if (!IsWindowWidgetDisabled(w, e->we.click.widget)) {
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1077
					RaiseWindowWidget(w, _performance_rating_detail_player + 13);
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1078
					_performance_rating_detail_player = (PlayerID)(e->we.click.widget - 13);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1079
					LowerWindowWidget(w, _performance_rating_detail_player + 13);
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1080
					SetWindowDirty(w);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1081
				}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1082
			}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1083
			break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1084
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1085
		case WE_CREATE: {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1086
			PlayerID i;
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1087
			Player *p2;
4702
c79e9d9f27b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4634
diff changeset
  1088
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
  1089
			/* Disable the players who are not active */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1090
			for (i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
  1091
				SetWindowWidgetDisabledState(w, i + 13, !GetPlayer(i)->is_active);
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1092
			}
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1093
			/* Update all player stats with the current data
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1094
			 * (this is because _score_info is not saved to a savegame) */
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1095
			FOR_ALL_PLAYERS(p2) {
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1096
				if (p2->is_active) UpdateCompanyRatingAndValue(p2, false);
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1097
			}
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1098
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1099
			w->custom[0] = DAY_TICKS;
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1100
			w->custom[1] = 5;
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1101
5946
ae3b1567b5d5 (svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
maedhros
parents: 5893
diff changeset
  1102
			if (_performance_rating_detail_player != INVALID_PLAYER) LowerWindowWidget(w, _performance_rating_detail_player + 13);
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1103
			SetWindowDirty(w);
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1104
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1105
			break;
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1106
		}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1107
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1108
		case WE_TICK: {
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1109
			/* Update the player score every 5 days */
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1110
			if (--w->custom[0] == 0) {
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1111
				w->custom[0] = DAY_TICKS;
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1112
				if (--w->custom[1] == 0) {
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1113
					Player *p2;
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1114
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1115
					w->custom[1] = 5;
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1116
					FOR_ALL_PLAYERS(p2) {
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6091
diff changeset
  1117
						/* Skip if player is not active */
3033
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1118
						if (p2->is_active) UpdateCompanyRatingAndValue(p2, false);
9cba043eb38f (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 3027
diff changeset
  1119
					}
3027
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1120
					SetWindowDirty(w);
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1121
				}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1122
			}
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1123
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1124
			break;
d2ebfd04bb77 (svn r3607) - Fix indenting of PerformanceRatingDetailWndProc()
peter1138
parents: 2952
diff changeset
  1125
		}
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1126
	}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1127
}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1128
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1129
static const Widget _performance_rating_detail_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
  1130
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
  1131
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   298,     0,    13, STR_PERFORMANCE_DETAIL, STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1132
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    14,    27, 0x0,                    STR_NULL},
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1133
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1134
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    28,    47, 0x0,                    STR_PERFORMANCE_DETAIL_VEHICLES_TIP},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1135
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    48,    67, 0x0,                    STR_PERFORMANCE_DETAIL_STATIONS_TIP},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1136
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    68,    87, 0x0,                    STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1137
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    88,   107, 0x0,                    STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1138
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   108,   127, 0x0,                    STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1139
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   128,   147, 0x0,                    STR_PERFORMANCE_DETAIL_DELIVERED_TIP},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1140
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   148,   167, 0x0,                    STR_PERFORMANCE_DETAIL_CARGO_TIP},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1141
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   168,   187, 0x0,                    STR_PERFORMANCE_DETAIL_MONEY_TIP},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1142
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   188,   207, 0x0,                    STR_PERFORMANCE_DETAIL_LOAN_TIP},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1143
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   208,   227, 0x0,                    STR_PERFORMANCE_DETAIL_TOTAL_TIP},
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1144
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1145
{      WWT_PANEL,   RESIZE_NONE,    14,     2,    38,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1146
{      WWT_PANEL,   RESIZE_NONE,    14,    39,    75,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1147
{      WWT_PANEL,   RESIZE_NONE,    14,    76,   112,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1148
{      WWT_PANEL,   RESIZE_NONE,    14,   113,   149,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1149
{      WWT_PANEL,   RESIZE_NONE,    14,   150,   186,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1150
{      WWT_PANEL,   RESIZE_NONE,    14,   187,   223,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1151
{      WWT_PANEL,   RESIZE_NONE,    14,   224,   260,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1152
{      WWT_PANEL,   RESIZE_NONE,    14,   261,   297,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 165
diff changeset
  1153
{   WIDGETS_END},
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1154
};
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1155
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1156
static const WindowDesc _performance_rating_detail_desc = {
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 4938
diff changeset
  1157
	WDP_AUTO, WDP_AUTO, 299, 228,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5812
diff changeset
  1158
	WC_PERFORMANCE_DETAIL, WC_NONE,
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1159
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1160
	_performance_rating_detail_widgets,
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1161
	PerformanceRatingDetailWndProc
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1162
};
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1163
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1086
diff changeset
  1164
void ShowPerformanceRatingDetail(void)
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1165
{
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1166
	AllocateWindowDescFront(&_performance_rating_detail_desc, 0);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1167
}