src/player_gui.cpp
author KUDr
Sat, 21 Apr 2007 08:23:57 +0000
branchcpp_gui
changeset 6308 646711c5feaa
parent 6303 84c215fc8eb8
permissions -rw-r--r--
(svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
     3
/** @file player_gui.cpp */
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1875
diff changeset
     6
#include "openttd.h"
1363
01d3de5d8039 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1323
diff changeset
     7
#include "table/sprites.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 200
diff changeset
     8
#include "table/strings.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     9
#include "functions.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "player.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "command.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "vehicle.h"
186
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    17
#include "economy.h"
5720
cc0ceeafaa55 (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5682
diff changeset
    18
#include "network/network.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2064
diff changeset
    19
#include "variables.h"
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2642
diff changeset
    20
#include "train.h"
6105
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5919
diff changeset
    21
#include "aircraft.h"
4261
2ec8f5a9747b (svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents: 4171
diff changeset
    22
#include "date.h"
4742
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
    23
#include "newgrf.h"
5720
cc0ceeafaa55 (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5682
diff changeset
    24
#include "network/network_data.h"
cc0ceeafaa55 (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5682
diff changeset
    25
#include "network/network_client.h"
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
    26
#include "player_face.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
2475
8443e1eefe1b (svn r3001) s/Player*/const Player*/
tron
parents: 2473
diff changeset
    28
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
    30
static void DrawPlayerEconomyStats(const Player *p, byte mode)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
{
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
    32
	int x, y, i, j, year;
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
    33
	const int64 (*tbl)[13];
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
    34
	int64 sum, cost;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
	StringID str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
186
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    37
	if (!(mode & 1)) { // normal sized economics window (mode&1) is minimized status
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
		/* draw categories */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
		DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, 0);
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2725
diff changeset
    40
		for (i = 0; i != 13; i++)
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
    41
			DrawString(2, 27 + i * 10, STR_7011_CONSTRUCTION + i, 0);
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
    42
		DrawStringRightAligned(111, 27 + 10 * 13 + 2, STR_7020_TOTAL, 0);
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
    43
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
		/* draw the price columns */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
		year = _cur_year - 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
		j = 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
		x = 215;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
		tbl = p->yearly_expenses + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
		do {
4329
9759d5c52010 (svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents: 4314
diff changeset
    50
			if (year >= p->inaugurated_year) {
4293
2c24234a7aec (svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents: 4286
diff changeset
    51
				SetDParam(0, year);
4314
c7ded7546e7f (svn r5967) -Change: use right alignment for the year in the player's balance window instead of centering (about) 'string width' / 2 from the right edge
rubidium
parents: 4299
diff changeset
    52
				DrawStringRightAlignedUnderline(x, 15, STR_7010, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
				sum = 0;
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2725
diff changeset
    54
				for (i = 0; i != 13; i++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
					/* draw one row in the price column */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
					cost = (*tbl)[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
					if (cost != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
						sum += cost;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
    59
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
						str = STR_701E;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
						if (cost < 0) { cost = -cost; str++; }
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    62
						SetDParam64(0, cost);
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
    63
						DrawStringRightAligned(x, 27 + i * 10, str, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
				str = STR_701E;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
				if (sum < 0) { sum = -sum; str++; }
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    69
				SetDParam64(0, sum);
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
    70
				DrawStringRightAligned(x, 27 + 13 * 10 + 2, str, 0);
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
    71
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
    72
				GfxFillRect(x - 75, 27 + 10 * 13, x, 27 + 10 * 13, 215);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
				x += 95;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
			year++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
			tbl--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
		} while (--j != 0);
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
		y = 171;
186
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    80
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
    81
		/* draw max loan aligned to loan below (y += 10) */
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    82
		SetDParam64(0, (uint64)_economy.max_loan);
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
    83
		DrawString(202, y + 10, STR_MAX_LOAN, 0);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    84
	} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
		y = 15;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    86
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
	DrawString(2, y, STR_7026_BANK_BALANCE, 0);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    89
	SetDParam64(0, p->money64);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	DrawStringRightAligned(182, y, STR_7028, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	y += 10;
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
	DrawString(2, y, STR_7027_LOAN, 0);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    95
	SetDParam64(0, p->current_loan);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	DrawStringRightAligned(182, y, STR_7028, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
	y += 12;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   100
	GfxFillRect(182 - 75, y - 2, 182, y - 2, 215);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   102
	SetDParam64(0, p->money64 - p->current_loan);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
	DrawStringRightAligned(182, y, STR_7028, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   106
static const OldWidget _player_finances_widgets[] = {
4937
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   107
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   108
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   379,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   109
{     WWT_IMGBTN,   RESIZE_NONE,    14,   380,   394,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   110
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   395,   406,     0,    13, 0x0,                    STR_STICKY_BUTTON},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   111
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   406,    14,   169, 0x0,                    STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   112
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   406,   170,   203, 0x0,                    STR_NULL},
4937
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   113
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   202,   204,   215, STR_7029_BORROW,        STR_7035_INCREASE_SIZE_OF_LOAN},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   114
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   203,   406,   204,   215, STR_702A_REPAY,         STR_7036_REPAY_PART_OF_LOAN},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   115
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   118
static const OldWidget _other_player_finances_widgets[] = {
4937
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   119
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   120
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   379,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   121
{     WWT_IMGBTN,   RESIZE_NONE,    14,   380,   394,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   122
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   395,   406,     0,    13, 0x0,                    STR_STICKY_BUTTON},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   123
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   406,    14,   169, 0x0,                    STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   124
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   406,   170,   203, 0x0,                    STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   125
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   128
static const OldWidget _other_player_finances_small_widgets[] = {
4937
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   129
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   130
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   253,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   131
{     WWT_IMGBTN,   RESIZE_NONE,    14,   254,   267,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   132
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   268,   279,     0,    13, 0x0,                    STR_STICKY_BUTTON},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   133
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                    STR_NULL},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   134
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   279,    14,    47, 0x0,                    STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   135
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   138
static const OldWidget _player_finances_small_widgets[] = {
4937
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   139
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   140
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   253,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   141
{     WWT_IMGBTN,   RESIZE_NONE,    14,   254,   267,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   142
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   268,   279,     0,    13, 0x0,                    STR_STICKY_BUTTON},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   143
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                    STR_NULL},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   144
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   279,    14,    47, STR_NULL,               STR_NULL},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   145
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   139,    48,    59, STR_7029_BORROW,        STR_7035_INCREASE_SIZE_OF_LOAN},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   146
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   140,   279,    48,    59, STR_702A_REPAY,         STR_7036_REPAY_PART_OF_LOAN},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   147
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   151
static void PlayerFinancesWndProc(BaseWindow *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
{
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2725
diff changeset
   153
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
	case WE_PAINT: {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   155
		PlayerID player = (PlayerID)w->window_number;
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   156
		const Player *p = GetPlayer(player);
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   157
4805
a03106c010b3 (svn r6727) -Fix r6619: don't disable inexistant widget
glx
parents: 4746
diff changeset
   158
		if (player == _local_player) {
a03106c010b3 (svn r6727) -Fix r6619: don't disable inexistant widget
glx
parents: 4746
diff changeset
   159
			/* borrow/repay buttons only exist for local player */
6246
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6241
diff changeset
   160
			w->SetWidgetDisabledState(7, p->current_loan == 0);
4805
a03106c010b3 (svn r6727) -Fix r6619: don't disable inexistant widget
glx
parents: 4746
diff changeset
   161
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   163
		SetDParam(0, p->name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   164
		SetDParam(1, p->name_2);
2475
8443e1eefe1b (svn r3001) s/Player*/const Player*/
tron
parents: 2473
diff changeset
   165
		SetDParam(2, GetPlayerNameString(player, 3));
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   166
		SetDParam(4, 10000);
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6237
diff changeset
   167
		w->DrawWidgets();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   169
		DrawPlayerEconomyStats(p, (byte)WP(w, def_d).data_1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
	case WE_CLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4605
diff changeset
   173
		switch (e->we.click.widget) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
		case 2: {/* toggle size */
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   175
			byte mode = (byte)WP(w, def_d).data_1;
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   176
			bool stickied = !!(w->flags4 & WF_STICKY);
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   177
			PlayerID player = (PlayerID)w->window_number;
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   178
			w->Close();
1003
5ce43e332bab (svn r1502) -Fix: [1101889] Crash under windows... stupid typo in player_gui.c ^ should've been &
darkvater
parents: 998
diff changeset
   179
			DoShowPlayerFinances(player, !HASBIT(mode, 0), stickied);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   182
		case 6: /* increase loan */
1767
394867897b0a (svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents: 1739
diff changeset
   183
			DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   186
		case 7: /* repay loan */
1767
394867897b0a (svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents: 1739
diff changeset
   187
			DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
		break;
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
static const WindowDesc _player_finances_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   195
	WDP_AUTO, WDP_AUTO, 407, 216,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
   196
	WC_FINANCES, WC_NONE,
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   197
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
	_player_finances_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
	PlayerFinancesWndProc
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
static const WindowDesc _player_finances_small_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   203
	WDP_AUTO, WDP_AUTO, 280, 60,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
   204
	WC_FINANCES, WC_NONE,
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   205
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
	_player_finances_small_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
	PlayerFinancesWndProc
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
static const WindowDesc _other_player_finances_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   211
	WDP_AUTO, WDP_AUTO, 407, 204,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
   212
	WC_FINANCES, WC_NONE,
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   213
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
	_other_player_finances_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
	PlayerFinancesWndProc
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
static const WindowDesc _other_player_finances_small_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   219
	WDP_AUTO, WDP_AUTO, 280, 48,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
   220
	WC_FINANCES, WC_NONE,
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   221
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
	_other_player_finances_small_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
	PlayerFinancesWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
2475
8443e1eefe1b (svn r3001) s/Player*/const Player*/
tron
parents: 2473
diff changeset
   226
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
{
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   228
	BaseWindow *w;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
	int mode;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
5005
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   231
	static const WindowDesc * const desc_table[2 * 2] = {
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   232
		&_player_finances_desc, &_player_finances_small_desc,
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   233
		&_other_player_finances_desc, &_other_player_finances_small_desc,
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   234
	};
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   235
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   236
	if (!IsValidPlayer(player)) return;
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   237
2475
8443e1eefe1b (svn r3001) s/Player*/const Player*/
tron
parents: 2473
diff changeset
   238
	mode = (player != _local_player) * 2 + show_small;
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   239
	w = BaseWindow::AllocateFront(desc_table[mode], player);
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
   240
	if (w != NULL) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
		w->caption_color = w->window_number;
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   242
		WP(w, def_d).data_1 = mode;
5005
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   243
		if (show_stickied) w->flags4 |= WF_STICKY;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
2475
8443e1eefe1b (svn r3001) s/Player*/const Player*/
tron
parents: 2473
diff changeset
   247
void ShowPlayerFinances(PlayerID player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
{
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   249
	DoShowPlayerFinances(player, false, false);
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
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   252
/* List of colours for the livery window */
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   253
static const StringID _colour_dropdown[] = {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   254
	STR_00D1_DARK_BLUE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   255
	STR_00D2_PALE_GREEN,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   256
	STR_00D3_PINK,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   257
	STR_00D4_YELLOW,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   258
	STR_00D5_RED,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   259
	STR_00D6_LIGHT_BLUE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   260
	STR_00D7_GREEN,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   261
	STR_00D8_DARK_GREEN,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   262
	STR_00D9_BLUE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   263
	STR_00DA_CREAM,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   264
	STR_00DB_MAUVE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   265
	STR_00DC_PURPLE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   266
	STR_00DD_ORANGE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   267
	STR_00DE_BROWN,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   268
	STR_00DF_GREY,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   269
	STR_00E0_WHITE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   270
	INVALID_STRING_ID
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   271
};
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   272
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   273
/* Association of liveries to livery classes */
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   274
static const LiveryClass livery_class[LS_END] = {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   275
	LC_OTHER,
4604
f99f5de6077a (svn r6456) - Replace single colour scheme for passenger wagons with separate schemes for each of steam, diesel or electric engines. Savegames from the previous revision will not load.
peter1138
parents: 4603
diff changeset
   276
	LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL,
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   277
	LC_ROAD, LC_ROAD,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   278
	LC_SHIP, LC_SHIP,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   279
	LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   280
};
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   281
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   282
/* Number of liveries in each class, used to determine the height of the livery window */
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   283
static const byte livery_height[] = {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   284
	1,
4604
f99f5de6077a (svn r6456) - Replace single colour scheme for passenger wagons with separate schemes for each of steam, diesel or electric engines. Savegames from the previous revision will not load.
peter1138
parents: 4603
diff changeset
   285
	11,
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   286
	2,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   287
	2,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   288
	3,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   289
};
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   290
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   291
struct livery_d {
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   292
	uint32 sel;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   293
	LiveryClass livery_class;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   294
};
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   295
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(livery_d));
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   296
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   297
static void ShowColourDropDownMenu(BaseWindow *w, uint32 widget)
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   298
{
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   299
	uint32 used_colours = 0;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   300
	const Livery *livery;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   301
	LiveryScheme scheme;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   302
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   303
	/* Disallow other player colours for the primary colour */
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   304
	if (HASBIT(WP(w, livery_d).sel, LS_DEFAULT) && widget == 10) {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   305
		const Player *p;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   306
		FOR_ALL_PLAYERS(p) {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   307
			if (p->is_active && p->index != _local_player) SETBIT(used_colours, p->player_color);
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   308
		}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   309
	}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   310
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   311
	/* Get the first selected livery to use as the default dropdown item */
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   312
	for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   313
		if (HASBIT(WP(w, livery_d).sel, scheme)) break;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   314
	}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   315
	if (scheme == LS_END) scheme = LS_DEFAULT;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   316
	livery = &GetPlayer((PlayerID)w->window_number)->livery[scheme];
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   317
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6237
diff changeset
   318
	w->ShowDropDownMenu(_colour_dropdown, widget == 10 ? livery->colour1 : livery->colour2, widget, used_colours, 0);
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   319
}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   320
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   321
static void SelectPlayerLiveryWndProc(BaseWindow *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
{
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2725
diff changeset
   323
	switch (e->event) {
4742
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   324
		case WE_CREATE:
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   325
			w->LowerWidget(WP(w, livery_d).livery_class + 2);
4742
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   326
			if (!_have_2cc) {
6250
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   327
				w->HideWidget(11);
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   328
				w->HideWidget(12);
4742
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   329
			}
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   330
			break;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   331
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   332
		case WE_PAINT: {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   333
			const Player *p = GetPlayer((PlayerID)w->window_number);
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   334
			LiveryScheme scheme = LS_DEFAULT;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   335
			int y = 51;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   337
			/* Disable dropdown controls if no scheme is selected */
6246
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6241
diff changeset
   338
			w->SetWidgetDisabledState( 9, (WP(w, livery_d).sel == 0));
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6241
diff changeset
   339
			w->SetWidgetDisabledState(10, (WP(w, livery_d).sel == 0));
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6241
diff changeset
   340
			w->SetWidgetDisabledState(11, (WP(w, livery_d).sel == 0));
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6241
diff changeset
   341
			w->SetWidgetDisabledState(12, (WP(w, livery_d).sel == 0));
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   342
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   343
			if (!(WP(w, livery_d).sel == 0)) {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   344
				for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   345
					if (HASBIT(WP(w, livery_d).sel, scheme)) break;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   346
				}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   347
				if (scheme == LS_END) scheme = LS_DEFAULT;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
			}
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   349
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   350
			SetDParam(0, STR_00D1_DARK_BLUE + p->livery[scheme].colour1);
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   351
			SetDParam(1, STR_00D1_DARK_BLUE + p->livery[scheme].colour2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6237
diff changeset
   353
			w->DrawWidgets();
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   354
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   355
			for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   356
				if (livery_class[scheme] == WP(w, livery_d).livery_class) {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   357
					bool sel = HASBIT(WP(w, livery_d).sel, scheme) != 0;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   358
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   359
					if (scheme != LS_DEFAULT) {
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5838
diff changeset
   360
						DrawSprite(p->livery[scheme].in_use ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, 2, y);
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   361
					}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   362
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   363
					DrawString(15, y, STR_LIVERY_DEFAULT + scheme, sel ? 0xC : 0x10);
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   364
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5838
diff changeset
   365
					DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour1), 152, y);
4742
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   366
					DrawString(165, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour1, sel ? 0xC : 2);
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   367
4742
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   368
					if (_have_2cc) {
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5838
diff changeset
   369
						DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour2), 277, y);
4742
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   370
						DrawString(290, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour2, sel ? 0xC : 2);
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   371
					}
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   372
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   373
					y += 14;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   374
				}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   375
			}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   376
			break;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   377
		}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   378
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   379
		case WE_CLICK: {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4605
diff changeset
   380
			switch (e->we.click.widget) {
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   381
				/* Livery Class buttons */
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   382
				case 2:
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   383
				case 3:
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   384
				case 4:
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   385
				case 5:
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   386
				case 6: {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   387
					LiveryScheme scheme;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   388
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   389
					w->RaiseWidget(WP(w, livery_d).livery_class + 2);
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   390
					WP(w, livery_d).livery_class = (LiveryClass)(e->we.click.widget - 2);
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   391
					WP(w, livery_d).sel = 0;
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   392
					w->LowerWidget(WP(w, livery_d).livery_class + 2);
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   393
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   394
					/* Select the first item in the list */
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   395
					for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   396
						if (livery_class[scheme] == WP(w, livery_d).livery_class) {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   397
							WP(w, livery_d).sel = 1 << scheme;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   398
							break;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   399
						}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   400
					}
6263
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6258
diff changeset
   401
					w->SetHeight(49 + livery_height[WP(w, livery_d).livery_class] * 14);
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6258
diff changeset
   402
					w->widget[13].bottom = w->Height() - 1;
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   403
					w->widget[13].data = livery_height[WP(w, livery_d).livery_class] << 8 | 1;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   404
					MarkWholeScreenDirty();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
					break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
				}
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   407
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   408
				case 9:
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   409
				case 10: /* First colour dropdown */
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   410
					ShowColourDropDownMenu(w, 10);
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   411
					break;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   412
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   413
				case 11:
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   414
				case 12: /* Second colour dropdown */
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   415
					ShowColourDropDownMenu(w, 12);
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   416
					break;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   417
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   418
				case 13: {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   419
					LiveryScheme scheme;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   420
					LiveryScheme j = (LiveryScheme)((e->we.click.pt.y - 48) / 14);
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   421
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   422
					for (scheme = LS_BEGIN; scheme <= j; scheme++) {
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   423
						if (livery_class[scheme] != WP(w, livery_d).livery_class) j++;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   424
						if (scheme >= LS_END) return;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   425
					}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   426
					if (j >= LS_END) return;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   427
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   428
					/* If clicking on the left edge, toggle using the livery */
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4605
diff changeset
   429
					if (e->we.click.pt.x < 10) {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   430
						DoCommandP(0, j | (2 << 8), !GetPlayer((PlayerID)w->window_number)->livery[j].in_use, NULL, CMD_SET_PLAYER_COLOR);
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   431
					}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   432
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   433
					if (_ctrl_pressed) {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   434
						TOGGLEBIT(WP(w, livery_d).sel, j);
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   435
					} else {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   436
						WP(w, livery_d).sel = 1 << j;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   437
					}
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   438
					w->SetDirty();
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   439
					break;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   440
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
			}
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   442
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
		}
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   444
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   445
		case WE_DROPDOWN_SELECT: {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   446
			LiveryScheme scheme;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   447
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   448
			for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   449
				if (HASBIT(WP(w, livery_d).sel, scheme)) {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4605
diff changeset
   450
					DoCommandP(0, scheme | (e->we.dropdown.button == 10 ? 0 : 256), e->we.dropdown.index, NULL, CMD_SET_PLAYER_COLOR);
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   451
				}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   452
			}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   453
			break;
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   454
		}
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   458
static const OldWidget _select_player_livery_2cc_widgets[] = {
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   459
{ WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,                  STR_018B_CLOSE_WINDOW },
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   460
{  WWT_CAPTION, RESIZE_NONE, 14,  11, 399,   0,  13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
4647
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   461
{   WWT_IMGBTN, RESIZE_NONE, 14,   0,  21,  14,  35, SPR_IMG_COMPANY_GENERAL,   STR_LIVERY_GENERAL_TIP },
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   462
{   WWT_IMGBTN, RESIZE_NONE, 14,  22,  43,  14,  35, SPR_IMG_TRAINLIST,         STR_LIVERY_TRAIN_TIP },
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   463
{   WWT_IMGBTN, RESIZE_NONE, 14,  44,  65,  14,  35, SPR_IMG_TRUCKLIST,         STR_LIVERY_ROADVEH_TIP },
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   464
{   WWT_IMGBTN, RESIZE_NONE, 14,  66,  87,  14,  35, SPR_IMG_SHIPLIST,          STR_LIVERY_SHIP_TIP },
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   465
{   WWT_IMGBTN, RESIZE_NONE, 14,  88, 109,  14,  35, SPR_IMG_AIRPLANESLIST,     STR_LIVERY_AIRCRAFT_TIP },
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   466
{    WWT_PANEL, RESIZE_NONE, 14, 110, 399,  14,  35, 0x0,                       STR_NULL },
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   467
{    WWT_PANEL, RESIZE_NONE, 14,   0, 149,  36,  47, 0x0,                       STR_NULL },
4647
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   468
{  WWT_TEXTBTN, RESIZE_NONE, 14, 150, 262,  36,  47, STR_02BD,                  STR_LIVERY_PRIMARY_TIP },
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   469
{  WWT_TEXTBTN, RESIZE_NONE, 14, 263, 274,  36,  47, STR_0225,                  STR_LIVERY_PRIMARY_TIP },
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   470
{  WWT_TEXTBTN, RESIZE_NONE, 14, 275, 387,  36,  47, STR_02E1,                  STR_LIVERY_SECONDARY_TIP },
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   471
{  WWT_TEXTBTN, RESIZE_NONE, 14, 388, 399,  36,  47, STR_0225,                  STR_LIVERY_SECONDARY_TIP },
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   472
{   WWT_MATRIX, RESIZE_NONE, 14,   0, 399,  48,  48 + 1 * 14, (1 << 8) | 1,     STR_LIVERY_PANEL_TIP },
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   473
{ WIDGETS_END },
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
4742
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   476
static const WindowDesc _select_player_livery_2cc_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   477
	WDP_AUTO, WDP_AUTO, 400, 49 + 1 * 14,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
   478
	WC_PLAYER_COLOR, WC_NONE,
4742
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   479
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   480
	_select_player_livery_2cc_widgets,
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   481
	SelectPlayerLiveryWndProc
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   482
};
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   483
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   484
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   485
static const OldWidget _select_player_livery_widgets[] = {
4742
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   486
{ WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,                  STR_018B_CLOSE_WINDOW },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   487
{  WWT_CAPTION, RESIZE_NONE, 14,  11, 274,   0,  13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   488
{   WWT_IMGBTN, RESIZE_NONE, 14,   0,  21,  14,  35, SPR_IMG_COMPANY_GENERAL,   STR_LIVERY_GENERAL_TIP },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   489
{   WWT_IMGBTN, RESIZE_NONE, 14,  22,  43,  14,  35, SPR_IMG_TRAINLIST,         STR_LIVERY_TRAIN_TIP },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   490
{   WWT_IMGBTN, RESIZE_NONE, 14,  44,  65,  14,  35, SPR_IMG_TRUCKLIST,         STR_LIVERY_ROADVEH_TIP },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   491
{   WWT_IMGBTN, RESIZE_NONE, 14,  66,  87,  14,  35, SPR_IMG_SHIPLIST,          STR_LIVERY_SHIP_TIP },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   492
{   WWT_IMGBTN, RESIZE_NONE, 14,  88, 109,  14,  35, SPR_IMG_AIRPLANESLIST,     STR_LIVERY_AIRCRAFT_TIP },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   493
{    WWT_PANEL, RESIZE_NONE, 14, 110, 274,  14,  35, 0x0,                       STR_NULL },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   494
{    WWT_PANEL, RESIZE_NONE, 14,   0, 149,  36,  47, 0x0,                       STR_NULL },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   495
{  WWT_TEXTBTN, RESIZE_NONE, 14, 150, 262,  36,  47, STR_02BD,                  STR_LIVERY_PRIMARY_TIP },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   496
{  WWT_TEXTBTN, RESIZE_NONE, 14, 263, 274,  36,  47, STR_0225,                  STR_LIVERY_PRIMARY_TIP },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   497
{  WWT_TEXTBTN, RESIZE_NONE, 14, 275, 275,  36,  47, STR_02E1,                  STR_LIVERY_SECONDARY_TIP },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   498
{  WWT_TEXTBTN, RESIZE_NONE, 14, 275, 275,  36,  47, STR_0225,                  STR_LIVERY_SECONDARY_TIP },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   499
{   WWT_MATRIX, RESIZE_NONE, 14,   0, 274,  48,  48 + 1 * 14, (1 << 8) | 1,     STR_LIVERY_PANEL_TIP },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   500
{ WIDGETS_END },
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   501
};
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   502
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   503
static const WindowDesc _select_player_livery_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   504
	WDP_AUTO, WDP_AUTO, 275, 49 + 1 * 14,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
   505
	WC_PLAYER_COLOR, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   507
	_select_player_livery_widgets,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   508
	SelectPlayerLiveryWndProc
0
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
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   511
/**
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   512
 * Draws the face of a player.
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   513
 * @param pf    the player's face
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   514
 * @param color the (background) color of the gradient
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   515
 * @param x     x-position to draw the face
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   516
 * @param y     y-position to draw the face
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   517
 */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   518
void DrawPlayerFace(PlayerFace pf, int color, int x, int y)
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   519
{
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   520
	GenderEthnicity ge = (GenderEthnicity)GetPlayerFaceBits(pf, PFV_GEN_ETHN, GE_WM);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   521
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   522
	bool has_moustache   = !HASBIT(ge, GENDER_FEMALE) && GetPlayerFaceBits(pf, PFV_HAS_MOUSTACHE,   ge) != 0;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   523
	bool has_tie_earring = !HASBIT(ge, GENDER_FEMALE) || GetPlayerFaceBits(pf, PFV_HAS_TIE_EARRING, ge) != 0;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   524
	bool has_glasses     = GetPlayerFaceBits(pf, PFV_HAS_GLASSES, ge) != 0;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   525
	SpriteID pal;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   526
	switch (GetPlayerFaceBits(pf, PFV_EYE_COLOUR, ge)) {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   527
		default: NOT_REACHED();
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   528
		case 0: pal = PALETTE_TO_BROWN; break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   529
		case 1: pal = PALETTE_TO_BLUE;  break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   530
		case 2: pal = PALETTE_TO_GREEN; break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   531
	}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   532
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   533
	/* Draw the gradient (background) */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   534
	DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOR(color), x, y);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   535
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   536
	for (PlayerFaceVariable pfv = PFV_CHEEKS; pfv < PFV_END; pfv++) {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   537
		switch (pfv) {
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   538
			case PFV_MOUSTACHE:   if (!has_moustache)   continue; break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   539
			case PFV_LIPS:        /* FALL THROUGH */
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   540
			case PFV_NOSE:        if (has_moustache)    continue; break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   541
			case PFV_TIE_EARRING: if (!has_tie_earring) continue; break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   542
			case PFV_GLASSES:     if (!has_glasses)     continue; break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   543
			default: break;
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   544
		}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   545
		DrawSprite(GetPlayerFaceSprite(pf, pfv, ge), (pfv == PFV_EYEBROWS) ? pal : PAL_NONE, x, y);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   546
	}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   547
}
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   548
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   549
static void SelectPlayerFaceWndProc(BaseWindow *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
{
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2725
diff changeset
   551
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   552
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
		Player *p;
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   554
		w->LowerWidget(WP(w, facesel_d).gender + 5);
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6237
diff changeset
   555
		w->DrawWidgets();
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   556
		p = GetPlayer((PlayerID)w->window_number);
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   557
		DrawPlayerFace(WP(w, facesel_d).face, p->player_color, 2, 16);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
	case WE_CLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4605
diff changeset
   561
		switch (e->we.click.widget) {
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   562
		case 3: w->Close(); break;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   563
		case 4: /* ok click */
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   564
			DoCommandP(0, 0, WP(w, facesel_d).face, NULL, CMD_SET_PLAYER_FACE);
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   565
			w->Close();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   566
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
		case 5: /* male click */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   568
		case 6: /* female click */
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   569
			w->RaiseWidget(WP(w, facesel_d).gender + 5);
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   570
			WP(w, facesel_d).gender = e->we.click.widget - 5;
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   571
			w->LowerWidget(WP(w, facesel_d).gender + 5);
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   572
			w->SetDirty();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
		case 7:
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   575
			WP(w, facesel_d).face = ConvertFromOldPlayerFace((WP(w, facesel_d).gender << 31) + GB(InteractiveRandom(), 0, 31));
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   576
			w->SetDirty();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   577
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   582
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   583
static const OldWidget _select_player_face_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
   584
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
   585
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   189,     0,    13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   586
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   189,    14,   136, 0x0,                     STR_NULL},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
   587
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    94,   137,   148, STR_012E_CANCEL,         STR_7047_CANCEL_NEW_FACE_SELECTION},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
   588
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    95,   189,   137,   148, STR_012F_OK,             STR_7048_ACCEPT_NEW_FACE_SELECTION},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
   589
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    95,   187,    25,    36, STR_7044_MALE,           STR_7049_SELECT_MALE_FACES},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
   590
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    95,   187,    37,    48, STR_7045_FEMALE,         STR_704A_SELECT_FEMALE_FACES},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
   591
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    95,   187,    79,    90, STR_7046_NEW_FACE,       STR_704B_GENERATE_RANDOM_NEW_FACE},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   592
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   593
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   595
static const WindowDesc _select_player_face_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   596
	WDP_AUTO, WDP_AUTO, 190, 149,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
   597
	WC_PLAYER_FACE, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   598
	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
   599
	_select_player_face_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
	SelectPlayerFaceWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   603
/* Names of the widgets. Keep them in the same order as in the widget array */
5273
5fde4b8c94c4 (svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents: 5070
diff changeset
   604
enum PlayerCompanyWindowWidgets {
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   605
	PCW_WIDGET_CLOSEBOX = 0,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   606
	PCW_WIDGET_CAPTION,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   607
	PCW_WIDGET_FACE,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   608
	PCW_WIDGET_NEW_FACE,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   609
	PCW_WIDGET_COLOR_SCHEME,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   610
	PCW_WIDGET_PRESIDENT_NAME,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   611
	PCW_WIDGET_COMPANY_NAME,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   612
	PCW_WIDGET_BUILD_VIEW_HQ,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   613
	PCW_WIDGET_RELOCATE_HQ,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   614
	PCW_WIDGET_BUY_SHARE,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   615
	PCW_WIDGET_SELL_SHARE,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   616
	PCW_WIDGET_COMPANY_PASSWORD,
5273
5fde4b8c94c4 (svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents: 5070
diff changeset
   617
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   618
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   619
static const OldWidget _player_company_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
   620
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
   621
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   359,     0,    13, STR_7001,                          STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   622
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   359,    14,   157, 0x0,                               STR_NULL},
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   623
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    89,   158,   169, STR_7004_NEW_FACE,                 STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT},
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   624
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    90,   179,   158,   169, STR_7005_COLOR_SCHEME,             STR_7031_CHANGE_THE_COMPANY_VEHICLE},
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   625
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   180,   269,   158,   169, STR_7009_PRESIDENT_NAME,           STR_7032_CHANGE_THE_PRESIDENT_S},
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   626
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   270,   359,   158,   169, STR_7008_COMPANY_NAME,             STR_7033_CHANGE_THE_COMPANY_NAME},
4808
9043553faa1c (svn r6730) Fix: Make Build HQ and Relocate HQ buttons of Player window behave as normal placement buttons, and not as push buttons.
belugas
parents: 4805
diff changeset
   627
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   266,   355,    18,    29, STR_7072_VIEW_HQ,                  STR_7070_BUILD_COMPANY_HEADQUARTERS},
9043553faa1c (svn r6730) Fix: Make Build HQ and Relocate HQ buttons of Player window behave as normal placement buttons, and not as push buttons.
belugas
parents: 4805
diff changeset
   628
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   266,   355,    32,    43, STR_RELOCATE_HQ,                   STR_RELOCATE_COMPANY_HEADQUARTERS},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
   629
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   179,   158,   169, STR_7077_BUY_25_SHARE_IN_COMPANY,  STR_7079_BUY_25_SHARE_IN_THIS_COMPANY},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
   630
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   180,   359,   158,   169, STR_7078_SELL_25_SHARE_IN_COMPANY, STR_707A_SELL_25_SHARE_IN_THIS_COMPANY},
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   631
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   266,   355,   138,   149, STR_COMPANY_PASSWORD,              STR_COMPANY_PASSWORD_TOOLTIP},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   632
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   633
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   634
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
   635
static void DrawPlayerVehiclesAmount(PlayerID player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   637
	const int x = 110;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   638
	int y = 72;
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   639
	const Vehicle *v;
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   640
	uint train = 0;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   641
	uint road  = 0;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   642
	uint air   = 0;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   643
	uint ship  = 0;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   644
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   645
	DrawString(x, y, STR_7039_VEHICLES, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   646
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   647
	FOR_ALL_VEHICLES(v) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
		if (v->owner == player) {
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   649
			switch (v->type) {
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   650
				case VEH_TRAIN:    if (IsFrontEngine(v)) train++; break;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   651
				case VEH_ROAD:     road++; break;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   652
				case VEH_AIRCRAFT: if (IsNormalAircraft(v)) air++; break;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   653
				case VEH_SHIP:     ship++; break;
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   654
				default: break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   655
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   656
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   657
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   658
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   659
	if (train + road + air + ship == 0) {
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   660
		DrawString(x + 70, y, STR_7042_NONE, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   661
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   662
		if (train != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   663
			SetDParam(0, train);
2246
f25de67915ee (svn r2766) Remove string and make use of the plural feature
tron
parents: 2187
diff changeset
   664
			DrawString(x + 70, y, STR_TRAINS, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   665
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   667
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   668
		if (road != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   669
			SetDParam(0, road);
2246
f25de67915ee (svn r2766) Remove string and make use of the plural feature
tron
parents: 2187
diff changeset
   670
			DrawString(x + 70, y, STR_ROAD_VEHICLES, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   671
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   672
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   673
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   674
		if (air != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   675
			SetDParam(0, air);
2246
f25de67915ee (svn r2766) Remove string and make use of the plural feature
tron
parents: 2187
diff changeset
   676
			DrawString(x + 70, y, STR_AIRCRAFT, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   677
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   678
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   680
		if (ship != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   681
			SetDParam(0, ship);
2246
f25de67915ee (svn r2766) Remove string and make use of the plural feature
tron
parents: 2187
diff changeset
   682
			DrawString(x + 70, y, STR_SHIPS, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   683
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   684
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   685
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   686
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
   687
int GetAmountOwnedBy(const Player *p, PlayerID owner)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   688
{
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   689
	return (p->share_owners[0] == owner) +
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   690
				 (p->share_owners[1] == owner) +
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   691
				 (p->share_owners[2] == owner) +
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   692
				 (p->share_owners[3] == owner);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   693
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   694
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
   695
static void DrawCompanyOwnerText(const Player *p)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   696
{
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   697
	const Player *p2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
	int num = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   699
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   700
	FOR_ALL_PLAYERS(p2) {
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
   701
		uint amt = GetAmountOwnedBy(p, p2->index);
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
   702
		if (amt != 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   703
			num++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   704
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
   705
			SetDParam(num * 3 + 0, amt * 25);
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
   706
			SetDParam(num * 3 + 1, p2->name_1);
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
   707
			SetDParam(num * 3 + 2, p2->name_2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   708
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
   709
			if (num != 0) break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   710
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   711
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
   713
	if (num >= 0) DrawString(120, 124, STR_707D_OWNED_BY + num, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   714
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   715
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   716
static void PlayerCompanyWndProc(BaseWindow *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   717
{
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
   718
	switch (e->event) {
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   719
		case WE_PAINT: {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   720
			const Player *p = GetPlayer((PlayerID)w->window_number);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   721
			bool local = w->window_number == _local_player;
1811
9012558a2b02 (svn r2315) - Fix: [ 1187613 ] No HQ present for competitor, disable 'View HQ' button, inspired by lucaspiller
Darkvater
parents: 1793
diff changeset
   722
6250
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   723
			w->SetWidgetHiddenState(PCW_WIDGET_NEW_FACE,       !local);
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   724
			w->SetWidgetHiddenState(PCW_WIDGET_COLOR_SCHEME,   !local);
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   725
			w->SetWidgetHiddenState(PCW_WIDGET_PRESIDENT_NAME, !local);
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   726
			w->SetWidgetHiddenState(PCW_WIDGET_COMPANY_NAME,   !local);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   727
			w->widget[PCW_WIDGET_BUILD_VIEW_HQ].data = (local && p->location_of_house == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
4808
9043553faa1c (svn r6730) Fix: Make Build HQ and Relocate HQ buttons of Player window behave as normal placement buttons, and not as push buttons.
belugas
parents: 4805
diff changeset
   728
			if (local && p->location_of_house != 0) w->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
6246
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6241
diff changeset
   729
			w->SetWidgetDisabledState(PCW_WIDGET_BUILD_VIEW_HQ, !local && p->location_of_house == 0);
6250
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   730
			w->SetWidgetHiddenState(PCW_WIDGET_RELOCATE_HQ,      !local || p->location_of_house == 0);
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   731
			w->SetWidgetHiddenState(PCW_WIDGET_BUY_SHARE,        local);
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   732
			w->SetWidgetHiddenState(PCW_WIDGET_SELL_SHARE,       local);
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   733
			w->SetWidgetHiddenState(PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
930
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   734
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   735
			if (!local) {
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   736
				if (_patches.allow_shares) { // Shares are allowed
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   737
					/* If all shares are owned by someone (none by nobody), disable buy button */
6246
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6241
diff changeset
   738
					w->SetWidgetDisabledState(PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 ||
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   739
							/* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */
4848
56549aa3e234 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
   740
							(GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) ||
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   741
							/* Spectators cannot do anything of course */
4848
56549aa3e234 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
   742
							_local_player == PLAYER_SPECTATOR);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   743
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   744
					/* If the player doesn't own any shares, disable sell button */
6246
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6241
diff changeset
   745
					w->SetWidgetDisabledState(PCW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(p, _local_player) == 0) ||
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   746
							/* Spectators cannot do anything of course */
4848
56549aa3e234 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
   747
							_local_player == PLAYER_SPECTATOR);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   748
				} else { // Shares are not allowed, disable buy/sell buttons
6247
67e881450cf3 (svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
KUDr
parents: 6246
diff changeset
   749
					w->DisableWidget(PCW_WIDGET_BUY_SHARE);
67e881450cf3 (svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
KUDr
parents: 6246
diff changeset
   750
					w->DisableWidget(PCW_WIDGET_SELL_SHARE);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   751
				}
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   752
			}
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   753
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   754
			SetDParam(0, p->name_1);
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   755
			SetDParam(1, p->name_2);
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   756
			SetDParam(2, GetPlayerNameString((PlayerID)w->window_number, 3));
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   757
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6237
diff changeset
   758
			w->DrawWidgets();
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   759
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   760
			SetDParam(0, p->inaugurated_year);
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   761
			DrawString(110, 25, STR_7038_INAUGURATED, 0);
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   762
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   763
			DrawPlayerVehiclesAmount((PlayerID)w->window_number);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   764
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   765
			DrawString(110, 48, STR_7006_COLOR_SCHEME, 0);
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   766
			/* Draw company-colour bus */
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5838
diff changeset
   767
			DrawSprite(SPR_VEH_BUS_SW_VIEW, PLAYER_SPRITE_COLOR(p->index), 215, 49);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   768
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   769
			DrawPlayerFace(p->face, p->player_color, 2, 16);
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   770
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   771
			SetDParam(0, p->president_name_1);
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   772
			SetDParam(1, p->president_name_2);
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   773
			DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94);
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   774
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   775
			SetDParam64(0, CalculateCompanyValue(p));
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   776
			DrawString(110, 114, STR_7076_COMPANY_VALUE, 0);
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   777
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   778
			DrawCompanyOwnerText(p);
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   779
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   780
			break;
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   781
		}
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   782
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   783
		case WE_CLICK:
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   784
			switch (e->we.click.widget) {
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   785
				case PCW_WIDGET_NEW_FACE: {
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   786
					BaseWindow *wf = BaseWindow::AllocateFront(&_select_player_face_desc, w->window_number);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   787
					if (wf != NULL) {
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   788
						wf->caption_color = w->window_number;
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   789
						WP(wf, facesel_d).face = GetPlayer((PlayerID)wf->window_number)->face;
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   790
						WP(wf, facesel_d).gender = 0;
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   791
					}
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   792
					break;
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   793
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   794
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   795
				case PCW_WIDGET_COLOR_SCHEME: {
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   796
					BaseWindow *wf = BaseWindow::AllocateFront(_have_2cc ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   797
					if (wf != NULL) {
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   798
						wf->caption_color = wf->window_number;
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   799
						WP(wf, livery_d).livery_class = LC_OTHER;
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   800
						WP(wf, livery_d).sel = 1;
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   801
						wf->LowerWidget(2);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   802
					}
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   803
					break;
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   804
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   805
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   806
				case PCW_WIDGET_PRESIDENT_NAME: {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   807
					const Player *p = GetPlayer((PlayerID)w->window_number);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   808
					WP(w, def_d).byte_1 = 0;
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   809
					SetDParam(0, p->president_name_2);
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5273
diff changeset
   810
					ShowQueryString(p->president_name_1, STR_700B_PRESIDENT_S_NAME, 31, 94, w, CS_ALPHANUMERAL);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   811
					break;
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   812
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   813
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   814
				case PCW_WIDGET_COMPANY_NAME: {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   815
					Player *p = GetPlayer((PlayerID)w->window_number);
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   816
					WP(w, def_d).byte_1 = 1;
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   817
					SetDParam(0, p->name_2);
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5273
diff changeset
   818
					ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w, CS_ALPHANUMERAL);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   819
					break;
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   820
				}
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   821
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   822
				case PCW_WIDGET_BUILD_VIEW_HQ: {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   823
					TileIndex tile = GetPlayer((PlayerID)w->window_number)->location_of_house;
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   824
					if (tile == 0) {
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   825
						if ((byte)w->window_number != _local_player)
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   826
							return;
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5838
diff changeset
   827
						SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, 1, w);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   828
						SetTileSelectSize(2, 2);
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   829
						w->LowerWidget(PCW_WIDGET_BUILD_VIEW_HQ);
6237
bce32e54c993 (svn r8695) [cpp_gui] -Codechange: changed AssignWidgetToWindow() and InvalidateWidget() into Window methods
bjarni
parents: 6235
diff changeset
   830
						w->InvalidateWidget(PCW_WIDGET_BUILD_VIEW_HQ);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   831
					} else {
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   832
						ScrollMainWindowToTile(tile);
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   833
					}
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   834
					break;
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   835
				}
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   836
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   837
				case PCW_WIDGET_RELOCATE_HQ:
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5838
diff changeset
   838
					SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, 1, w);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   839
					SetTileSelectSize(2, 2);
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   840
					w->LowerWidget(PCW_WIDGET_RELOCATE_HQ);
6237
bce32e54c993 (svn r8695) [cpp_gui] -Codechange: changed AssignWidgetToWindow() and InvalidateWidget() into Window methods
bjarni
parents: 6235
diff changeset
   841
					w->InvalidateWidget(PCW_WIDGET_RELOCATE_HQ);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   842
					break;
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   843
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   844
				case PCW_WIDGET_BUY_SHARE:
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   845
					DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS));
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   846
					break;
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   847
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   848
				case PCW_WIDGET_SELL_SHARE:
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   849
					DoCommandP(0, w->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN));
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   850
					break;
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   851
4830
0ff2a14e90be (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4808
diff changeset
   852
				#ifdef ENABLE_NETWORK
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   853
				case PCW_WIDGET_COMPANY_PASSWORD:
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   854
					if (w->window_number == _local_player) {
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   855
						WP(w, def_d).byte_1 = 2;
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   856
						ShowQueryString(BindCString(_network_player_info[_local_player].password),
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5273
diff changeset
   857
							STR_SET_COMPANY_PASSWORD, sizeof(_network_player_info[_local_player].password), 250, w, CS_ALPHANUMERAL);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   858
					}
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   859
					break;
4830
0ff2a14e90be (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4808
diff changeset
   860
				#endif /* ENABLE_NETWORK */
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   861
			}
917
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   862
			break;
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   863
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   864
		case WE_MOUSELOOP:
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   865
			/* redraw the window every now and then */
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   866
			if ((++w->vscroll.pos & 0x1F) == 0) w->SetDirty();
917
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   867
			break;
147
d0c8100d18cf (svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents: 16
diff changeset
   868
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   869
		case WE_PLACE_OBJ:
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   870
			if (DoCommandP(e->we.place.tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   871
				ResetObjectToPlace();
4808
9043553faa1c (svn r6730) Fix: Make Build HQ and Relocate HQ buttons of Player window behave as normal placement buttons, and not as push buttons.
belugas
parents: 4805
diff changeset
   872
				w->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   873
				w->RaiseButtons();
4808
9043553faa1c (svn r6730) Fix: Make Build HQ and Relocate HQ buttons of Player window behave as normal placement buttons, and not as push buttons.
belugas
parents: 4805
diff changeset
   874
			break;
9043553faa1c (svn r6730) Fix: Make Build HQ and Relocate HQ buttons of Player window behave as normal placement buttons, and not as push buttons.
belugas
parents: 4805
diff changeset
   875
9043553faa1c (svn r6730) Fix: Make Build HQ and Relocate HQ buttons of Player window behave as normal placement buttons, and not as push buttons.
belugas
parents: 4805
diff changeset
   876
		case WE_ABORT_PLACE_OBJ:
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   877
			w->RaiseButtons();
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   878
			break;
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   879
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   880
		case WE_DESTROY:
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   881
			DeleteWindowById(WC_PLAYER_FACE, w->window_number);
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   882
			break;
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   883
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   884
		case WE_ON_EDIT_TEXT: {
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   885
			char *b = e->we.edittext.str;
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   886
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   887
			/* empty string is allowed for password */
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   888
			if (*b == '\0' && WP(w, def_d).byte_1 != 2) return;
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   889
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   890
			_cmd_text = b;
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   891
			switch (WP(w, def_d).byte_1) {
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   892
				case 0: /* Change president name */
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   893
					DoCommandP(0, 0, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT));
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   894
					break;
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   895
				case 1: /* Change company name */
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   896
					DoCommandP(0, 0, 0, NULL, CMD_CHANGE_COMPANY_NAME | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME));
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   897
					break;
4830
0ff2a14e90be (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4808
diff changeset
   898
				#ifdef ENABLE_NETWORK
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   899
				case 2: /* Change company password */
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   900
					if (*b == '\0') *b = '*'; // empty password is a '*' because of console argument
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   901
					NetworkChangeCompanyPassword(1, &b);
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   902
					break;
4830
0ff2a14e90be (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4808
diff changeset
   903
				#endif /* ENABLE_NETWORK */
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   904
			}
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   905
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   906
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   907
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   908
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   909
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   910
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   911
static const WindowDesc _player_company_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   912
	WDP_AUTO, WDP_AUTO, 360, 170,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
   913
	WC_COMPANY, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   914
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
   915
	_player_company_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   916
	PlayerCompanyWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   917
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   918
2475
8443e1eefe1b (svn r3001) s/Player*/const Player*/
tron
parents: 2473
diff changeset
   919
void ShowPlayerCompany(PlayerID player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   920
{
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   921
	BaseWindow *w;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   922
5005
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   923
	if (!IsValidPlayer(player)) return;
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   924
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   925
	w = BaseWindow::AllocateFront(&_player_company_desc, player);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   926
	if (w != NULL) w->caption_color = w->window_number;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   927
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   928
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   929
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   930
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   931
static void BuyCompanyWndProc(BaseWindow *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   932
{
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2725
diff changeset
   933
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   934
	case WE_PAINT: {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   935
		Player *p = GetPlayer((PlayerID)w->window_number);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   936
		SetDParam(0, p->name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   937
		SetDParam(1, p->name_2);
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6237
diff changeset
   938
		w->DrawWidgets();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   939
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   940
		DrawPlayerFace(p->face, p->player_color, 2, 16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   941
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   942
		SetDParam(0, p->name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   943
		SetDParam(1, p->name_2);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   944
		SetDParam(2, p->bankrupt_value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   945
		DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   946
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   947
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   948
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   949
	case WE_CLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4605
diff changeset
   950
		switch (e->we.click.widget) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   951
		case 3:
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   952
			w->Close();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   953
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   954
		case 4: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   955
			DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   956
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   957
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   958
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   959
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   960
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   961
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   962
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   963
static const OldWidget _buy_company_widgets[] = {
3326
b5ce3e805425 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme
belugas
parents: 2952
diff changeset
   964
{   WWT_CLOSEBOX,   RESIZE_NONE,     5,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
b5ce3e805425 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme
belugas
parents: 2952
diff changeset
   965
{    WWT_CAPTION,   RESIZE_NONE,     5,    11,   333,     0,    13, STR_00B3_MESSAGE_FROM, STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   966
{      WWT_PANEL,   RESIZE_NONE,     5,     0,   333,    14,   136, 0x0,                   STR_NULL},
3326
b5ce3e805425 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme
belugas
parents: 2952
diff changeset
   967
{    WWT_TEXTBTN,   RESIZE_NONE,     5,   148,   207,   117,   128, STR_00C9_NO,           STR_NULL},
b5ce3e805425 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme
belugas
parents: 2952
diff changeset
   968
{    WWT_TEXTBTN,   RESIZE_NONE,     5,   218,   277,   117,   128, STR_00C8_YES,          STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   969
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   970
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   971
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   972
static const WindowDesc _buy_company_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   973
	153, 171, 334, 137,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
   974
	WC_BUY_COMPANY, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   975
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   976
	_buy_company_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   977
	BuyCompanyWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   978
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   979
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   980
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   981
void ShowBuyCompanyDialog(uint player)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   982
{
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   983
	BaseWindow::AllocateFront(&_buy_company_desc, player);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   984
}
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   985
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   986
/********** HIGHSCORE and ENDGAME windows */
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   987
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   988
/* Always draw a maximized window and within there the centered background */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
   989
static void SetupHighScoreEndWindow(BaseWindow *w, uint *x, uint *y)
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   990
{
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   991
	uint i;
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   992
	/* resize window to "full-screen" */
6263
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6258
diff changeset
   993
	w->SetSize(Point(_screen.width, _screen.height));
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6258
diff changeset
   994
	w->widget[0].right = _screen.width - 1;
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6258
diff changeset
   995
	w->widget[0].bottom = _screen.height - 1;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   996
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6237
diff changeset
   997
	w->DrawWidgets();
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   998
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   999
	/* Center Highscore/Endscreen background */
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1000
	*x = max(0, (_screen.width  / 2) - (640 / 2));
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1001
	*y = max(0, (_screen.height / 2) - (480 / 2));
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1002
	for (i = 0; i < 10; i++) // the image is split into 10 50px high parts
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5838
diff changeset
  1003
		DrawSprite(WP(w, highscore_d).background_img + i, PAL_NONE, *x, *y + (i * 50));
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1004
}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1005
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1006
extern StringID EndGameGetPerformanceTitleFromValue(uint value);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1007
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
  1008
/** End game window shown at the end of the game */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
  1009
static void EndGameWndProc(BaseWindow *w, WindowEvent *e)
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1010
{
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1011
	switch (e->event) {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1012
	case WE_PAINT: {
4998
d9824e2539a2 (svn r7008) -Fix [FS#369]: Crash at game end when server company is bankrupt
Darkvater
parents: 4938
diff changeset
  1013
		const Player *p;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1014
		uint x, y;
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1015
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1016
		SetupHighScoreEndWindow(w, &x, &y);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1017
4998
d9824e2539a2 (svn r7008) -Fix [FS#369]: Crash at game end when server company is bankrupt
Darkvater
parents: 4938
diff changeset
  1018
		if (!IsValidPlayer(_local_player)) break;
d9824e2539a2 (svn r7008) -Fix [FS#369]: Crash at game end when server company is bankrupt
Darkvater
parents: 4938
diff changeset
  1019
d9824e2539a2 (svn r7008) -Fix [FS#369]: Crash at game end when server company is bankrupt
Darkvater
parents: 4938
diff changeset
  1020
		p = GetPlayer(_local_player);
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1021
		/* We need to get performance from last year because the image is shown
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1022
		 * at the start of the new year when these things have already been copied */
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
  1023
		if (WP(w, highscore_d).background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1024
			SetDParam(0, p->president_name_1);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1025
			SetDParam(1, p->president_name_2);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1026
			SetDParam(2, p->name_1);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1027
			SetDParam(3, p->name_2);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1028
			SetDParam(4, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history));
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1029
			DrawStringMultiCenter(x + (640 / 2), y + 107, STR_021C_OF_ACHIEVES_STATUS, 640);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1030
		} else {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1031
			SetDParam(0, p->name_1);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1032
			SetDParam(1, p->name_2);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1033
			SetDParam(2, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history));
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1034
			DrawStringMultiCenter(x + (640 / 2), y + 157, STR_021B_ACHIEVES_STATUS, 640);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1035
		}
1017
608592d4d7a6 (svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents: 1016
diff changeset
  1036
	} break;
1839
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1037
	case WE_CLICK: /* Close the window (and show the highscore window) */
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
  1038
		w->Close();
1875
3a1dba8ed6ea (svn r2381) - Fix: [ 1210610 ] Endgame window on easy difficulty results in infinite loop. Oops. Seperated the window classes of endgame and highscreen.
Darkvater
parents: 1839
diff changeset
  1039
		break;
1839
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1040
	case WE_DESTROY: /* Show the highscore window when this one is closed */
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1041
		if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1042
		ShowHighscoreTable(w->window_number, WP(w, highscore_d).rank);
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1043
		break;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1044
	}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1045
}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1046
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
  1047
static void HighScoreWndProc(BaseWindow *w, WindowEvent *e)
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1048
{
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1049
	switch (e->event) {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1050
	case WE_PAINT: {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1051
		const HighScore *hs = _highscore_table[w->window_number];
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
  1052
		uint x, y;
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
  1053
		uint8 i;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1054
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1055
		SetupHighScoreEndWindow(w, &x, &y);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1056
4285
72b3f7d6c891 (svn r5915) -Cleanup: some variables were named *_date while they were only holding years; rename these variables to match this.
rubidium
parents: 4261
diff changeset
  1057
		SetDParam(0, _patches.ending_year);
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
  1058
		SetDParam(1, w->window_number + STR_6801_EASY);
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
  1059
		DrawStringMultiCenter(x + (640 / 2), y + 62, !_networking ? STR_0211_TOP_COMPANIES_WHO_REACHED : STR_TOP_COMPANIES_NETWORK_GAME, 500);
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1060
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1061
		/* Draw Highscore peepz */
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1062
		for (i = 0; i < lengthof(_highscore_table[0]); i++) {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1063
			SetDParam(0, i + 1);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1064
			DrawString(x + 40, y + 140 + (i * 55), STR_0212, 0x10);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1065
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1066
			if (hs[i].company[0] != '\0') {
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
  1067
				uint16 colour = (WP(w, highscore_d).rank == (int8)i) ? 0x3 : 0x10; // draw new highscore in red
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1068
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1069
				DoDrawString(hs[i].company, x + 71, y + 140 + (i * 55), colour);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1070
				SetDParam(0, hs[i].title);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1071
				SetDParam(1, hs[i].score);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1072
				DrawString(x + 71, y + 160 + (i * 55), STR_HIGHSCORE_STATS, colour);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1073
			}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1074
		}
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1017
diff changeset
  1075
	} break;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1076
1839
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1077
	case WE_CLICK: /* Onclick to close window, and in destroy event handle the rest */
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
  1078
		w->Close();
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1079
		break;
1839
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1080
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1081
	case WE_DESTROY: /* Get back all the hidden windows */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
  1082
		if (_game_mode != GM_MENU) BaseWindow::ShowVitalWindows();
1839
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1083
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1084
		if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1085
		break;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1086
	}
1839
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1087
	}
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1088
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
  1089
static const OldWidget _highscore_widgets[] = {
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1090
{      WWT_PANEL, RESIZE_NONE, 16, 0, 640, 0, 480, 0x0, STR_NULL},
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1091
{   WIDGETS_END},
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1092
};
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1093
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1094
static const WindowDesc _highscore_desc = {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1095
	0, 0, 641, 481,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
  1096
	WC_HIGHSCORE, WC_NONE,
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1097
	0,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1098
	_highscore_widgets,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1099
	HighScoreWndProc
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1100
};
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1101
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1102
static const WindowDesc _endgame_desc = {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1103
	0, 0, 641, 481,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
  1104
	WC_ENDSCREEN, WC_NONE,
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1105
	0,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1106
	_highscore_widgets,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1107
	EndGameWndProc
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1108
};
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1109
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
  1110
/** Show the highscore table for a given difficulty. When called from
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1111
 * endgame ranking is set to the top5 element that was newly added
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1112
 * and is thus highlighted */
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
  1113
void ShowHighscoreTable(int difficulty, int8 ranking)
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1114
{
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
  1115
	BaseWindow *w;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1116
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
  1117
	/* pause game to show the chart */
1839
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1118
	if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1119
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1120
	/* Close all always on-top windows to get a clean screen */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
  1121
	if (_game_mode != GM_MENU) BaseWindow::HideVitalWindows();
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1122
1875
3a1dba8ed6ea (svn r2381) - Fix: [ 1210610 ] Endgame window on easy difficulty results in infinite loop. Oops. Seperated the window classes of endgame and highscreen.
Darkvater
parents: 1839
diff changeset
  1123
	DeleteWindowByClass(WC_HIGHSCORE);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
  1124
	w = BaseWindow::Allocate(&_highscore_desc);
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1125
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1126
	if (w != NULL) {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1127
		MarkWholeScreenDirty();
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1128
		w->window_number = difficulty; // show highscore chart for difficulty...
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
  1129
		WP(w, highscore_d).background_img = SPR_HIGHSCORE_CHART_BEGIN; // which background to show
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
  1130
		WP(w, highscore_d).rank = ranking;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1131
	}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1132
}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1133
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
  1134
/** Show the endgame victory screen in 2050. Update the new highscore
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1135
 * if it was high enough */
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
  1136
void ShowEndGameChart()
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1137
{
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
  1138
	BaseWindow *w;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1139
1839
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1140
	/* Dedicated server doesn't need the highscore window */
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1141
	if (_network_dedicated) return;
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1142
	/* Pause in single-player to have a look at the highscore at your own leisure */
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1143
	if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1144
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
  1145
	BaseWindow::HideVitalWindows();
1875
3a1dba8ed6ea (svn r2381) - Fix: [ 1210610 ] Endgame window on easy difficulty results in infinite loop. Oops. Seperated the window classes of endgame and highscreen.
Darkvater
parents: 1839
diff changeset
  1146
	DeleteWindowByClass(WC_ENDSCREEN);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6251
diff changeset
  1147
	w = BaseWindow::Allocate(&_endgame_desc);
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1148
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1149
	if (w != NULL) {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1150
		MarkWholeScreenDirty();
1077
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1151
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1152
		WP(w, highscore_d).background_img = SPR_TYCOON_IMG1_BEGIN;
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1153
4848
56549aa3e234 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
  1154
		if (_local_player != PLAYER_SPECTATOR) {
1962
51ee4f459268 (svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents: 1914
diff changeset
  1155
			const Player *p = GetPlayer(_local_player);
1077
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1156
			if (p->old_economy[0].performance_history == SCORE_MAX)
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1157
				WP(w, highscore_d).background_img = SPR_TYCOON_IMG2_BEGIN;
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1158
		}
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1159
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
  1160
		/* In a network game show the endscores of the custom difficulty 'network' which is the last one
1077
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1161
		 * as well as generate a TOP5 of that game, and not an all-time top5. */
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1162
		if (_networking) {
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1163
			w->window_number = lengthof(_highscore_table) - 1;
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1164
			WP(w, highscore_d).rank = SaveHighScoreValueNetwork();
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1165
		} else {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
  1166
			/* in single player _local player is always valid */
1962
51ee4f459268 (svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents: 1914
diff changeset
  1167
			const Player *p = GetPlayer(_local_player);
1077
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1168
			w->window_number = _opt.diff_level;
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1169
			WP(w, highscore_d).rank = SaveHighScoreValue(p);
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1170
		}
1109
1bab892228cd (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents: 1077
diff changeset
  1171
	}
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1172
}