graph_gui.c
author truelight
Sat, 26 Mar 2005 21:22:29 +0000
changeset 1575 a566a645401f
parent 1130 236aa7efbe7a
child 1891 92a3b0aa0946
permissions -rw-r--r--
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
to the sign. Very needed for coop. You can find it under World Map.
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     1
#include "stdafx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     2
#include "ttd.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 410
diff changeset
     3
#include "table/strings.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     4
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "player.h"
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
     8
#include "economy.h"
1575
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
     9
#include "signs.h"
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    10
#include "strings.h"
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    11
#include "debug.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
    13
static uint _legend_excludebits;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
static uint _legend_cargobits;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
/************************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
/* GENERIC GRAPH DRAWER */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
/************************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
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
    20
enum {GRAPH_NUM = 16};
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
    21
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
typedef struct GraphDrawer {
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
    23
	uint sel; // bitmask of the players *excluded* (e.g. 11111111 means that no players are shown)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
	byte num_dataset;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
	byte num_on_x_axis;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
	byte month;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
	byte year;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
	bool include_neg;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
	byte num_vert_lines;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
	uint16 unk61A;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
	uint16 unk61C;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
	int left, top;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
	uint height;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
	StringID format_str_y_axis;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
	byte color_3, color_2, bg_line_color;
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
    36
	byte colors[GRAPH_NUM];
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
    37
	uint64 cost[GRAPH_NUM][24]; // last 2 years
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
} GraphDrawer;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
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
#define INVALID_VALUE 0x80000000
da0ae9d977e0 (svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents: 222
diff changeset
    41
410
8de2aaf20800 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 240
diff changeset
    42
static void DrawGraph(GraphDrawer *gw)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
{
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    44
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
	int i,j,k;
1130
236aa7efbe7a (svn r1631) A couple of fixes for the signed/unsigned warnings. Only train_cmd.c remains to need fixing...
dominik
parents: 1093
diff changeset
    46
	uint x,y,old_x,old_y;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
	int color;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
	int right, bottom;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
	int num_x, num_dataset;
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
    50
	uint64 *row_ptr, *col_ptr;
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
    51
	int64 mx;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
	int adj_height;
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
    53
	uint64 y_scaling, tmp;
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
    54
	int64 value;
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
    55
	int64 cur_val;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	uint sel;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
240
f1efbac04112 (svn r241) -Fix: Trailing spaces :O
darkvater
parents: 236
diff changeset
    58
	/* 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
    59
	 * both values for cargo and players. So if any are higher, quit */
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
    60
	assert(GRAPH_NUM >= NUM_CARGO && GRAPH_NUM >= MAX_PLAYERS);
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
    61
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
	color = _color_list[gw->bg_line_color].window_color_1b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
	/* draw the vertical lines */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
	i = gw->num_vert_lines; assert(i > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
	x = gw->left + 66;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
	bottom = gw->top + gw->height - 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
	do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
		GfxFillRect(x, gw->top, x, bottom, color);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
		x += 22;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
	} while (--i);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    72
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
	/* draw the horizontal lines */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
	i = 9;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
	x = gw->left + 44;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
	y = gw->height + gw->top;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
	right = gw->left + 44 + gw->num_vert_lines*22-1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
	do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
		GfxFillRect(x, y, right, y, color);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
		y -= gw->height >> 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
	} while (--i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
	/* draw vertical edge line */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
	GfxFillRect(x, gw->top, x, bottom, gw->color_2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	adj_height = gw->height;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
	if (gw->include_neg) adj_height >>= 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	/* draw horiz edge line */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
	y = adj_height + gw->top;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	GfxFillRect(x, y, right, y, gw->color_2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	/* find the max element */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	if (gw->num_on_x_axis == 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
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
    98
	num_dataset = gw->num_dataset;
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
    99
	assert(num_dataset > 0);
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
   100
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
	row_ptr = gw->cost[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
	mx = 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
   103
		/* bit selection for the showing of various players, base max element
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
   104
		 * on to-be shown player-information. This way the graph can scale */
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
   105
	sel = gw->sel;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
	do {
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
   107
		if (!(sel&1)) {
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
   108
			num_x = gw->num_on_x_axis;
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
   109
			assert(num_x > 0);
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
   110
			col_ptr = row_ptr;
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
   111
			do {
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
   112
				if (*col_ptr != INVALID_VALUE) {
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
   113
					mx = max64(mx, myabs64(*col_ptr));
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
   114
				}
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
   115
			} while (col_ptr++, --num_x);
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
   116
		}
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
   117
	} while (sel>>=1, row_ptr+=24, --num_dataset);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   118
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	/* setup scaling */
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
   120
	y_scaling = INVALID_VALUE;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
	value = adj_height * 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
	if (mx > value) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
		mx = (mx + 7) & ~7;
236
da0ae9d977e0 (svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents: 222
diff changeset
   125
		y_scaling = (((uint64) (value>>1) << 32) / mx);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
		value = mx;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
	/* draw text strings on the y axis */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
	tmp = value;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
	if (gw->include_neg) tmp >>= 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
	x = gw->left + 45;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
	y = gw->top - 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
	i = 9;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	do {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   136
		SetDParam(0, gw->format_str_y_axis);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   137
		SetDParam64(1, (int64)tmp);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
		tmp -= (value >> 3);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
		DrawStringRightAligned(x, y, STR_0170, gw->color_3);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
		y += gw->height >> 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
	} while (--i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
	/* draw strings on the x axis */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
	if (gw->month != 0xFF) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
		x = gw->left + 44;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
		y = gw->top + gw->height + 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
		j = gw->month;
970
492ca84ecc6c (svn r1465) -Fix: [1099101] starting year patch goes out of range. Clamped year between 1920-2090 as wel as adding defines for it.
darkvater
parents: 867
diff changeset
   148
		k = gw->year + MAX_YEAR_BEGIN_REAL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
		i = gw->num_on_x_axis;assert(i>0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
		do {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   151
			SetDParam(2, k);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   152
			SetDParam(0, j + STR_0162_JAN);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   153
			SetDParam(1, j + STR_0162_JAN + 2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
			DrawString(x, y, j == 0 ? STR_016F : STR_016E, gw->color_3);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
			j += 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
			if (j >= 12) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
				j = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
				k++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
			x += 22;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
		} while (--i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
		x = gw->left + 52;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
		y = gw->top + gw->height + 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
		j = gw->unk61A;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
		i = gw->num_on_x_axis;assert(i>0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
		do {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   169
			SetDParam(0, j);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
			DrawString(x, y, STR_01CB, gw->color_3);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
			j += gw->unk61C;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
			x += 22;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
		} while (--i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
	/* draw lines and dots */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
	i = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
	row_ptr = gw->cost[0];
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   179
	sel = gw->sel; // show only selected lines. GraphDrawer qw->sel set in Graph-Legend (_legend_excludebits)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
	do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
		if (!(sel & 1)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
			x = gw->left + 55;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
			j = gw->num_on_x_axis;assert(j>0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
			col_ptr = row_ptr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
			color = gw->colors[i];
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
   186
			old_y = old_x = INVALID_VALUE;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
				cur_val = *col_ptr++;
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
   189
				if (cur_val != INVALID_VALUE) {
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
   190
					y = adj_height - BIGMULSS64(cur_val, y_scaling >> 1, 31) + gw->top;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
					GfxFillRect(x-1, y-1, x+1, y+1, color);
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
   193
					if (old_x != INVALID_VALUE)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
						GfxDrawLine(old_x, old_y, x, y, color);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
					old_x = x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
					old_y = y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
				} else {
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
   199
					old_x = INVALID_VALUE;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
			} while (x+=22,--j);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
	} while (sel>>=1,row_ptr+=24, ++i < gw->num_dataset);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
/* GRAPH LEGEND */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
void DrawPlayerIcon(int p, int x, int y)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
	DrawSprite(SPRITE_PALETTE(PLAYER_SPRITE_COLOR(p) + 0x2EB), x, y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
static void GraphLegendWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
	Player *p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
		FOR_ALL_PLAYERS(p) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
			if (!p->is_active)
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   223
				SETBIT(_legend_excludebits, p->index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
		}
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   225
		w->click_state = ((~_legend_excludebits) << 3);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
		FOR_ALL_PLAYERS(p) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
			if (!p->is_active)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
				continue;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
			DrawPlayerIcon(p->index, 4, 18+p->index*12);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   234
			SetDParam(0, p->name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   235
			SetDParam(1, p->name_2);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   236
			SetDParam(2, GetPlayerNameString(p->index, 3));
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   237
			DrawString(21,17+p->index*12,STR_7021,HASBIT(_legend_excludebits, p->index) ? 0x10 : 0xC);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
		break;
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
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
		if (IS_INT_INSIDE(e->click.widget, 3, 11)) {
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   243
			_legend_excludebits ^= (1 << (e->click.widget-3));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
			InvalidateWindow(WC_INCOME_GRAPH, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
			InvalidateWindow(WC_OPERATING_PROFIT, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
			InvalidateWindow(WC_DELIVERED_CARGO, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
			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
   249
			InvalidateWindow(WC_COMPANY_VALUE, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
static const Widget _graph_legend_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   256
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5, STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   257
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   249,     0,    13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   258
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   249,    14,   113, 0x0,STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   259
{     WWT_IMGBTN,   RESIZE_NONE,    14,     2,   247,    16,    27, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   260
{     WWT_IMGBTN,   RESIZE_NONE,    14,     2,   247,    28,    39, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   261
{     WWT_IMGBTN,   RESIZE_NONE,    14,     2,   247,    40,    51, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   262
{     WWT_IMGBTN,   RESIZE_NONE,    14,     2,   247,    52,    63, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   263
{     WWT_IMGBTN,   RESIZE_NONE,    14,     2,   247,    64,    75, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   264
{     WWT_IMGBTN,   RESIZE_NONE,    14,     2,   247,    76,    87, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   265
{     WWT_IMGBTN,   RESIZE_NONE,    14,     2,   247,    88,    99, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   266
{     WWT_IMGBTN,   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
   267
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
static const WindowDesc _graph_legend_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
	-1, -1, 250, 114,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
	WC_GRAPH_LEGEND,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
	_graph_legend_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
	GraphLegendWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
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
   278
static void ShowGraphLegend(void)
0
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
	AllocateWindowDescFront(&_graph_legend_desc, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
/********************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
/* OPERATING PROFIT */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
/********************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
static void SetupGraphDrawerForPlayers(GraphDrawer *gd)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
	Player *p;
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   290
	uint excludebits = _legend_excludebits;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
	int nums;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
	int mo,yr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   294
	// Exclude the players which aren't valid
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
	FOR_ALL_PLAYERS(p) {
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   296
		if (!p->is_active) SETBIT(excludebits,p->index);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   297
	}
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   298
	gd->sel = excludebits;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
	gd->num_vert_lines = 24;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
	nums = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
	FOR_ALL_PLAYERS(p) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
		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
   304
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
	gd->num_on_x_axis = min(nums,24);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
	mo = (_cur_month/3-nums)*3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
	yr = _cur_year;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
	while (mo < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
		yr--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
		mo += 12;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
	gd->year = yr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
	gd->month = mo;
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
static void OperatingProfitWndProc(Window *w, WindowEvent *e)
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
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
		GraphDrawer gd;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
		Player *p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
		int i,j;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
		int numd;
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
		DrawWindowWidgets(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   328
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
		gd.left = 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
		gd.top = 18;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
		gd.height = 136;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
		gd.include_neg = true;
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
   333
		gd.format_str_y_axis = STR_CURRCOMPACT32;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
		gd.color_3 = 0x10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
		gd.color_2 = 0xD7;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
		gd.bg_line_color = 0xE;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   337
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
		SetupGraphDrawerForPlayers(&gd);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
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
   340
		numd = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
		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
   342
			if (p->is_active) {
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   343
				gd.colors[numd] = _color_list[p->player_color].window_color_bgb;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   344
				for(j=gd.num_on_x_axis,i=0; --j >= 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
   345
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)(p->old_economy[j].income + p->old_economy[j].expenses);
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   346
					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
   347
				}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   348
			}
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   349
			numd++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
		}
1085
408f95e1b70a (svn r1586) Fix: [ 1107340 ] Graphs don't show comapany info for company #8
dominik
parents: 1079
diff changeset
   351
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
   352
		gd.num_dataset = numd;
0
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
		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
   355
	}	break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
	case WE_CLICK:
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
   357
		if (e->click.widget == 2) /* Clicked on Legend */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
			ShowGraphLegend();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
static const Widget _operating_profit_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   364
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,												STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   365
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7025_OPERATING_PROFIT_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   366
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,										STR_704D_SHOW_KEY_TO_GRAPHS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   367
{     WWT_IMGBTN,   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
   368
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
static const WindowDesc _operating_profit_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
	-1, -1, 576, 174,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
	WC_OPERATING_PROFIT,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
	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
   375
	_operating_profit_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
	OperatingProfitWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
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
   380
void ShowOperatingProfitGraph(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
	if (AllocateWindowDescFront(&_operating_profit_desc, 0)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
/****************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   389
/* INCOME GRAPH */
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
static void IncomeGraphWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
		GraphDrawer gd;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
		Player *p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
		int i,j;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
		int numd;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
		gd.left = 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
		gd.top = 18;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
		gd.height = 104;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
		gd.include_neg = false;
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
   407
		gd.format_str_y_axis = STR_CURRCOMPACT32;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
		gd.color_3 = 0x10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
		gd.color_2 = 0xD7;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
		gd.bg_line_color = 0xE;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
		SetupGraphDrawerForPlayers(&gd);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
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
   413
		numd = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
		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
   415
			if (p->is_active) {
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   416
				gd.colors[numd] = _color_list[p->player_color].window_color_bgb;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   417
				for(j=gd.num_on_x_axis,i=0; --j >= 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
   418
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].income;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   419
					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
   420
				}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   421
			}
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   422
			numd++;
0
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
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
   425
		gd.num_dataset = numd;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
		DrawGraph(&gd);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
		if (e->click.widget == 2)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
			ShowGraphLegend();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   434
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   435
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
}
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
static const Widget _income_graph_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   439
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   440
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7022_INCOME_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   441
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,					STR_704D_SHOW_KEY_TO_GRAPHS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   442
{     WWT_IMGBTN,   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
   443
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
static const WindowDesc _income_graph_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
	-1, -1, 576, 142,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
	WC_INCOME_GRAPH,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
	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
   450
	_income_graph_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
	IncomeGraphWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
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
   454
void ShowIncomeGraph(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
	if (AllocateWindowDescFront(&_income_graph_desc, 0)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   459
}
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
/*******************/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
/* DELIVERED CARGO */
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
static void DeliveredCargoGraphWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
		GraphDrawer gd;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
		Player *p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
		int i,j;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
		int numd;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
		gd.left = 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
		gd.top = 18;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
		gd.height = 104;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
		gd.include_neg = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
		gd.format_str_y_axis = STR_7024;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
		gd.color_3 = 0x10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
		gd.color_2 = 0xD7;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
		gd.bg_line_color = 0xE;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
		SetupGraphDrawerForPlayers(&gd);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
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
   486
		numd = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
		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
   488
			if (p->is_active) {
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   489
				gd.colors[numd] = _color_list[p->player_color].window_color_bgb;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   490
				for(j=gd.num_on_x_axis,i=0; --j >= 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
   491
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].delivered_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
   492
					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
   493
				}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   494
			}
1079
d6da6dc920a4 (svn r1580) Fix: [ 1106354 ] Graph's keys get confused
dominik
parents: 983
diff changeset
   495
			numd++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
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
   498
		gd.num_dataset = numd;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
		DrawGraph(&gd);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
		if (e->click.widget == 2)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
			ShowGraphLegend();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   509
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
static const Widget _delivered_cargo_graph_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   512
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,													STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   513
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7050_UNITS_OF_CARGO_DELIVERED, STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   514
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,											STR_704D_SHOW_KEY_TO_GRAPHS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
   515
{     WWT_IMGBTN,   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
   516
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
static const WindowDesc _delivered_cargo_graph_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
	-1, -1, 576, 142,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
	WC_DELIVERED_CARGO,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
	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
   523
	_delivered_cargo_graph_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
	DeliveredCargoGraphWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
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
   527
void ShowDeliveredCargoGraph(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
	if (AllocateWindowDescFront(&_delivered_cargo_graph_desc, 0)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
	}
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   532
}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   533
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
   534
/***********************/
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   535
/* 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
   536
/***********************/
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   537
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   538
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
   539
{
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   540
	switch(e->event) {
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   541
	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
   542
		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
   543
		Player *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
   544
		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
   545
		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
   546
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   547
		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
   548
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   549
		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
   550
		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
   551
		gd.height = 200;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   552
		gd.include_neg = false;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   553
		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
   554
		gd.color_3 = 0x10;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   555
		gd.color_2 = 0xD7;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   556
		gd.bg_line_color = 0xE;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   557
		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
   558
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   559
		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
   560
		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
   561
			if (p->is_active) {
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   562
				gd.colors[numd] = _color_list[p->player_color].window_color_bgb;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   563
				for(j=gd.num_on_x_axis,i=0; --j >= 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
   564
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].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
   565
					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
   566
				}
9d00ef71146e (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
			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
   569
		}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   570
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   571
		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
   572
9d00ef71146e (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
		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
   574
		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
   575
	}
9d00ef71146e (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
9d00ef71146e (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
	case WE_CLICK:
9d00ef71146e (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
		if (e->click.widget == 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
   579
			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
   580
		if (e->click.widget == 3)
9d00ef71146e (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
			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
   582
		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
   583
	}
9d00ef71146e (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
}
9d00ef71146e (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
9d00ef71146e (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
static const Widget _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
   587
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,															STR_018B_CLOSE_WINDOW},
9d00ef71146e (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
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   475,     0,    13, STR_7051_COMPANY_PERFORMANCE_RATINGS,	STR_018C_WINDOW_TITLE_DRAG_THIS},
9d00ef71146e (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
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,													STR_704D_SHOW_KEY_TO_GRAPHS},
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   590
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   476,   525,     0,    13, STR_PERFORMANCE_DETAIL_KEY,						STR_704D_SHOW_KEY_TO_GRAPHS},
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   591
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   575,    14,   237, 0x0,																		STR_NULL},
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   592
{   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
   593
};
9d00ef71146e (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
static const WindowDesc _performance_history_desc = {
9d00ef71146e (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
	-1, -1, 576, 238,
9d00ef71146e (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
	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
   598
	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
   599
	_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
   600
	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
   601
};
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   602
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
   603
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
   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
	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
   606
		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
   607
	}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   608
}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   609
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   610
/*****************/
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   611
/* 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
   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 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
   615
{
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   616
	switch(e->event) {
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   617
	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
   618
		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
   619
		Player *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
   620
		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
   621
		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
   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
		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
   624
9d00ef71146e (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
		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
   626
		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
   627
		gd.height = 200;
9d00ef71146e (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
		gd.include_neg = false;
9d00ef71146e (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
		gd.format_str_y_axis = STR_CURRCOMPACT64;
9d00ef71146e (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
		gd.color_3 = 0x10;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   631
		gd.color_2 = 0xD7;
9d00ef71146e (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
		gd.bg_line_color = 0xE;
9d00ef71146e (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
		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
   634
9d00ef71146e (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
		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
   636
		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
   637
			if (p->is_active) {
9d00ef71146e (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
				gd.colors[numd] = _color_list[p->player_color].window_color_bgb;
9d00ef71146e (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
				for(j=gd.num_on_x_axis,i=0; --j >= 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
   640
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].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
   641
					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
   642
				}
9d00ef71146e (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
			}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   644
			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
   645
		}
9d00ef71146e (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
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   647
		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
   648
9d00ef71146e (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
		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
   650
		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
   651
	}
9d00ef71146e (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
	case WE_CLICK:
9d00ef71146e (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
		if (e->click.widget == 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
   655
			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
   656
		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
   657
	}
9d00ef71146e (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
}
9d00ef71146e (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
static const Widget _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
   661
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,								STR_018B_CLOSE_WINDOW},
9d00ef71146e (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
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7052_COMPANY_VALUES,	STR_018C_WINDOW_TITLE_DRAG_THIS},
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   663
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,						STR_704D_SHOW_KEY_TO_GRAPHS},
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   664
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   575,    14,   237, 0x0,											STR_NULL},
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   665
{   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
   666
};
9d00ef71146e (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
static const WindowDesc _company_value_graph_desc = {
9d00ef71146e (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
	-1, -1, 576, 238,
9d00ef71146e (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
	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
   671
	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
   672
	_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
   673
	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
   674
};
9d00ef71146e (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
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
   676
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
   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
	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
   679
		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
   680
	}
9d00ef71146e (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
}
9d00ef71146e (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
/* 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
   685
/*****************/
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   686
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   687
static const byte _cargo_legend_colors[12] = {152, 32, 15, 174, 208, 194, 191, 84, 184, 10, 202, 215};
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   688
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   689
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
   690
{
9d00ef71146e (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
	switch(e->event) {
9d00ef71146e (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
	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
   693
		int i, j, x, y;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   694
		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
   695
9d00ef71146e (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
		gd.sel = _legend_cargobits;
9d00ef71146e (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
		w->click_state = (~_legend_cargobits) << 3;
9d00ef71146e (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
		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
   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
		x = 495;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   701
		y = 25;
9d00ef71146e (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
		for(i=0; i!=NUM_CARGO; 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
   704
			GfxFillRect(x, y, x+8, y+5, 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
			GfxFillRect(x+1, y+1, x+7, y+4, _cargo_legend_colors[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
   706
			SetDParam(0, _cargoc.names_s[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
   707
			DrawString(x+14, y, STR_7065, 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
   708
			y += 8;
9d00ef71146e (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
		}
9d00ef71146e (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
		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
   712
		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
   713
		gd.height = 104;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   714
		gd.include_neg = false;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   715
		gd.format_str_y_axis = STR_CURRCOMPACT32;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   716
		gd.color_3 = 16;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   717
		gd.color_2 = 215;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   718
		gd.bg_line_color = 14;
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   719
		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
   720
		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
   721
		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
   722
		gd.month = 0xFF;
9d00ef71146e (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
		gd.unk61A = 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
   724
		gd.unk61C = 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
   725
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   726
		for(i=0; i!=NUM_CARGO; 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
   727
			gd.colors[i] = _cargo_legend_colors[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
   728
			for(j=0; j!=20; 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
   729
				gd.cost[i][j] = (uint64)GetTransportedGoodsIncome(10, 20, j*6+6,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
   730
			}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   731
		}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   732
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   733
		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
   734
9d00ef71146e (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
		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
   736
		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
   737
	} 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
   738
9d00ef71146e (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
	case WE_CLICK: {
9d00ef71146e (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
		switch(e->click.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
   741
		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
   742
		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
   743
		case 11: case 12: case 13: case 14:
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   744
			_legend_cargobits ^= 1 << (e->click.widget - 3);
9d00ef71146e (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
			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
   746
			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
   747
		}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   748
	} 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
   749
	}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   750
}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   751
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   752
static const Widget _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
   753
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,											STR_018B_CLOSE_WINDOW},
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   754
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   567,     0,    13, STR_7061_CARGO_PAYMENT_RATES,	STR_018C_WINDOW_TITLE_DRAG_THIS},
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   755
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   567,    14,   141, 0x0,														STR_NULL},
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   756
{      WWT_PANEL,   RESIZE_NONE,    12,   493,   562,    24,    31, 0x0,														STR_7064_TOGGLE_GRAPH_FOR_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
   757
{      WWT_PANEL,   RESIZE_NONE,    12,   493,   562,    32,    39, 0x0,														STR_7064_TOGGLE_GRAPH_FOR_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
   758
{      WWT_PANEL,   RESIZE_NONE,    12,   493,   562,    40,    47, 0x0,														STR_7064_TOGGLE_GRAPH_FOR_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
   759
{      WWT_PANEL,   RESIZE_NONE,    12,   493,   562,    48,    55, 0x0,														STR_7064_TOGGLE_GRAPH_FOR_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
   760
{      WWT_PANEL,   RESIZE_NONE,    12,   493,   562,    56,    63, 0x0,														STR_7064_TOGGLE_GRAPH_FOR_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
   761
{      WWT_PANEL,   RESIZE_NONE,    12,   493,   562,    64,    71, 0x0,														STR_7064_TOGGLE_GRAPH_FOR_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
   762
{      WWT_PANEL,   RESIZE_NONE,    12,   493,   562,    72,    79, 0x0,														STR_7064_TOGGLE_GRAPH_FOR_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
   763
{      WWT_PANEL,   RESIZE_NONE,    12,   493,   562,    80,    87, 0x0,														STR_7064_TOGGLE_GRAPH_FOR_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
   764
{      WWT_PANEL,   RESIZE_NONE,    12,   493,   562,    88,    95, 0x0,														STR_7064_TOGGLE_GRAPH_FOR_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
   765
{      WWT_PANEL,   RESIZE_NONE,    12,   493,   562,    96,   103, 0x0,														STR_7064_TOGGLE_GRAPH_FOR_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
   766
{      WWT_PANEL,   RESIZE_NONE,    12,   493,   562,   104,   111, 0x0,														STR_7064_TOGGLE_GRAPH_FOR_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
   767
{      WWT_PANEL,   RESIZE_NONE,    12,   493,   562,   112,   119, 0x0,														STR_7064_TOGGLE_GRAPH_FOR_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
   768
{   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
   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
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   771
static const WindowDesc _cargo_payment_rates_desc = {
9d00ef71146e (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
	-1, -1, 568, 142,
9d00ef71146e (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
	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
   774
	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
   775
	_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
   776
	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
   777
};
9d00ef71146e (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
9d00ef71146e (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
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
   780
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
   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
	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
   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
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   785
/************************/
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   786
/* 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
   787
/************************/
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   788
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   789
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
   790
	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
   791
	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
   792
	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
   793
	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
   794
	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
   795
	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
   796
	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
   797
	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
   798
	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
   799
	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
   800
	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
   801
	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
   802
	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
   803
	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
   804
	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
   805
	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
   806
};
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   807
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   808
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
   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
	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
   811
}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   812
9d00ef71146e (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
static int CDECL _perf_hist_comp(const void *elem1, const void *elem2 ) {
9d00ef71146e (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
	const Player *p1 = *(const Player* const *)elem1;
9d00ef71146e (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
	const Player *p2 = *(const Player* const *)elem2;
9d00ef71146e (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
	int32 v = p2->old_economy[1].performance_history - p1->old_economy[1].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
   817
	return (v!=0) | (v >> (sizeof(int32)*8-1));
9d00ef71146e (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
}
9d00ef71146e (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
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
   821
{
9d00ef71146e (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
	switch(e->event) {
9d00ef71146e (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
	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
   824
		Player *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
   825
		Player *plist[MAX_PLAYERS];
9d00ef71146e (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
		size_t pl_num, 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
   827
9d00ef71146e (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
		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
   829
9d00ef71146e (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
		pl_num=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
   831
		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
   832
			if (p->is_active)
9d00ef71146e (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
				plist[pl_num++] = 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
   834
		}
9d00ef71146e (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
		assert(pl_num > 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
   836
9d00ef71146e (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
		qsort(plist, pl_num, sizeof(Player*), _perf_hist_comp);
9d00ef71146e (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
		i = 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
   840
		do {
9d00ef71146e (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
			SetDParam(0, i + 1 + STR_01AB);
9d00ef71146e (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
			p = plist[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
   843
			SetDParam(1, p->name_1);
9d00ef71146e (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
			SetDParam(2, p->name_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
   845
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   846
			SetDParam(3, GetPlayerNameString(p->index, 4));
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   847
			/*	WARNING ugly hack!
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   848
					GetPlayerNameString sets up (Player #) if the player is human in an extra DPARAM16
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   849
					It seems that if player is non-human, nothing is set up, so param is 0. GetString doesn't like
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   850
					that because there is another param after it.
9d00ef71146e (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
					So we'll just shift the rating one back if player is AI and all is fine
9d00ef71146e (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
			SetDParam((IS_HUMAN_PLAYER(p->index) ? 5 : 4), GetPerformanceTitleFromValue(p->old_economy[1].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
   854
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   855
			DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, 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
   856
			DrawPlayerIcon(p->index, 27, 16 + i * 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
   857
		} while (++i != pl_num);
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   858
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   859
		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
   860
	}
9d00ef71146e (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
	}
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   862
}
9d00ef71146e (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
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   864
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   865
static const Widget _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
   866
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,											STR_018B_CLOSE_WINDOW},
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   867
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   399,     0,    13, STR_7053_COMPANY_LEAGUE_TABLE,	STR_018C_WINDOW_TITLE_DRAG_THIS},
9d00ef71146e (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
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   399,    14,    96, 0x0,														STR_NULL},
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   869
{   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
   870
};
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   871
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   872
static const WindowDesc _company_league_desc = {
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   873
	-1, -1, 400, 97,
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   874
	WC_COMPANY_LEAGUE,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
   875
	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
   876
	_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
   877
	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
   878
};
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   879
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
   880
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
   881
{
9d00ef71146e (svn r1587) -CodeChange: fixed up the graph loop a little..numd now shows the exact amount, no +1 needed
darkvater
parents: 1085
diff changeset
   882
	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
   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
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   885
/*****************************/
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   886
/* PERFORMANCE RATING DETAIL */
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   887
/*****************************/
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   888
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   889
static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   890
{
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   891
	switch(e->event) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   892
	case WE_PAINT: {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   893
		int val, needed, score, i;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   894
		byte owner, x;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   895
		uint16 y=14;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   896
		int total_score = 0;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   897
		int color_done, color_notdone;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   898
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   899
		// Draw standard stuff
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   900
		DrawWindowWidgets(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   901
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   902
		// The player of which we check the detail performance rating
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   903
		owner = FindFirstBit(w->click_state) - 13;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   904
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   905
		// Paint the player icons
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   906
		for (i=0;i<MAX_PLAYERS;i++) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   907
       		if (!DEREF_PLAYER(i)->is_active) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   908
       			// Check if we have the player as an active player
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   909
       			if (!(w->disabled_state & (1 << (i+13)))) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   910
       				// Bah, player gone :(
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   911
                   	w->disabled_state += 1 << (i+13);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   912
                   	// Is this player selected? If so, select first player (always save? :s)
979
f12f96116cdd (svn r1475) Fix some more signed/unsigned comparison warnings
tron
parents: 970
diff changeset
   913
                   	if (w->click_state == 1U << (i + 13))
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   914
                   		w->click_state = 1 << 13;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   915
                   	// We need a repaint
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   916
                   	SetWindowDirty(w);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   917
                }
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   918
               	continue;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   919
            }
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   920
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   921
			// Check if we have the player marked as inactive
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   922
			if ((w->disabled_state & (1 << (i+13)))) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   923
				// New player! Yippie :p
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   924
				w->disabled_state -= 1 << (i+13);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   925
               	// We need a repaint
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   926
               	SetWindowDirty(w);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   927
            }
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   928
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   929
			if (i == owner) x = 1; else x = 0;
519
8d124eb58806 (svn r844) Fix some typos ([ 1074329 ]) and use a bigger font in the detailed performance rating window
tron
parents: 507
diff changeset
   930
			DrawPlayerIcon(i, i * 37 + 13 + x, 16 + x);
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   931
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   932
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   933
		// The colors used to show how the progress is going
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   934
		color_done = _color_list[6].window_color_1b;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   935
		color_notdone = _color_list[4].window_color_1b;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   936
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   937
		// Draw all the score parts
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   938
		for (i=0;i<NUM_SCORE;i++) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   939
			y += 20;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   940
    		val = _score_part[owner][i];
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   941
    		needed = score_info[i].needed;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   942
    		score = score_info[i].score;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   943
    		// SCORE_TOTAL has his own rulez ;)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   944
    		if (i == SCORE_TOTAL) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   945
    			needed = total_score;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   946
    			score = SCORE_MAX;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   947
    		} else
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   948
    			total_score += score;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   949
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   950
    		DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, 0);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   951
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   952
    		// Draw the score
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   953
    		SetDParam(0, score);
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   954
    		DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   955
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   956
    		// Calculate the %-bar
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   957
    		if (val > needed) x = 50;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   958
    		else if (val == 0) x = 0;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   959
    		else x = ((val * 50) / needed);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   960
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   961
    		// SCORE_LOAN is inversed
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   962
    		if (val < 0 && i == SCORE_LOAN)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   963
    			x = 0;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   964
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   965
    		// Draw the bar
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   966
    		if (x != 0)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   967
    			GfxFillRect(112, y-2, x + 112, y+10, color_done);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   968
    		if (x != 50)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   969
    			GfxFillRect(x + 112, y-2, 50 + 112, y+10, color_notdone);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   970
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   971
   			// Calculate the %
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   972
    		if (val > needed) x = 100;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   973
    		else x = ((val * 100) / needed);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   974
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   975
    		// SCORE_LOAN is inversed
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   976
    		if (val < 0 && i == SCORE_LOAN)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   977
    			x = 0;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   978
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   979
    		// Draw it
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   980
    		SetDParam(0, x);
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   981
    		DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, 0);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   982
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   983
    		// SCORE_LOAN is inversed
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   984
    		if (i == SCORE_LOAN)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   985
				val = needed - val;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   986
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   987
    		// Draw the amount we have against what is needed
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   988
    		//  For some of them it is in currency format
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   989
    		SetDParam(0, val);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 519
diff changeset
   990
    		SetDParam(1, needed);
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   991
    		switch (i) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   992
    			case SCORE_MIN_PROFIT:
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   993
    			case SCORE_MIN_INCOME:
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   994
    			case SCORE_MAX_INCOME:
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   995
    			case SCORE_MONEY:
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   996
    			case SCORE_LOAN:
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   997
    				DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, 0);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   998
    				break;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
   999
    			default:
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1000
    				DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, 0);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1001
			}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1002
    	}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1003
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1004
		break;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1005
	}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1006
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1007
	case WE_CLICK:
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1008
		// Check which button is clicked
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1009
		if (IS_INT_INSIDE(e->click.widget, 13, 21)) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1010
			// Is it no on disable?
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1011
			if ((w->disabled_state & (1 << e->click.widget)) == 0) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1012
				w->click_state = 1 << e->click.widget;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1013
				SetWindowDirty(w);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1014
			}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1015
		}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1016
		break;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1017
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1018
	case WE_CREATE:
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1019
		{
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1020
    		int i;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1021
    		Player *p2;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1022
        	w->hidden_state = 0;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1023
        	w->disabled_state = 0;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1024
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1025
        	// Hide the player who are not active
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1026
        	for (i=0;i<MAX_PLAYERS;i++) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1027
        		if (!DEREF_PLAYER(i)->is_active) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1028
        			w->disabled_state += 1 << (i+13);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1029
        		}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1030
        	}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1031
        	// Update all player stats with the current data
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1032
        	//  (this is because _score_info is not saved to a savegame)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1033
        	FOR_ALL_PLAYERS(p2)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1034
        		if (p2->is_active)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1035
        			UpdateCompanyRatingAndValue(p2, false);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1036
165
f81fa8c27236 (svn r166) -Codechange: change 74 for constant DAY_TICKS
darkvater
parents: 140
diff changeset
  1037
        	w->custom[0] = DAY_TICKS;
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1038
        	w->custom[1] = 5;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1039
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1040
        	w->click_state = 1 << 13;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1041
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1042
			SetWindowDirty(w);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1043
        }
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1044
    	break;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1045
    case WE_TICK:
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1046
        {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1047
        	// Update the player score every 5 days
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1048
            if (--w->custom[0] == 0) {
165
f81fa8c27236 (svn r166) -Codechange: change 74 for constant DAY_TICKS
darkvater
parents: 140
diff changeset
  1049
            	w->custom[0] = DAY_TICKS;
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1050
            	if (--w->custom[1] == 0) {
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1051
            		Player *p2;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1052
            		w->custom[1] = 5;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1053
            		FOR_ALL_PLAYERS(p2)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1054
            			// Skip if player is not active
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1055
            			if (p2->is_active)
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1056
            				UpdateCompanyRatingAndValue(p2, false);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1057
            		SetWindowDirty(w);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1058
            	}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1059
            }
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1060
        }
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1061
        break;
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1062
	}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1063
}
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1064
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1065
static const Widget _performance_rating_detail_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1066
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,								STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1067
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   298,     0,    13, STR_PERFORMANCE_DETAIL,	STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1068
{     WWT_IMGBTN,   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
  1069
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1070
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   298,    28,    47, 0x0,STR_PERFORMANCE_DETAIL_VEHICLES_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1071
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   298,    48,    67, 0x0,STR_PERFORMANCE_DETAIL_STATIONS_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1072
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   298,    68,    87, 0x0,STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1073
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   298,    88,   107, 0x0,STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1074
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   298,   108,   127, 0x0,STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1075
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   298,   128,   147, 0x0,STR_PERFORMANCE_DETAIL_DELIVERED_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1076
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   298,   148,   167, 0x0,STR_PERFORMANCE_DETAIL_CARGO_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1077
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   298,   168,   187, 0x0,STR_PERFORMANCE_DETAIL_MONEY_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1078
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   298,   188,   207, 0x0,STR_PERFORMANCE_DETAIL_LOAN_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1079
{     WWT_IMGBTN,   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
  1080
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1081
{     WWT_IMGBTN,   RESIZE_NONE,    14,     2,    38,    14,    26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1082
{     WWT_IMGBTN,   RESIZE_NONE,    14,    39,    75,    14,    26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1083
{     WWT_IMGBTN,   RESIZE_NONE,    14,    76,   112,    14,    26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1084
{     WWT_IMGBTN,   RESIZE_NONE,    14,   113,   149,    14,    26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1085
{     WWT_IMGBTN,   RESIZE_NONE,    14,   150,   186,    14,    26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1086
{     WWT_IMGBTN,   RESIZE_NONE,    14,   187,   223,    14,    26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1087
{     WWT_IMGBTN,   RESIZE_NONE,    14,   224,   260,    14,    26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 534
diff changeset
  1088
{     WWT_IMGBTN,   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
  1089
{   WIDGETS_END},
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1090
};
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1091
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1092
static const WindowDesc _performance_rating_detail_desc = {
519
8d124eb58806 (svn r844) Fix some typos ([ 1074329 ]) and use a bigger font in the detailed performance rating window
tron
parents: 507
diff changeset
  1093
	-1, -1, 299, 228,
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1094
	WC_PERFORMANCE_DETAIL,0,
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1095
	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
  1096
	_performance_rating_detail_widgets,
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1097
	PerformanceRatingDetailWndProc
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1098
};
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1099
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
  1100
void ShowPerformanceRatingDetail(void)
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1101
{
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1102
	AllocateWindowDescFront(&_performance_rating_detail_desc, 0);
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 57
diff changeset
  1103
}
1575
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1104
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1105
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1106
static uint16 _num_sign_sort;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1107
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1108
static char _bufcache[64];
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1109
static uint16 _last_sign_idx;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1110
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1111
static int CDECL SignNameSorter(const void *a, const void *b)
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1112
{
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1113
	char buf1[64];
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1114
	SignStruct *ss;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1115
	const uint16 cmp1 = *(const uint16 *)a;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1116
	const uint16 cmp2 = *(const uint16 *)b;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1117
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1118
	ss = GetSign(cmp1);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1119
	GetString(buf1, ss->str);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1120
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1121
	if (cmp2 != _last_sign_idx) {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1122
		_last_sign_idx = cmp2;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1123
		ss = GetSign(cmp2);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1124
		GetString(_bufcache, ss->str);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1125
	}
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1126
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1127
	return strcmp(buf1, _bufcache);	// sort by name
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1128
}
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1129
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1130
static void GlobalSortSignList(void)
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1131
{
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1132
	const SignStruct *ss;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1133
	uint32 n = 0;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1134
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1135
	_num_sign_sort = 0;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1136
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1137
	/* Create array for sorting */
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1138
	_sign_sort = realloc(_sign_sort, GetSignPoolSize() * sizeof(_sign_sort[0]));
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1139
	if (_sign_sort == NULL)
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1140
		error("Could not allocate memory for the sign-sorting-list");
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1141
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1142
	FOR_ALL_SIGNS(ss) {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1143
		if(ss->str != STR_NULL) {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1144
			_sign_sort[n++] = ss->index;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1145
			_num_sign_sort++;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1146
		}
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1147
	}
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1148
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1149
	qsort(_sign_sort, n, sizeof(_sign_sort[0]), SignNameSorter);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1150
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1151
	_sign_sort_dirty = false;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1152
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1153
	DEBUG(misc, 1) ("Resorting global sign list...");
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1154
}
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1155
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1156
static void SignListWndProc(Window *w, WindowEvent *e)
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1157
{
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1158
	switch (e->event) {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1159
	case WE_PAINT: {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1160
		uint32 i;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1161
		int y = 16; // offset from top of widget
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1162
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1163
		if (_sign_sort_dirty)
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1164
			GlobalSortSignList();
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1165
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1166
		SetVScrollCount(w, _num_sign_sort);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1167
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1168
		SetDParam(0, w->vscroll.count);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1169
		DrawWindowWidgets(w);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1170
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1171
		/* No signs? */
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1172
		if (w->vscroll.count == 0) {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1173
			DrawString(2, y, STR_304A_NONE, 0);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1174
			return;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1175
		}
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1176
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1177
		{
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1178
			SignStruct *ss;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1179
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1180
			/* Start drawing the signs */
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1181
			i = 0;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1182
			for (i = w->vscroll.pos; i < (uint)w->vscroll.cap + w->vscroll.pos && i < w->vscroll.count; i++) {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1183
				ss = GetSign(_sign_sort[i]);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1184
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1185
				if (ss->owner != OWNER_NONE)
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1186
					DrawPlayerIcon(ss->owner, 4, y + 1);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1187
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1188
				DrawString(22, y, ss->str, 8);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1189
				y += 10;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1190
			}
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1191
		}
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1192
	} break;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1193
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1194
	case WE_CLICK: {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1195
		switch (e->click.widget) {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1196
		case 3: {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1197
			uint32 id_v = (e->click.pt.y - 15) / 10;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1198
			SignStruct *ss;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1199
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1200
			if (id_v >= w->vscroll.cap)
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1201
				return;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1202
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1203
			id_v += w->vscroll.pos;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1204
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1205
			if (id_v >= w->vscroll.count)
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1206
				return;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1207
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1208
			ss = GetSign(_sign_sort[id_v]);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1209
			ScrollMainWindowToTile(TILE_FROM_XY(ss->x, ss->y));
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1210
		} break;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1211
		}
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1212
	} break;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1213
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1214
	case WE_RESIZE:
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1215
		w->vscroll.cap += e->sizing.diff.y / 10;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1216
		break;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1217
	}
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1218
}
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1219
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1220
static const Widget _sign_list_widget[] = {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1221
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,									STR_018B_CLOSE_WINDOW},
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1222
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   345,     0,    13, STR_SIGN_LIST_CAPTION,		STR_018C_WINDOW_TITLE_DRAG_THIS},
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1223
{  WWT_STICKYBOX,     RESIZE_LR,    14,   346,   357,     0,    13, 0x0,											STR_STICKY_BUTTON},
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1224
{      WWT_PANEL,     RESIZE_RB,    14,     0,   345,    14,   137, 0x0,											STR_NULL},
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1225
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   346,   357,    14,   125, 0x0,											STR_0190_SCROLL_BAR_SCROLLS_LIST},
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1226
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   346,   357,   126,   137, 0x0,											STR_RESIZE_BUTTON},
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1227
{   WIDGETS_END},
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1228
};
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1229
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1230
static const WindowDesc _sign_list_desc = {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1231
	-1, -1, 358, 138,
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1232
	WC_SIGN_LIST,0,
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1233
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1234
	_sign_list_widget,
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1235
	SignListWndProc
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1236
};
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1237
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1238
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1239
void ShowSignList(void)
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1240
{
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1241
	Window *w;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1242
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1243
	w = AllocateWindowDescFront(&_sign_list_desc, 0);
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1244
	if (w != NULL) {
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1245
		w->vscroll.cap = 12;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1246
		w->resize.step_height = 10;
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1247
		w->resize.height = w->height - 10 * 7; // minimum if 5 in the list
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1248
	}
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
  1249
}