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