src/player_gui.cpp
author glx
Tue, 13 May 2008 01:05:39 +0000
changeset 9198 7cb23ea1b7b8
parent 9164 18e971e0b44f
child 9203 082fbf0500c4
permissions -rw-r--r--
(svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 9094
diff changeset
     3
/** @file player_gui.cpp Player related GUIs. */
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1875
diff changeset
     6
#include "openttd.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     8
#include "window_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     9
#include "textbuf_gui.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    10
#include "viewport_func.h"
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    11
#include "gfx_func.h"
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    12
#include "player_func.h"
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    13
#include "player_base.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    14
#include "command_func.h"
5469
7edfc643abbc (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: 5431
diff changeset
    15
#include "network/network.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2064
diff changeset
    16
#include "variables.h"
6857
60130753e595 (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 6769
diff changeset
    17
#include "roadveh.h"
2676
59b65b4fb480 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2642
diff changeset
    18
#include "train.h"
5854
9eee280920f0 (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: 5668
diff changeset
    19
#include "aircraft.h"
4742
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
    20
#include "newgrf.h"
5469
7edfc643abbc (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: 5431
diff changeset
    21
#include "network/network_data.h"
7edfc643abbc (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: 5431
diff changeset
    22
#include "network/network_client.h"
7998
9cf9f9153262 (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents: 7997
diff changeset
    23
#include "network/network_gui.h"
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
    24
#include "player_face.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8107
diff changeset
    25
#include "strings_func.h"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8121
diff changeset
    26
#include "functions.h"
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8121
diff changeset
    27
#include "window_func.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8131
diff changeset
    28
#include "date_func.h"
8214
971f861d5543 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8144
diff changeset
    29
#include "string_func.h"
8270
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8264
diff changeset
    30
#include "settings_type.h"
8284
ebdc5ba08874 (svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents: 8270
diff changeset
    31
#include "widgets/dropdown_func.h"
8908
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
    32
#include "widgets/dropdown_type.h"
9127
14f21c5954ee (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 9116
diff changeset
    33
#include "tilehighlight_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    35
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    36
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    37
9153
d1d16656129b (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 9143
diff changeset
    38
struct highscore_d {
d1d16656129b (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 9143
diff changeset
    39
	uint32 background_img;
d1d16656129b (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 9143
diff changeset
    40
	int8 rank;
d1d16656129b (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 9143
diff changeset
    41
};
d1d16656129b (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 9143
diff changeset
    42
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d));
d1d16656129b (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 9143
diff changeset
    43
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
    44
enum {
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
    45
	FIRST_GUI_CALL = INT_MAX,  ///< default value to specify thuis is the first call of the resizable gui
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
    46
};
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
    47
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
    48
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied, int top = FIRST_GUI_CALL, int left = FIRST_GUI_CALL);
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
    49
static void DoSelectPlayerFace(PlayerID player, bool show_big, int top =  FIRST_GUI_CALL, int left = FIRST_GUI_CALL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
    51
static void DrawPlayerEconomyStats(const Player *p, byte mode)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
{
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6352
diff changeset
    53
	int x, y, i, j, year;
8515
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8343
diff changeset
    54
	const Money (*tbl)[EXPENSES_END];
6990
136a08baf0ed (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 6952
diff changeset
    55
	Money sum, cost;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	StringID str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
186
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    58
	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
    59
		/* draw categories */
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
    60
		DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, TC_FROMSTRING);
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
    61
		for (i = 0; i != EXPENSES_END; i++)
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
    62
			DrawString(2, 27 + i * 10, STR_7011_CONSTRUCTION + i, TC_FROMSTRING);
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
    63
		DrawStringRightAligned(111, 27 + 10 * EXPENSES_END + 2, STR_7020_TOTAL, TC_FROMSTRING);
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
    64
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
		/* draw the price columns */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
		year = _cur_year - 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
		j = 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
		x = 215;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
		tbl = p->yearly_expenses + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
		do {
4329
0e6e689f66e7 (svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents: 4314
diff changeset
    71
			if (year >= p->inaugurated_year) {
4293
4b7006c1b5eb (svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents: 4286
diff changeset
    72
				SetDParam(0, year);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
    73
				DrawStringRightAlignedUnderline(x, 15, STR_7010, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
				sum = 0;
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
    75
				for (i = 0; i != EXPENSES_END; i++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
					/* draw one row in the price column */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
					cost = (*tbl)[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
					if (cost != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
						sum += cost;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
    80
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
						str = STR_701E;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
						if (cost < 0) { cost = -cost; str++; }
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
    83
						SetDParam(0, cost);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
    84
						DrawStringRightAligned(x, 27 + i * 10, str, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
				str = STR_701E;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
				if (sum < 0) { sum = -sum; str++; }
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
    90
				SetDParam(0, sum);
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
    91
				DrawStringRightAligned(x, 27 + EXPENSES_END * 10 + 2, str, TC_FROMSTRING);
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
    92
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
    93
				GfxFillRect(x - 75, 27 + 10 * EXPENSES_END, x, 27 + 10 * EXPENSES_END, 215);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
				x += 95;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
			year++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
			tbl--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
		} while (--j != 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
   100
		y = 27 + 10 * EXPENSES_END + 14;
186
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
   101
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
   102
		/* draw max loan aligned to loan below (y += 10) */
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
   103
		SetDParam(0, _economy.max_loan);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   104
		DrawString(202, y + 10, STR_MAX_LOAN, TC_FROMSTRING);
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   105
	} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
		y = 15;
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   107
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   109
	DrawString(2, y, STR_7026_BANK_BALANCE, TC_FROMSTRING);
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
   110
	SetDParam(0, p->player_money);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   111
	DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
	y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   115
	DrawString(2, y, STR_7027_LOAN, TC_FROMSTRING);
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
   116
	SetDParam(0, p->current_loan);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   117
	DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	y += 12;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6352
diff changeset
   121
	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
   122
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
   123
	SetDParam(0, p->player_money - p->current_loan);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   124
	DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   127
enum PlayerFinancesWindowWidgets {
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   128
	PFW_WIDGET_TOGGLE_SIZE   = 2,
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   129
	PFW_WIDGET_INCREASE_LOAN = 6,
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   130
	PFW_WIDGET_REPAY_LOAN    = 7,
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   131
};
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   132
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
static const Widget _player_finances_widgets[] = {
4937
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   134
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   135
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   379,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   136
{     WWT_IMGBTN,   RESIZE_NONE,    14,   380,   394,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   137
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   395,   406,     0,    13, 0x0,                    STR_STICKY_BUTTON},
8969
6d1c74e0e2cd (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 8960
diff changeset
   138
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   406,    14, 39 + 10 * EXPENSES_END, 0x0,    STR_NULL},
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
   139
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   406, 40 + 10 * EXPENSES_END, 73 + 10 * EXPENSES_END, 0x0, STR_NULL},
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
   140
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   202, 74 + 10 * EXPENSES_END, 85 + 10 * EXPENSES_END, STR_7029_BORROW,        STR_7035_INCREASE_SIZE_OF_LOAN},
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
   141
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   203,   406, 74 + 10 * EXPENSES_END, 85 + 10 * EXPENSES_END, 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
   142
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
static const Widget _player_finances_small_widgets[] = {
4937
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   146
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   147
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   253,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   148
{     WWT_IMGBTN,   RESIZE_NONE,    14,   254,   267,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   149
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   268,   279,     0,    13, 0x0,                    STR_STICKY_BUTTON},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   150
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                    STR_NULL},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   151
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   279,    14,    47, STR_NULL,               STR_NULL},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   152
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   139,    48,    59, STR_7029_BORROW,        STR_7035_INCREASE_SIZE_OF_LOAN},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   153
{ 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
   154
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
static void PlayerFinancesWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2725
diff changeset
   160
	switch (e->event) {
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   161
		case WE_PAINT: {
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   162
			PlayerID player = (PlayerID)w->window_number;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   163
			const Player *p = GetPlayer(player);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   165
			/* Recheck the size of the window as it might need to be resized due to the local player changing */
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
   166
			int new_height = ((player != _local_player) ? 0 : 12) + ((WP(w, def_d).data_1 != 0) ? 48 : 74 + 10 * EXPENSES_END);
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   167
			if (w->height != new_height) {
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   168
				/* Make window dirty before and after resizing */
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9115
diff changeset
   169
				w->SetDirty();
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   170
				w->height = new_height;
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9115
diff changeset
   171
				w->SetDirty();
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   172
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   173
				w->SetWidgetHiddenState(PFW_WIDGET_INCREASE_LOAN, player != _local_player);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   174
				w->SetWidgetHiddenState(PFW_WIDGET_REPAY_LOAN,    player != _local_player);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   175
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   177
			/* Borrow button only shows when there is any more money to loan */
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   178
			w->SetWidgetDisabledState(PFW_WIDGET_INCREASE_LOAN, p->current_loan == _economy.max_loan);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   180
			/* Repay button only shows when there is any more money to repay */
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   181
			w->SetWidgetDisabledState(PFW_WIDGET_REPAY_LOAN, player != _local_player || p->current_loan == 0);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   182
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   183
			SetDParam(0, p->index);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   184
			SetDParam(1, p->index);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   185
			SetDParam(2, LOAN_INTERVAL);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   186
			DrawWindowWidgets(w);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   187
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   188
			DrawPlayerEconomyStats(p, (byte)WP(w, def_d).data_1);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   189
		} break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   190
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   191
		case WE_CLICK:
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   192
			switch (e->we.click.widget) {
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   193
				case PFW_WIDGET_TOGGLE_SIZE: {/* toggle size */
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   194
					byte mode = (byte)WP(w, def_d).data_1;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   195
					bool stickied = !!(w->flags4 & WF_STICKY);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   196
					int oldtop = w->top;   ///< current top position of the window before closing it
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   197
					int oldleft = w->left; ///< current left position of the window before closing it
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   198
					PlayerID player = (PlayerID)w->window_number;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   199
9115
47ae980bace3 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 9111
diff changeset
   200
					delete w;
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   201
					/* Open up the (toggled size) Finance window at the same position as the previous */
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   202
					DoShowPlayerFinances(player, !HasBit(mode, 0), stickied, oldtop, oldleft);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   203
				}
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   204
				break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   205
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   206
				case PFW_WIDGET_INCREASE_LOAN: /* increase loan */
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   207
					DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY));
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   208
					break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   209
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   210
				case PFW_WIDGET_REPAY_LOAN: /* repay loan */
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   211
					DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN));
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   212
					break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   213
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
	}
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 _player_finances_desc = {
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
   219
	WDP_AUTO, WDP_AUTO, 407, 86 + 10 * EXPENSES_END, 407, 86 + 10 * EXPENSES_END,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
   220
	WC_FINANCES, WC_NONE,
2064
e6a2b42d0b15 (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
	_player_finances_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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
static const WindowDesc _player_finances_small_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   227
	WDP_AUTO, WDP_AUTO, 280, 60, 280, 60,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
   228
	WC_FINANCES, WC_NONE,
2064
e6a2b42d0b15 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   229
	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
   230
	_player_finances_small_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
	PlayerFinancesWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   234
/**
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   235
 * Open the small/large finance window of the player
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   236
 *
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   237
 * @param player         the player who's finances are requested to be seen
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   238
 * @param show_small     show large or small version opf the window
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   239
 * @param show_stickied  previous "stickyness" of the window
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   240
 * @param top            previous top position of the window
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   241
 * @param left           previous left position of the window
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   242
 *
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   243
 * @pre is player a valid player
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   244
 */
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   245
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied, int top, int left)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
{
5005
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   247
	if (!IsValidPlayer(player)) return;
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   248
9143
029e126e3439 (svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
rubidium
parents: 9142
diff changeset
   249
	Window *w = AllocateWindowDescFront<Window>(show_small ? &_player_finances_small_desc : &_player_finances_desc, player);
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
   250
	if (w != NULL) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
		w->caption_color = w->window_number;
7513
4be1c3af32b7 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium
parents: 7341
diff changeset
   252
		WP(w, def_d).data_1 = show_small;
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   253
5005
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   254
		if (show_stickied) w->flags4 |= WF_STICKY;
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   255
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   256
		/* Check if repositioning from default is required */
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   257
		if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) {
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   258
			w->top = top;
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   259
			w->left = left;
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   260
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
2475
efdcc705cb61 (svn r3001) s/Player*/const Player*/
tron
parents: 2473
diff changeset
   264
void ShowPlayerFinances(PlayerID player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
{
888
a299cab0927e (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   266
	DoShowPlayerFinances(player, false, false);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
4603
20c816f664de (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
/* List of colours for the livery window */
20c816f664de (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
static const StringID _colour_dropdown[] = {
20c816f664de (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
	STR_00D1_DARK_BLUE,
20c816f664de (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
	STR_00D2_PALE_GREEN,
20c816f664de (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
	STR_00D3_PINK,
20c816f664de (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
	STR_00D4_YELLOW,
20c816f664de (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
	STR_00D5_RED,
20c816f664de (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
   276
	STR_00D6_LIGHT_BLUE,
20c816f664de (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
	STR_00D7_GREEN,
20c816f664de (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
	STR_00D8_DARK_GREEN,
20c816f664de (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
	STR_00D9_BLUE,
20c816f664de (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
	STR_00DA_CREAM,
20c816f664de (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
	STR_00DB_MAUVE,
20c816f664de (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
	STR_00DC_PURPLE,
20c816f664de (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
	STR_00DD_ORANGE,
20c816f664de (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
	STR_00DE_BROWN,
20c816f664de (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
   285
	STR_00DF_GREY,
20c816f664de (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
	STR_00E0_WHITE,
20c816f664de (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
};
20c816f664de (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
20c816f664de (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
/* Association of liveries to livery classes */
20c816f664de (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
static const LiveryClass livery_class[LS_END] = {
20c816f664de (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
   291
	LC_OTHER,
8309
5d3e63cd70e0 (svn r11874) -Fix [FS#1655]: all wagons of maglev/monorail trains would get the livery colour of the engine instead of their wagon type.
rubidium
parents: 8284
diff changeset
   292
	LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL,
4603
20c816f664de (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
	LC_ROAD, LC_ROAD,
20c816f664de (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
   294
	LC_SHIP, LC_SHIP,
20c816f664de (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
	LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT,
6724
4f404dfe9752 (svn r9956) -Codechange: Add tram livery schemes
peter1138
parents: 6491
diff changeset
   296
	LC_ROAD, LC_ROAD,
4603
20c816f664de (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
   297
};
20c816f664de (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
20c816f664de (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
/* Number of liveries in each class, used to determine the height of the livery window */
20c816f664de (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
static const byte livery_height[] = {
20c816f664de (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
	1,
8309
5d3e63cd70e0 (svn r11874) -Fix [FS#1655]: all wagons of maglev/monorail trains would get the livery colour of the engine instead of their wagon type.
rubidium
parents: 8284
diff changeset
   302
	13,
6724
4f404dfe9752 (svn r9956) -Codechange: Add tram livery schemes
peter1138
parents: 6491
diff changeset
   303
	4,
4603
20c816f664de (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
	2,
20c816f664de (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
	3,
20c816f664de (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
};
20c816f664de (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
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   308
struct livery_d {
4603
20c816f664de (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
	uint32 sel;
20c816f664de (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
	LiveryClass livery_class;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   311
};
4603
20c816f664de (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
   312
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(livery_d));
20c816f664de (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
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   314
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   315
enum PlayerLiveryWindowWidgets {
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   316
	PLW_WIDGET_CLASS_GENERAL = 2,
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   317
	PLW_WIDGET_CLASS_RAIL,
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   318
	PLW_WIDGET_CLASS_ROAD,
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   319
	PLW_WIDGET_CLASS_SHIP,
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   320
	PLW_WIDGET_CLASS_AIRCRAFT,
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   321
8343
a6b70ddd862b (svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents: 8339
diff changeset
   322
	PLW_WIDGET_PRI_COL_DROPDOWN = 9,
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   323
	PLW_WIDGET_SEC_COL_DROPDOWN,
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   324
	PLW_WIDGET_MATRIX,
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   325
};
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   326
8908
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   327
class DropDownListColourItem : public DropDownListItem {
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   328
public:
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   329
	DropDownListColourItem(int result, bool masked) : DropDownListItem(result, masked) {}
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   330
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   331
	virtual ~DropDownListColourItem() {}
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   332
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   333
	virtual StringID String() const
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   334
	{
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   335
		return _colour_dropdown[this->result];
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   336
	}
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   337
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   338
	virtual uint Height(uint width) const
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   339
	{
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   340
		return 14;
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   341
	}
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   342
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   343
	virtual void Draw(int x, int y, uint width, uint height, bool sel) const
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   344
	{
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   345
		DrawSprite(SPR_VEH_BUS_SIDE_VIEW, PALETTE_RECOLOR_START + this->result, x + 16, y + 7);
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   346
		DrawStringTruncated(x + 32, y + 3, this->String(), sel ? TC_WHITE : TC_BLACK, x + width - 30);
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   347
	}
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   348
};
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   349
4603
20c816f664de (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
static void ShowColourDropDownMenu(Window *w, uint32 widget)
20c816f664de (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
{
20c816f664de (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
   352
	uint32 used_colours = 0;
20c816f664de (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
   353
	const Livery *livery;
20c816f664de (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
   354
	LiveryScheme scheme;
20c816f664de (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
20c816f664de (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
	/* Disallow other player colours for the primary colour */
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   357
	if (HasBit(WP(w, livery_d).sel, LS_DEFAULT) && widget == PLW_WIDGET_PRI_COL_DROPDOWN) {
4603
20c816f664de (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
		const Player *p;
20c816f664de (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
		FOR_ALL_PLAYERS(p) {
7931
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7928
diff changeset
   360
			if (p->is_active && p->index != _local_player) SetBit(used_colours, p->player_color);
4603
20c816f664de (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
		}
20c816f664de (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
	}
20c816f664de (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
20c816f664de (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
	/* Get the first selected livery to use as the default dropdown item */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   365
	for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7889
diff changeset
   366
		if (HasBit(WP(w, livery_d).sel, scheme)) break;
4603
20c816f664de (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
	}
20c816f664de (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
   368
	if (scheme == LS_END) scheme = LS_DEFAULT;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   369
	livery = &GetPlayer((PlayerID)w->window_number)->livery[scheme];
4603
20c816f664de (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
   370
8908
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   371
	DropDownList *list = new DropDownList();
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   372
	for (uint i = 0; i < lengthof(_colour_dropdown); i++) {
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   373
		list->push_back(new DropDownListColourItem(i, HasBit(used_colours, i)));
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   374
	}
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   375
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   376
	ShowDropDownList(w, list, widget == PLW_WIDGET_PRI_COL_DROPDOWN ? livery->colour1 : livery->colour2, widget);
4603
20c816f664de (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
}
20c816f664de (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
20c816f664de (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
static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2725
diff changeset
   381
	switch (e->event) {
4742
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   382
		case WE_CREATE:
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   383
			w->LowerWidget(WP(w, livery_d).livery_class + PLW_WIDGET_CLASS_GENERAL);
6914
6219e65dd7bf (svn r10167) -Codechange: Change the flagging system of grf loaded feature from a bitset to a bool evaluation.
belugas
parents: 6909
diff changeset
   384
			if (!_loaded_newgrf_features.has_2CC) {
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   385
				w->HideWidget(PLW_WIDGET_SEC_COL_DROPDOWN);
4742
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   386
			}
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   387
			break;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   388
4603
20c816f664de (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
   389
		case WE_PAINT: {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   390
			const Player *p = GetPlayer((PlayerID)w->window_number);
4603
20c816f664de (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
			LiveryScheme scheme = LS_DEFAULT;
20c816f664de (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
   392
			int y = 51;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   394
			/* Disable dropdown controls if no scheme is selected */
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   395
			w->SetWidgetDisabledState(PLW_WIDGET_PRI_COL_DROPDOWN, (WP(w, livery_d).sel == 0));
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   396
			w->SetWidgetDisabledState(PLW_WIDGET_SEC_COL_DROPDOWN, (WP(w, livery_d).sel == 0));
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   397
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   398
			if (!(WP(w, livery_d).sel == 0)) {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   399
				for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7889
diff changeset
   400
					if (HasBit(WP(w, livery_d).sel, scheme)) break;
4603
20c816f664de (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
   401
				}
20c816f664de (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
   402
				if (scheme == LS_END) scheme = LS_DEFAULT;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
			}
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   404
4603
20c816f664de (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
   405
			SetDParam(0, STR_00D1_DARK_BLUE + p->livery[scheme].colour1);
20c816f664de (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
   406
			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
   407
4603
20c816f664de (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
			DrawWindowWidgets(w);
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   409
4603
20c816f664de (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
			for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
20c816f664de (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
				if (livery_class[scheme] == WP(w, livery_d).livery_class) {
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7889
diff changeset
   412
					bool sel = HasBit(WP(w, livery_d).sel, scheme) != 0;
4603
20c816f664de (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
20c816f664de (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
   414
					if (scheme != LS_DEFAULT) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   415
						DrawSprite(p->livery[scheme].in_use ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, 2, y);
4603
20c816f664de (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
					}
20c816f664de (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
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   418
					DrawString(15, y, STR_LIVERY_DEFAULT + scheme, sel ? TC_WHITE : TC_BLACK);
4603
20c816f664de (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
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   420
					DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour1), 152, y);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   421
					DrawString(165, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour1, sel ? TC_WHITE : TC_GOLD);
4603
20c816f664de (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
   422
6914
6219e65dd7bf (svn r10167) -Codechange: Change the flagging system of grf loaded feature from a bitset to a bool evaluation.
belugas
parents: 6909
diff changeset
   423
					if (_loaded_newgrf_features.has_2CC) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   424
						DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour2), 277, y);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   425
						DrawString(290, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour2, sel ? TC_WHITE : TC_GOLD);
4742
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   426
					}
4603
20c816f664de (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
20c816f664de (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
					y += 14;
20c816f664de (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
   429
				}
20c816f664de (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
   430
			}
20c816f664de (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
			break;
20c816f664de (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
		}
20c816f664de (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
20c816f664de (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
		case WE_CLICK: {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4605
diff changeset
   435
			switch (e->we.click.widget) {
4603
20c816f664de (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
				/* Livery Class buttons */
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   437
				case PLW_WIDGET_CLASS_GENERAL:
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   438
				case PLW_WIDGET_CLASS_RAIL:
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   439
				case PLW_WIDGET_CLASS_ROAD:
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   440
				case PLW_WIDGET_CLASS_SHIP:
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   441
				case PLW_WIDGET_CLASS_AIRCRAFT: {
4603
20c816f664de (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
					LiveryScheme scheme;
20c816f664de (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
   443
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   444
					w->RaiseWidget(WP(w, livery_d).livery_class + PLW_WIDGET_CLASS_GENERAL);
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   445
					WP(w, livery_d).livery_class = (LiveryClass)(e->we.click.widget - PLW_WIDGET_CLASS_GENERAL);
4603
20c816f664de (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
					WP(w, livery_d).sel = 0;
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   447
					w->LowerWidget(WP(w, livery_d).livery_class + PLW_WIDGET_CLASS_GENERAL);
4603
20c816f664de (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
20c816f664de (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
					/* Select the first item in the list */
20c816f664de (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
   450
					for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
20c816f664de (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
						if (livery_class[scheme] == WP(w, livery_d).livery_class) {
20c816f664de (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
							WP(w, livery_d).sel = 1 << scheme;
20c816f664de (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;
20c816f664de (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
						}
20c816f664de (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
   455
					}
20c816f664de (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
   456
					w->height = 49 + livery_height[WP(w, livery_d).livery_class] * 14;
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   457
					w->widget[PLW_WIDGET_MATRIX].bottom = w->height - 1;
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   458
					w->widget[PLW_WIDGET_MATRIX].data = livery_height[WP(w, livery_d).livery_class] << 8 | 1;
4603
20c816f664de (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
					MarkWholeScreenDirty();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   460
					break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   461
				}
4603
20c816f664de (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
   462
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   463
				case PLW_WIDGET_PRI_COL_DROPDOWN: /* First colour dropdown */
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   464
					ShowColourDropDownMenu(w, PLW_WIDGET_PRI_COL_DROPDOWN);
4603
20c816f664de (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
   465
					break;
20c816f664de (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
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   467
				case PLW_WIDGET_SEC_COL_DROPDOWN: /* Second colour dropdown */
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   468
					ShowColourDropDownMenu(w, PLW_WIDGET_SEC_COL_DROPDOWN);
4603
20c816f664de (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
   469
					break;
20c816f664de (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
   470
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   471
				case PLW_WIDGET_MATRIX: {
4603
20c816f664de (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
   472
					LiveryScheme scheme;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   473
					LiveryScheme j = (LiveryScheme)((e->we.click.pt.y - 48) / 14);
4603
20c816f664de (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
   474
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   475
					for (scheme = LS_BEGIN; scheme <= j; scheme++) {
4603
20c816f664de (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
   476
						if (livery_class[scheme] != WP(w, livery_d).livery_class) j++;
20c816f664de (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
   477
						if (scheme >= LS_END) return;
20c816f664de (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
   478
					}
20c816f664de (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
   479
					if (j >= LS_END) return;
20c816f664de (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
   480
20c816f664de (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
   481
					/* If clicking on the left edge, toggle using the livery */
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4605
diff changeset
   482
					if (e->we.click.pt.x < 10) {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   483
						DoCommandP(0, j | (2 << 8), !GetPlayer((PlayerID)w->window_number)->livery[j].in_use, NULL, CMD_SET_PLAYER_COLOR);
4603
20c816f664de (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
   484
					}
20c816f664de (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
   485
20c816f664de (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
   486
					if (_ctrl_pressed) {
7932
6c3d71e8a129 (svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents: 7931
diff changeset
   487
						ToggleBit(WP(w, livery_d).sel, j);
4603
20c816f664de (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
   488
					} else {
20c816f664de (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
   489
						WP(w, livery_d).sel = 1 << j;
20c816f664de (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
   490
					}
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9115
diff changeset
   491
					w->SetDirty();
4603
20c816f664de (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
   492
					break;
20c816f664de (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
   493
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   494
			}
4603
20c816f664de (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
   495
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
		}
4603
20c816f664de (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
   497
20c816f664de (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
   498
		case WE_DROPDOWN_SELECT: {
20c816f664de (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
   499
			LiveryScheme scheme;
20c816f664de (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
   500
20c816f664de (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
   501
			for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7889
diff changeset
   502
				if (HasBit(WP(w, livery_d).sel, scheme)) {
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   503
					DoCommandP(0, scheme | (e->we.dropdown.button == PLW_WIDGET_PRI_COL_DROPDOWN ? 0 : 256), e->we.dropdown.index, NULL, CMD_SET_PLAYER_COLOR);
4603
20c816f664de (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
   504
				}
20c816f664de (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
   505
			}
20c816f664de (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
   506
			break;
20c816f664de (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
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   509
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
4742
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   511
static const Widget _select_player_livery_2cc_widgets[] = {
4603
20c816f664de (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
   512
{ WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,                  STR_018B_CLOSE_WINDOW },
20c816f664de (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
   513
{  WWT_CAPTION, RESIZE_NONE, 14,  11, 399,   0,  13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
4647
b047726d5a8b (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   514
{   WWT_IMGBTN, RESIZE_NONE, 14,   0,  21,  14,  35, SPR_IMG_COMPANY_GENERAL,   STR_LIVERY_GENERAL_TIP },
b047726d5a8b (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   515
{   WWT_IMGBTN, RESIZE_NONE, 14,  22,  43,  14,  35, SPR_IMG_TRAINLIST,         STR_LIVERY_TRAIN_TIP },
b047726d5a8b (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   516
{   WWT_IMGBTN, RESIZE_NONE, 14,  44,  65,  14,  35, SPR_IMG_TRUCKLIST,         STR_LIVERY_ROADVEH_TIP },
b047726d5a8b (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   517
{   WWT_IMGBTN, RESIZE_NONE, 14,  66,  87,  14,  35, SPR_IMG_SHIPLIST,          STR_LIVERY_SHIP_TIP },
b047726d5a8b (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   518
{   WWT_IMGBTN, RESIZE_NONE, 14,  88, 109,  14,  35, SPR_IMG_AIRPLANESLIST,     STR_LIVERY_AIRCRAFT_TIP },
4603
20c816f664de (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
   519
{    WWT_PANEL, RESIZE_NONE, 14, 110, 399,  14,  35, 0x0,                       STR_NULL },
20c816f664de (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
   520
{    WWT_PANEL, RESIZE_NONE, 14,   0, 149,  36,  47, 0x0,                       STR_NULL },
8343
a6b70ddd862b (svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents: 8339
diff changeset
   521
{ WWT_DROPDOWN, RESIZE_NONE, 14, 150, 274,  36,  47, STR_02BD,                  STR_LIVERY_PRIMARY_TIP },
a6b70ddd862b (svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents: 8339
diff changeset
   522
{ WWT_DROPDOWN, RESIZE_NONE, 14, 275, 399,  36,  47, STR_02E1,                  STR_LIVERY_SECONDARY_TIP },
4647
b047726d5a8b (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   523
{   WWT_MATRIX, RESIZE_NONE, 14,   0, 399,  48,  48 + 1 * 14, (1 << 8) | 1,     STR_LIVERY_PANEL_TIP },
4603
20c816f664de (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
   524
{ WIDGETS_END },
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
4742
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   527
static const WindowDesc _select_player_livery_2cc_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   528
	WDP_AUTO, WDP_AUTO, 400, 49 + 1 * 14, 400, 49 + 1 * 14,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
   529
	WC_PLAYER_COLOR, WC_NONE,
4742
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   530
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   531
	_select_player_livery_2cc_widgets,
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   532
	SelectPlayerLiveryWndProc
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   533
};
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   534
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   535
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   536
static const Widget _select_player_livery_widgets[] = {
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   537
{ WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,                  STR_018B_CLOSE_WINDOW },
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   538
{  WWT_CAPTION, RESIZE_NONE, 14,  11, 274,   0,  13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   539
{   WWT_IMGBTN, RESIZE_NONE, 14,   0,  21,  14,  35, SPR_IMG_COMPANY_GENERAL,   STR_LIVERY_GENERAL_TIP },
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   540
{   WWT_IMGBTN, RESIZE_NONE, 14,  22,  43,  14,  35, SPR_IMG_TRAINLIST,         STR_LIVERY_TRAIN_TIP },
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   541
{   WWT_IMGBTN, RESIZE_NONE, 14,  44,  65,  14,  35, SPR_IMG_TRUCKLIST,         STR_LIVERY_ROADVEH_TIP },
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   542
{   WWT_IMGBTN, RESIZE_NONE, 14,  66,  87,  14,  35, SPR_IMG_SHIPLIST,          STR_LIVERY_SHIP_TIP },
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   543
{   WWT_IMGBTN, RESIZE_NONE, 14,  88, 109,  14,  35, SPR_IMG_AIRPLANESLIST,     STR_LIVERY_AIRCRAFT_TIP },
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   544
{    WWT_PANEL, RESIZE_NONE, 14, 110, 274,  14,  35, 0x0,                       STR_NULL },
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   545
{    WWT_PANEL, RESIZE_NONE, 14,   0, 149,  36,  47, 0x0,                       STR_NULL },
8343
a6b70ddd862b (svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents: 8339
diff changeset
   546
{ WWT_DROPDOWN, RESIZE_NONE, 14, 150, 274,  36,  47, STR_02BD,                  STR_LIVERY_PRIMARY_TIP },
a6b70ddd862b (svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents: 8339
diff changeset
   547
{ WWT_DROPDOWN, RESIZE_NONE, 14, 275, 275,  36,  47, STR_02E1,                  STR_LIVERY_SECONDARY_TIP },
4742
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   548
{   WWT_MATRIX, RESIZE_NONE, 14,   0, 274,  48,  48 + 1 * 14, (1 << 8) | 1,     STR_LIVERY_PANEL_TIP },
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   549
{ WIDGETS_END },
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   550
};
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   551
4603
20c816f664de (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
   552
static const WindowDesc _select_player_livery_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   553
	WDP_AUTO, WDP_AUTO, 275, 49 + 1 * 14, 275, 49 + 1 * 14,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
   554
	WC_PLAYER_COLOR, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
4603
20c816f664de (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
   556
	_select_player_livery_widgets,
20c816f664de (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
   557
	SelectPlayerLiveryWndProc
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   560
/**
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   561
 * Draws the face of a player.
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   562
 * @param pf    the player's face
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   563
 * @param color the (background) color of the gradient
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   564
 * @param x     x-position to draw the face
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   565
 * @param y     y-position to draw the face
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   566
 */
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   567
void DrawPlayerFace(PlayerFace pf, int color, int x, int y)
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   568
{
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   569
	GenderEthnicity ge = (GenderEthnicity)GetPlayerFaceBits(pf, PFV_GEN_ETHN, GE_WM);
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   570
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7889
diff changeset
   571
	bool has_moustache   = !HasBit(ge, GENDER_FEMALE) && GetPlayerFaceBits(pf, PFV_HAS_MOUSTACHE,   ge) != 0;
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7889
diff changeset
   572
	bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetPlayerFaceBits(pf, PFV_HAS_TIE_EARRING, ge) != 0;
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   573
	bool has_glasses     = GetPlayerFaceBits(pf, PFV_HAS_GLASSES, ge) != 0;
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   574
	SpriteID pal;
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   575
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   576
	/* Modify eye colour palette only if 2 or more valid values exist */
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   577
	if (_pf_info[PFV_EYE_COLOUR].valid_values[ge] < 2) {
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   578
		pal = PAL_NONE;
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   579
	} else {
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   580
		switch (GetPlayerFaceBits(pf, PFV_EYE_COLOUR, ge)) {
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   581
			default: NOT_REACHED();
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   582
			case 0: pal = PALETTE_TO_BROWN; break;
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   583
			case 1: pal = PALETTE_TO_BLUE;  break;
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   584
			case 2: pal = PALETTE_TO_GREEN; break;
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   585
		}
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   586
	}
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   587
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   588
	/* Draw the gradient (background) */
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   589
	DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOR(color), x, y);
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   590
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   591
	for (PlayerFaceVariable pfv = PFV_CHEEKS; pfv < PFV_END; pfv++) {
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   592
		switch (pfv) {
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   593
			case PFV_MOUSTACHE:   if (!has_moustache)   continue; break;
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   594
			case PFV_LIPS:        /* FALL THROUGH */
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   595
			case PFV_NOSE:        if (has_moustache)    continue; break;
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   596
			case PFV_TIE_EARRING: if (!has_tie_earring) continue; break;
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   597
			case PFV_GLASSES:     if (!has_glasses)     continue; break;
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   598
			default: break;
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   599
		}
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   600
		DrawSprite(GetPlayerFaceSprite(pf, pfv, ge), (pfv == PFV_EYEBROWS) ? pal : PAL_NONE, x, y);
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   601
	}
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   602
}
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   603
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   604
/** Widget description for the normal/simple player face selection dialog */
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   605
static const Widget _select_player_face_widgets[] = {
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   606
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},              // PFW_WIDGET_CLOSEBOX
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   607
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   174,     0,    13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // PFW_WIDGET_CAPTION
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   608
{     WWT_IMGBTN,   RESIZE_NONE,    14,   175,   189,     0,    13, SPR_LARGE_SMALL_WINDOW,  STR_FACE_ADVANCED_TIP},              // PFW_WIDGET_TOGGLE_LARGE_SMALL
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   609
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   189,    14,   150, 0x0,                     STR_NULL},                           // PFW_WIDGET_SELECT_FACE
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   610
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    94,   151,   162, STR_012E_CANCEL,         STR_7047_CANCEL_NEW_FACE_SELECTION}, // PFW_WIDGET_CANCEL
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   611
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    95,   189,   151,   162, STR_012F_OK,             STR_7048_ACCEPT_NEW_FACE_SELECTION}, // PFW_WIDGET_ACCEPT
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   612
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    95,   187,    75,    86, STR_7044_MALE,           STR_7049_SELECT_MALE_FACES},         // PFW_WIDGET_MALE
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   613
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    95,   187,    87,    98, STR_7045_FEMALE,         STR_704A_SELECT_FEMALE_FACES},       // PFW_WIDGET_FEMALE
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   614
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     2,    93,   137,   148, STR_7046_NEW_FACE,       STR_704B_GENERATE_RANDOM_NEW_FACE},  // PFW_WIDGET_RANDOM_NEW_FACE
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   615
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    95,   187,    16,    27, STR_FACE_ADVANCED,       STR_FACE_ADVANCED_TIP},              // PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   616
{   WIDGETS_END},
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   617
};
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   618
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   619
/** Widget description for the advanced player face selection dialog */
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   620
static const Widget _select_player_face_adv_widgets[] = {
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   621
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},              // PFW_WIDGET_CLOSEBOX
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   622
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   204,     0,    13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // PFW_WIDGET_CAPTION
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   623
{     WWT_IMGBTN,   RESIZE_NONE,    14,   205,   219,     0,    13, SPR_LARGE_SMALL_WINDOW,  STR_FACE_SIMPLE_TIP},                // PFW_WIDGET_TOGGLE_LARGE_SMALL
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   624
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   219,    14,   207, 0x0,                     STR_NULL},                           // PFW_WIDGET_SELECT_FACE
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   625
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    94,   208,   219, STR_012E_CANCEL,         STR_7047_CANCEL_NEW_FACE_SELECTION}, // PFW_WIDGET_CANCEL
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   626
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    95,   219,   208,   219, STR_012F_OK,             STR_7048_ACCEPT_NEW_FACE_SELECTION}, // PFW_WIDGET_ACCEPT
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   627
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    96,   156,    32,    43, STR_7044_MALE,           STR_7049_SELECT_MALE_FACES},         // PFW_WIDGET_MALE
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   628
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   157,   217,    32,    43, STR_7045_FEMALE,         STR_704A_SELECT_FEMALE_FACES},       // PFW_WIDGET_FEMALE
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   629
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     2,    93,   137,   148, STR_RANDOM,              STR_704B_GENERATE_RANDOM_NEW_FACE},  // PFW_WIDGET_RANDOM_NEW_FACE
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   630
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    95,   217,    16,    27, STR_FACE_SIMPLE,         STR_FACE_SIMPLE_TIP},                // PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   631
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     2,    93,   158,   169, STR_FACE_LOAD,           STR_FACE_LOAD_TIP},                  // PFW_WIDGET_LOAD
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   632
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     2,    93,   170,   181, STR_FACE_FACECODE,       STR_FACE_FACECODE_TIP},              // PFW_WIDGET_FACECODE
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   633
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     2,    93,   182,   193, STR_FACE_SAVE,           STR_FACE_SAVE_TIP},                  // PFW_WIDGET_SAVE
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   634
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    96,   156,    46,    57, STR_FACE_EUROPEAN,       STR_FACE_SELECT_EUROPEAN},           // PFW_WIDGET_ETHNICITY_EUR
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   635
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   157,   217,    46,    57, STR_FACE_AFRICAN,        STR_FACE_SELECT_AFRICAN},            // PFW_WIDGET_ETHNICITY_AFR
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   636
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   175,   217,    60,    71, STR_EMPTY,               STR_FACE_MOUSTACHE_EARRING_TIP},     // PFW_WIDGET_HAS_MOUSTACHE_EARRING
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   637
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   175,   217,    72,    83, STR_EMPTY,               STR_FACE_GLASSES_TIP},               // PFW_WIDGET_HAS_GLASSES
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   638
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   110,   121, SPR_ARROW_LEFT,          STR_FACE_EYECOLOUR_TIP},             // PFW_WIDGET_EYECOLOUR_L
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   639
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   110,   121, STR_EMPTY,               STR_FACE_EYECOLOUR_TIP},             // PFW_WIDGET_EYECOLOUR
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   640
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   110,   121, SPR_ARROW_RIGHT,         STR_FACE_EYECOLOUR_TIP},             // PFW_WIDGET_EYECOLOUR_R
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   641
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   158,   169, SPR_ARROW_LEFT,          STR_FACE_CHIN_TIP},                  // PFW_WIDGET_CHIN_L
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   642
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   158,   169, STR_EMPTY,               STR_FACE_CHIN_TIP},                  // PFW_WIDGET_CHIN
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   643
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   158,   169, SPR_ARROW_RIGHT,         STR_FACE_CHIN_TIP},                  // PFW_WIDGET_CHIN_R
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   644
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,    98,   109, SPR_ARROW_LEFT,          STR_FACE_EYEBROWS_TIP},              // PFW_WIDGET_EYEBROWS_L
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   645
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,    98,   109, STR_EMPTY,               STR_FACE_EYEBROWS_TIP},              // PFW_WIDGET_EYEBROWS
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   646
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,    98,   109, SPR_ARROW_RIGHT,         STR_FACE_EYEBROWS_TIP},              // PFW_WIDGET_EYEBROWS_R
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   647
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   146,   157, SPR_ARROW_LEFT,          STR_FACE_LIPS_MOUSTACHE_TIP},        // PFW_WIDGET_LIPS_MOUSTACHE_L
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   648
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   146,   157, STR_EMPTY,               STR_FACE_LIPS_MOUSTACHE_TIP},        // PFW_WIDGET_LIPS_MOUSTACHE
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   649
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   146,   157, SPR_ARROW_RIGHT,         STR_FACE_LIPS_MOUSTACHE_TIP},        // PFW_WIDGET_LIPS_MOUSTACHE_R
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   650
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   134,   145, SPR_ARROW_LEFT,          STR_FACE_NOSE_TIP},                  // PFW_WIDGET_NOSE_L
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   651
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   134,   145, STR_EMPTY,               STR_FACE_NOSE_TIP},                  // PFW_WIDGET_NOSE
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   652
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   134,   145, SPR_ARROW_RIGHT,         STR_FACE_NOSE_TIP},                  // PFW_WIDGET_NOSE_R
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   653
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,    86,    97, SPR_ARROW_LEFT,          STR_FACE_HAIR_TIP},                  // PFW_WIDGET_HAIR_L
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   654
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,    86,    97, STR_EMPTY,               STR_FACE_HAIR_TIP},                  // PFW_WIDGET_HAIR
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   655
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,    86,    97, SPR_ARROW_RIGHT,         STR_FACE_HAIR_TIP},                  // PFW_WIDGET_HAIR_R
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   656
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   170,   181, SPR_ARROW_LEFT,          STR_FACE_JACKET_TIP},                // PFW_WIDGET_JACKET_L
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   657
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   170,   181, STR_EMPTY,               STR_FACE_JACKET_TIP},                // PFW_WIDGET_JACKET
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   658
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   170,   181, SPR_ARROW_RIGHT,         STR_FACE_JACKET_TIP},                // PFW_WIDGET_JACKET_R
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   659
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   182,   193, SPR_ARROW_LEFT,          STR_FACE_COLLAR_TIP},                // PFW_WIDGET_COLLAR_L
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   660
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   182,   193, STR_EMPTY,               STR_FACE_COLLAR_TIP},                // PFW_WIDGET_COLLAR
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   661
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   182,   193, SPR_ARROW_RIGHT,         STR_FACE_COLLAR_TIP},                // PFW_WIDGET_COLLAR_R
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   662
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   194,   205, SPR_ARROW_LEFT,          STR_FACE_TIE_EARRING_TIP},           // PFW_WIDGET_TIE_EARRING_L
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   663
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   194,   205, STR_EMPTY,               STR_FACE_TIE_EARRING_TIP},           // PFW_WIDGET_TIE_EARRING
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   664
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   194,   205, SPR_ARROW_RIGHT,         STR_FACE_TIE_EARRING_TIP},           // PFW_WIDGET_TIE_EARRING_R
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   665
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   122,   133, SPR_ARROW_LEFT,          STR_FACE_GLASSES_TIP_2},             // PFW_WIDGET_GLASSES_L
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   666
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   122,   133, STR_EMPTY,               STR_FACE_GLASSES_TIP_2},             // PFW_WIDGET_GLASSES
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   667
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   122,   133, SPR_ARROW_RIGHT,         STR_FACE_GLASSES_TIP_2},             // PFW_WIDGET_GLASSES_R
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   668
{   WIDGETS_END},
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   669
};
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   670
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   671
class SelectPlayerFaceWindow : public Window
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   672
{
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   673
	PlayerFace face; // player face bits
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   674
	bool advanced;   // advance player face selection window
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   675
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   676
	GenderEthnicity ge;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   677
	bool is_female;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   678
	bool is_moust_male;
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   679
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   680
	/**
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   681
	 * Names of the widgets. Keep them in the same order as in the widget array.
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   682
	 * Do not change the order of the widgets from PFW_WIDGET_HAS_MOUSTACHE_EARRING to PFW_WIDGET_GLASSES_R,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   683
	 * this order is needed for the WE_CLICK event of DrawFaceStringLabel().
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   684
	 */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   685
	enum PlayerFaceWindowWidgets {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   686
		PFW_WIDGET_CLOSEBOX = 0,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   687
		PFW_WIDGET_CAPTION,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   688
		PFW_WIDGET_TOGGLE_LARGE_SMALL,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   689
		PFW_WIDGET_SELECT_FACE,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   690
		PFW_WIDGET_CANCEL,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   691
		PFW_WIDGET_ACCEPT,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   692
		PFW_WIDGET_MALE,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   693
		PFW_WIDGET_FEMALE,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   694
		PFW_WIDGET_RANDOM_NEW_FACE,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   695
		PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   696
		/* from here is the advanced player face selection window */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   697
		PFW_WIDGET_LOAD,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   698
		PFW_WIDGET_FACECODE,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   699
		PFW_WIDGET_SAVE,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   700
		PFW_WIDGET_ETHNICITY_EUR,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   701
		PFW_WIDGET_ETHNICITY_AFR,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   702
		PFW_WIDGET_HAS_MOUSTACHE_EARRING,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   703
		PFW_WIDGET_HAS_GLASSES,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   704
		PFW_WIDGET_EYECOLOUR_L,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   705
		PFW_WIDGET_EYECOLOUR,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   706
		PFW_WIDGET_EYECOLOUR_R,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   707
		PFW_WIDGET_CHIN_L,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   708
		PFW_WIDGET_CHIN,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   709
		PFW_WIDGET_CHIN_R,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   710
		PFW_WIDGET_EYEBROWS_L,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   711
		PFW_WIDGET_EYEBROWS,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   712
		PFW_WIDGET_EYEBROWS_R,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   713
		PFW_WIDGET_LIPS_MOUSTACHE_L,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   714
		PFW_WIDGET_LIPS_MOUSTACHE,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   715
		PFW_WIDGET_LIPS_MOUSTACHE_R,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   716
		PFW_WIDGET_NOSE_L,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   717
		PFW_WIDGET_NOSE,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   718
		PFW_WIDGET_NOSE_R,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   719
		PFW_WIDGET_HAIR_L,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   720
		PFW_WIDGET_HAIR,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   721
		PFW_WIDGET_HAIR_R,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   722
		PFW_WIDGET_JACKET_L,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   723
		PFW_WIDGET_JACKET,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   724
		PFW_WIDGET_JACKET_R,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   725
		PFW_WIDGET_COLLAR_L,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   726
		PFW_WIDGET_COLLAR,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   727
		PFW_WIDGET_COLLAR_R,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   728
		PFW_WIDGET_TIE_EARRING_L,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   729
		PFW_WIDGET_TIE_EARRING,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   730
		PFW_WIDGET_TIE_EARRING_R,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   731
		PFW_WIDGET_GLASSES_L,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   732
		PFW_WIDGET_GLASSES,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   733
		PFW_WIDGET_GLASSES_R,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   734
	};
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   735
	/**
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   736
	 * Draw dynamic a label to the left of the button and a value in the button
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   737
	 *
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   738
	 * @param widget_index   index of this widget in the window
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   739
	 * @param str            the label which will be draw
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   740
	 * @param val            the value which will be draw
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   741
	 * @param is_bool_widget is it a bool button
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   742
	 */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   743
	void DrawFaceStringLabel(byte widget_index, StringID str, uint8 val, bool is_bool_widget)
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   744
	{
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   745
		/* Write the label in gold (0x2) to the left of the button. */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   746
		DrawStringRightAligned(this->widget[widget_index].left - (is_bool_widget ? 5 : 14), this->widget[widget_index].top + 1, str, TC_GOLD);
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   747
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   748
		if (!this->IsWidgetDisabled(widget_index)) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   749
			if (is_bool_widget) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   750
				/* if it a bool button write yes or no */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   751
				str = (val != 0) ? STR_FACE_YES : STR_FACE_NO;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   752
			} else {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   753
				/* else write the value + 1 */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   754
				SetDParam(0, val + 1);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   755
				str = STR_JUST_INT;
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   756
			}
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   757
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   758
			/* Draw the value/bool in white (0xC). If the button clicked adds 1px to x and y text coordinates (IsWindowWidgetLowered()). */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   759
			DrawStringCentered(this->widget[widget_index].left + (this->widget[widget_index].right - this->widget[widget_index].left) / 2 +
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   760
				this->IsWidgetLowered(widget_index), this->widget[widget_index].top + 1 + this->IsWidgetLowered(widget_index), str, TC_WHITE);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   761
		}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   762
	}
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   763
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   764
	void UpdateData()
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   765
	{
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   766
		this->ge = (GenderEthnicity)GB(this->face, _pf_info[PFV_GEN_ETHN].offset, _pf_info[PFV_GEN_ETHN].length); // get the gender and ethnicity
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   767
		this->is_female = HasBit(this->ge, GENDER_FEMALE); // get the gender: 0 == male and 1 == female
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   768
		this->is_moust_male = !is_female && GetPlayerFaceBits(this->face, PFV_HAS_MOUSTACHE, this->ge) != 0; // is a male face with moustache
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   769
	}
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   770
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   771
public:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   772
	SelectPlayerFaceWindow(const WindowDesc *desc, void *data, WindowNumber number) : Window(desc, data, number)
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   773
	{
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   774
		this->FindWindowPlacementAndResize(desc);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   775
		this->caption_color = this->window_number;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   776
		this->face = GetPlayer((PlayerID)this->window_number)->face;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   777
		this->advanced = *(bool*)data;
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   778
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   779
		this->UpdateData();
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   780
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   781
		/* Check if repositioning from default is required */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   782
		if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   783
			this->top = top;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   784
			this->left = left;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   785
		}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   786
	}
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   787
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   788
	virtual void OnPaint()
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   789
	{
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   790
		/* lower the non-selected gender button */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   791
		this->SetWidgetLoweredState(PFW_WIDGET_MALE,  !this->is_female);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   792
		this->SetWidgetLoweredState(PFW_WIDGET_FEMALE, this->is_female);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   793
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   794
		/* advanced player face selection window */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   795
		if (this->advanced) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   796
			/* lower the non-selected ethnicity button */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   797
			this->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_EUR, !HasBit(this->ge, ETHNICITY_BLACK));
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   798
			this->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_AFR,  HasBit(this->ge, ETHNICITY_BLACK));
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   799
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   800
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   801
			/* Disable dynamically the widgets which PlayerFaceVariable has less than 2 options
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   802
			* (or in other words you haven't any choice).
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   803
			* If the widgets depend on a HAS-variable and this is false the widgets will be disabled, too. */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   804
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   805
			/* Eye colour buttons */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   806
			this->SetWidgetsDisabledState(_pf_info[PFV_EYE_COLOUR].valid_values[this->ge] < 2,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   807
				PFW_WIDGET_EYECOLOUR, PFW_WIDGET_EYECOLOUR_L, PFW_WIDGET_EYECOLOUR_R, WIDGET_LIST_END);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   808
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   809
			/* Chin buttons */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   810
			this->SetWidgetsDisabledState(_pf_info[PFV_CHIN].valid_values[this->ge] < 2,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   811
				PFW_WIDGET_CHIN, PFW_WIDGET_CHIN_L, PFW_WIDGET_CHIN_R, WIDGET_LIST_END);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   812
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   813
			/* Eyebrows buttons */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   814
			this->SetWidgetsDisabledState(_pf_info[PFV_EYEBROWS].valid_values[this->ge] < 2,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   815
				PFW_WIDGET_EYEBROWS, PFW_WIDGET_EYEBROWS_L, PFW_WIDGET_EYEBROWS_R, WIDGET_LIST_END);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   816
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   817
			/* Lips or (if it a male face with a moustache) moustache buttons */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   818
			this->SetWidgetsDisabledState(_pf_info[this->is_moust_male ? PFV_MOUSTACHE : PFV_LIPS].valid_values[this->ge] < 2,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   819
				PFW_WIDGET_LIPS_MOUSTACHE, PFW_WIDGET_LIPS_MOUSTACHE_L, PFW_WIDGET_LIPS_MOUSTACHE_R, WIDGET_LIST_END);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   820
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   821
			/* Nose buttons | male faces with moustache haven't any nose options */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   822
			this->SetWidgetsDisabledState(_pf_info[PFV_NOSE].valid_values[this->ge] < 2 || this->is_moust_male,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   823
				PFW_WIDGET_NOSE, PFW_WIDGET_NOSE_L, PFW_WIDGET_NOSE_R, WIDGET_LIST_END);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   824
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   825
			/* Hair buttons */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   826
			this->SetWidgetsDisabledState(_pf_info[PFV_HAIR].valid_values[this->ge] < 2,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   827
				PFW_WIDGET_HAIR, PFW_WIDGET_HAIR_L, PFW_WIDGET_HAIR_R, WIDGET_LIST_END);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   828
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   829
			/* Jacket buttons */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   830
			this->SetWidgetsDisabledState(_pf_info[PFV_JACKET].valid_values[this->ge] < 2,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   831
				PFW_WIDGET_JACKET, PFW_WIDGET_JACKET_L, PFW_WIDGET_JACKET_R, WIDGET_LIST_END);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   832
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   833
			/* Collar buttons */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   834
			this->SetWidgetsDisabledState(_pf_info[PFV_COLLAR].valid_values[this->ge] < 2,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   835
				PFW_WIDGET_COLLAR, PFW_WIDGET_COLLAR_L, PFW_WIDGET_COLLAR_R, WIDGET_LIST_END);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   836
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   837
			/* Tie/earring buttons | female faces without earring haven't any earring options */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   838
			this->SetWidgetsDisabledState(_pf_info[PFV_TIE_EARRING].valid_values[this->ge] < 2 ||
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   839
					(this->is_female && GetPlayerFaceBits(this->face, PFV_HAS_TIE_EARRING, this->ge) == 0),
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   840
				PFW_WIDGET_TIE_EARRING, PFW_WIDGET_TIE_EARRING_L, PFW_WIDGET_TIE_EARRING_R, WIDGET_LIST_END);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   841
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   842
			/* Glasses buttons | faces without glasses haven't any glasses options */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   843
			this->SetWidgetsDisabledState(_pf_info[PFV_GLASSES].valid_values[this->ge] < 2 || GetPlayerFaceBits(this->face, PFV_HAS_GLASSES, this->ge) == 0,
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   844
				PFW_WIDGET_GLASSES, PFW_WIDGET_GLASSES_L, PFW_WIDGET_GLASSES_R, WIDGET_LIST_END);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   845
		}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   846
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   847
		DrawWindowWidgets(this);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   848
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   849
		/* Draw dynamic button value and labels for the advanced player face selection window */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   850
		if (this->advanced) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   851
			if (this->is_female) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   852
				/* Only for female faces */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   853
				this->DrawFaceStringLabel(PFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_EARRING,   GetPlayerFaceBits(this->face, PFV_HAS_TIE_EARRING, this->ge), true );
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   854
				this->DrawFaceStringLabel(PFW_WIDGET_TIE_EARRING,           STR_FACE_EARRING,   GetPlayerFaceBits(this->face, PFV_TIE_EARRING,     this->ge), false);
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   855
			} else {
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   856
				/* Only for male faces */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   857
				this->DrawFaceStringLabel(PFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_MOUSTACHE, GetPlayerFaceBits(this->face, PFV_HAS_MOUSTACHE,   this->ge), true );
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   858
				this->DrawFaceStringLabel(PFW_WIDGET_TIE_EARRING,           STR_FACE_TIE,       GetPlayerFaceBits(this->face, PFV_TIE_EARRING,     this->ge), false);
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   859
			}
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   860
			if (this->is_moust_male) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   861
				/* Only for male faces with moustache */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   862
				this->DrawFaceStringLabel(PFW_WIDGET_LIPS_MOUSTACHE,        STR_FACE_MOUSTACHE, GetPlayerFaceBits(this->face, PFV_MOUSTACHE,       this->ge), false);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   863
			} else {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   864
				/* Only for female faces or male faces without moustache */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   865
				this->DrawFaceStringLabel(PFW_WIDGET_LIPS_MOUSTACHE,        STR_FACE_LIPS,      GetPlayerFaceBits(this->face, PFV_LIPS,            this->ge), false);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   866
			}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   867
			/* For all faces */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   868
			this->DrawFaceStringLabel(PFW_WIDGET_HAS_GLASSES,           STR_FACE_GLASSES,     GetPlayerFaceBits(this->face, PFV_HAS_GLASSES,     this->ge), true );
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   869
			this->DrawFaceStringLabel(PFW_WIDGET_HAIR,                  STR_FACE_HAIR,        GetPlayerFaceBits(this->face, PFV_HAIR,            this->ge), false);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   870
			this->DrawFaceStringLabel(PFW_WIDGET_EYEBROWS,              STR_FACE_EYEBROWS,    GetPlayerFaceBits(this->face, PFV_EYEBROWS,        this->ge), false);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   871
			this->DrawFaceStringLabel(PFW_WIDGET_EYECOLOUR,             STR_FACE_EYECOLOUR,   GetPlayerFaceBits(this->face, PFV_EYE_COLOUR,      this->ge), false);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   872
			this->DrawFaceStringLabel(PFW_WIDGET_GLASSES,               STR_FACE_GLASSES,     GetPlayerFaceBits(this->face, PFV_GLASSES,         this->ge), false);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   873
			this->DrawFaceStringLabel(PFW_WIDGET_NOSE,                  STR_FACE_NOSE,        GetPlayerFaceBits(this->face, PFV_NOSE,            this->ge), false);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   874
			this->DrawFaceStringLabel(PFW_WIDGET_CHIN,                  STR_FACE_CHIN,        GetPlayerFaceBits(this->face, PFV_CHIN,            this->ge), false);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   875
			this->DrawFaceStringLabel(PFW_WIDGET_JACKET,                STR_FACE_JACKET,      GetPlayerFaceBits(this->face, PFV_JACKET,          this->ge), false);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   876
			this->DrawFaceStringLabel(PFW_WIDGET_COLLAR,                STR_FACE_COLLAR,      GetPlayerFaceBits(this->face, PFV_COLLAR,          this->ge), false);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   877
		}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   878
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   879
		/* Draw the player face picture */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   880
		DrawPlayerFace(this->face, GetPlayer((PlayerID)this->window_number)->player_color, 2, 16);
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   881
	}
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   882
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   883
	virtual void OnClick(Point pt, int widget)
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   884
	{
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   885
		switch (widget) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   886
			/* Toggle size, advanced/simple face selection */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   887
			case PFW_WIDGET_TOGGLE_LARGE_SMALL:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   888
			case PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON: {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   889
				int oldtop = this->top;     ///< current top position of the window before closing it
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   890
				int oldleft = this->left;   ///< current top position of the window before closing it
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   891
				PlayerID player = (PlayerID)this->window_number;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   892
				bool adv = !this->advanced;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   893
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   894
				DoCommandP(0, 0, this->face, NULL, CMD_SET_PLAYER_FACE);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   895
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   896
				delete this;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   897
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   898
				/* Open up the (toggled size) Face selection window at the same position as the previous */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   899
				DoSelectPlayerFace(player, adv, oldtop, oldleft);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   900
			} break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   901
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   902
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   903
			/* OK button */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   904
			case PFW_WIDGET_ACCEPT:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   905
				DoCommandP(0, 0, this->face, NULL, CMD_SET_PLAYER_FACE);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   906
				/* Fall-Through */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   907
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   908
			/* Cancel button */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   909
			case PFW_WIDGET_CANCEL:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   910
				delete this;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   911
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   912
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   913
			/* Load button */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   914
			case PFW_WIDGET_LOAD:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   915
				this->face = _player_face;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   916
				ScaleAllPlayerFaceBits(this->face);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   917
				ShowErrorMessage(INVALID_STRING_ID, STR_FACE_LOAD_DONE, 0, 0);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   918
				this->UpdateData();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   919
				this->SetDirty();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   920
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   921
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   922
			/* 'Player face number' button, view and/or set player face number */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   923
			case PFW_WIDGET_FACECODE:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   924
				SetDParam(0, this->face);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   925
				ShowQueryString(STR_JUST_INT, STR_FACE_FACECODE_CAPTION, 10 + 1, 0, this, CS_NUMERAL);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   926
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   927
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   928
			/* Save button */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   929
			case PFW_WIDGET_SAVE:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   930
				_player_face = this->face;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   931
				ShowErrorMessage(INVALID_STRING_ID, STR_FACE_SAVE_DONE, 0, 0);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   932
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   933
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   934
			/* Toggle gender (male/female) button */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   935
			case PFW_WIDGET_MALE:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   936
			case PFW_WIDGET_FEMALE:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   937
				SetPlayerFaceBits(this->face, PFV_GENDER, this->ge, widget - PFW_WIDGET_MALE);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   938
				ScaleAllPlayerFaceBits(this->face);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   939
				this->UpdateData();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   940
				this->SetDirty();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   941
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   942
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   943
			/* Randomize face button */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   944
			case PFW_WIDGET_RANDOM_NEW_FACE:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   945
				RandomPlayerFaceBits(this->face, this->ge, this->advanced);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   946
				this->UpdateData();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   947
				this->SetDirty();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   948
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   949
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   950
			/* Toggle ethnicity (european/african) button */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   951
			case PFW_WIDGET_ETHNICITY_EUR:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   952
			case PFW_WIDGET_ETHNICITY_AFR:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   953
				SetPlayerFaceBits(this->face, PFV_ETHNICITY, this->ge, widget - PFW_WIDGET_ETHNICITY_EUR);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   954
				ScaleAllPlayerFaceBits(this->face);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   955
				this->UpdateData();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   956
				this->SetDirty();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   957
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   958
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   959
			default:
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   960
				/* For all buttons from PFW_WIDGET_HAS_MOUSTACHE_EARRING to PFW_WIDGET_GLASSES_R is the same function.
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   961
				* Therefor is this combined function.
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   962
				* First it checks which PlayerFaceVariable will be change and then
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   963
				* a: invert the value for boolean variables
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   964
				* or b: it checks inside of IncreasePlayerFaceBits() if a left (_L) butten is pressed and then decrease else increase the variable */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   965
				if (this->advanced && widget >= PFW_WIDGET_HAS_MOUSTACHE_EARRING && widget <= PFW_WIDGET_GLASSES_R) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   966
					PlayerFaceVariable pfv; // which PlayerFaceVariable shall be edited
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   967
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   968
					if (widget < PFW_WIDGET_EYECOLOUR_L) { // Bool buttons
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   969
						switch (widget - PFW_WIDGET_HAS_MOUSTACHE_EARRING) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   970
							default: NOT_REACHED();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   971
							case 0: pfv = this->is_female ? PFV_HAS_TIE_EARRING : PFV_HAS_MOUSTACHE; break; // Has earring/moustache button
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   972
							case 1: pfv = PFV_HAS_GLASSES; break; // Has glasses button
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   973
						}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   974
						SetPlayerFaceBits(this->face, pfv, this->ge, !GetPlayerFaceBits(this->face, pfv, this->ge));
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   975
						ScaleAllPlayerFaceBits(this->face);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   976
					} else { // Value buttons
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   977
						switch ((widget - PFW_WIDGET_EYECOLOUR_L) / 3) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   978
							default: NOT_REACHED();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   979
							case 0: pfv = PFV_EYE_COLOUR; break;  // Eye colour buttons
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   980
							case 1: pfv = PFV_CHIN; break;        // Chin buttons
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   981
							case 2: pfv = PFV_EYEBROWS; break;    // Eyebrows buttons
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   982
							case 3: pfv = this->is_moust_male ? PFV_MOUSTACHE : PFV_LIPS; break; // Moustache or lips buttons
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   983
							case 4: pfv = PFV_NOSE; break;        // Nose buttons
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   984
							case 5: pfv = PFV_HAIR; break;        // Hair buttons
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   985
							case 6: pfv = PFV_JACKET; break;      // Jacket buttons
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   986
							case 7: pfv = PFV_COLLAR; break;      // Collar buttons
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   987
							case 8: pfv = PFV_TIE_EARRING; break; // Tie/earring buttons
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   988
							case 9: pfv = PFV_GLASSES; break;     // Glasses buttons
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   989
						}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   990
						/* 0 == left (_L), 1 == middle or 2 == right (_R) - button click */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   991
						IncreasePlayerFaceBits(this->face, pfv, this->ge, (((widget - PFW_WIDGET_EYECOLOUR_L) % 3) != 0) ? 1 : -1);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   992
					}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   993
					this->UpdateData();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   994
					this->SetDirty();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   995
				}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   996
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   997
		}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   998
	}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   999
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1000
	virtual void OnQueryTextFinished(char *str)
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1001
	{
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1002
		if (str == NULL) return;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1003
		/* Set a new player face number */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1004
		if (!StrEmpty(str)) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1005
			this->face = strtoul(str, NULL, 10);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1006
			ScaleAllPlayerFaceBits(this->face);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1007
			ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_SET, 0, 0);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1008
			this->UpdateData();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1009
			this->SetDirty();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1010
		} else {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1011
			ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_ERR, 0, 0);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1012
		}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1013
	}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1014
};
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1015
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1016
/** normal/simple player face selection window description */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1017
static const WindowDesc _select_player_face_desc = {
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1018
	WDP_AUTO, WDP_AUTO, 190, 163, 190, 163,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
  1019
	WC_PLAYER_FACE, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1020
	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
  1021
	_select_player_face_widgets,
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1022
	NULL
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1023
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1024
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1025
/** advanced player face selection window description */
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1026
static const WindowDesc _select_player_face_adv_desc = {
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1027
	WDP_AUTO, WDP_AUTO, 220, 220, 220, 220,
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1028
	WC_PLAYER_FACE, WC_NONE,
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1029
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1030
	_select_player_face_adv_widgets,
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1031
	NULL
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1032
};
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1033
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1034
/**
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1035
 * Open the simple/advanced player face selection window
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1036
 *
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1037
 * @param player the player which face shall be edited
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1038
 * @param adv    simple or advanced player face selection window
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
  1039
 * @param top    previous top position of the window
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
  1040
 * @param left   previous left position of the window
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1041
 *
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1042
 * @pre is player a valid player
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1043
 */
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
  1044
static void DoSelectPlayerFace(PlayerID player, bool adv, int top, int left)
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1045
{
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1046
	if (!IsValidPlayer(player)) return;
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1047
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1048
	AllocateWindowDescFront<SelectPlayerFaceWindow>(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, player, &adv); // simple or advanced window
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1049
}
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1050
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1051
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1052
/* Names of the widgets. Keep them in the same order as in the widget array */
5273
d9f707aa36a6 (svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents: 5070
diff changeset
  1053
enum PlayerCompanyWindowWidgets {
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1054
	PCW_WIDGET_CLOSEBOX = 0,
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1055
	PCW_WIDGET_CAPTION,
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1056
	PCW_WIDGET_FACE,
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1057
	PCW_WIDGET_NEW_FACE,
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1058
	PCW_WIDGET_COLOR_SCHEME,
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1059
	PCW_WIDGET_PRESIDENT_NAME,
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1060
	PCW_WIDGET_COMPANY_NAME,
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1061
	PCW_WIDGET_BUILD_VIEW_HQ,
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1062
	PCW_WIDGET_RELOCATE_HQ,
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1063
	PCW_WIDGET_BUY_SHARE,
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1064
	PCW_WIDGET_SELL_SHARE,
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1065
	PCW_WIDGET_COMPANY_PASSWORD,
5273
d9f707aa36a6 (svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents: 5070
diff changeset
  1066
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1067
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1068
static const Widget _player_company_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
  1069
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
  1070
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   359,     0,    13, STR_7001,                          STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
  1071
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   359,    14,   157, 0x0,                               STR_NULL},
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1072
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    89,   158,   169, STR_7004_NEW_FACE,                 STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT},
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1073
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    90,   179,   158,   169, STR_7005_COLOR_SCHEME,             STR_7031_CHANGE_THE_COMPANY_VEHICLE},
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1074
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   180,   269,   158,   169, STR_7009_PRESIDENT_NAME,           STR_7032_CHANGE_THE_PRESIDENT_S},
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1075
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   270,   359,   158,   169, STR_7008_COMPANY_NAME,             STR_7033_CHANGE_THE_COMPANY_NAME},
4808
07bc43331422 (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
  1076
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   266,   355,    18,    29, STR_7072_VIEW_HQ,                  STR_7070_BUILD_COMPANY_HEADQUARTERS},
07bc43331422 (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
  1077
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   266,   355,    32,    43, STR_RELOCATE_HQ,                   STR_RELOCATE_COMPANY_HEADQUARTERS},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
  1078
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   179,   158,   169, STR_7077_BUY_25_SHARE_IN_COMPANY,  STR_7079_BUY_25_SHARE_IN_THIS_COMPANY},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
  1079
{ 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
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1080
{ 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
  1081
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1082
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1083
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1084
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1085
/**
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1086
 * Draws text "Vehicles:" and number of all vehicle types, or "(none)"
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1087
 * @param player ID of player to print statistics of
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1088
 */
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
  1089
static void DrawPlayerVehiclesAmount(PlayerID player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1090
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1091
	const int x = 110;
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1092
	int y = 63;
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1093
	const Vehicle *v;
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1094
	uint train = 0;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1095
	uint road  = 0;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1096
	uint air   = 0;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1097
	uint ship  = 0;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
  1098
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
  1099
	DrawString(x, y, STR_7039_VEHICLES, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1100
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1101
	FOR_ALL_VEHICLES(v) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1102
		if (v->owner == player) {
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1103
			switch (v->type) {
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
  1104
				case VEH_TRAIN:    if (IsFrontEngine(v)) train++; break;
6857
60130753e595 (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 6769
diff changeset
  1105
				case VEH_ROAD:     if (IsRoadVehFront(v)) road++; break;
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
  1106
				case VEH_AIRCRAFT: if (IsNormalAircraft(v)) air++; break;
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
  1107
				case VEH_SHIP:     ship++; break;
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1108
				default: break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1109
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1110
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1111
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1112
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6352
diff changeset
  1113
	if (train + road + air + ship == 0) {
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
  1114
		DrawString(x + 70, y, STR_7042_NONE, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1115
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1116
		if (train != 0) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1117
			SetDParam(0, train);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
  1118
			DrawString(x + 70, y, STR_TRAINS, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1119
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1120
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1121
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1122
		if (road != 0) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1123
			SetDParam(0, road);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
  1124
			DrawString(x + 70, y, STR_ROAD_VEHICLES, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1125
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1126
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1127
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1128
		if (air != 0) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1129
			SetDParam(0, air);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
  1130
			DrawString(x + 70, y, STR_AIRCRAFT, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1131
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1132
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1133
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1134
		if (ship != 0) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1135
			SetDParam(0, ship);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
  1136
			DrawString(x + 70, y, STR_SHIPS, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1137
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1138
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1139
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1140
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
  1141
int GetAmountOwnedBy(const Player *p, PlayerID owner)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1142
{
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
  1143
	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
  1144
				 (p->share_owners[1] == owner) +
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
  1145
				 (p->share_owners[2] == owner) +
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1146
				 (p->share_owners[3] == owner);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1147
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1148
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1149
/**
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1150
 * Draws list of all companies with shares
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1151
 * @param p pointer to the Player structure
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1152
 */
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
  1153
static void DrawCompanyOwnerText(const Player *p)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1154
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1155
	const Player *p2;
7884
46547eab1ac8 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
  1156
	uint num = 0;
46547eab1ac8 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
  1157
	const byte height = GetCharacterHeight(FS_NORMAL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1158
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1159
	FOR_ALL_PLAYERS(p2) {
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
  1160
		uint amt = GetAmountOwnedBy(p, p2->index);
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
  1161
		if (amt != 0) {
7884
46547eab1ac8 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
  1162
			SetDParam(0, amt * 25);
46547eab1ac8 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
  1163
			SetDParam(1, p2->index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1164
7884
46547eab1ac8 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
  1165
			DrawString(120, (num++) * height + 116, STR_707D_OWNED_BY, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1166
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1167
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1168
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1169
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1170
/**
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1171
 * Player company window event definition
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1172
 *
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1173
 * @param w window pointer
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1174
 * @param e event been triggered
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1175
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1176
static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1177
{
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
  1178
	switch (e->event) {
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1179
		case WE_PAINT: {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1180
			const Player *p = GetPlayer((PlayerID)w->window_number);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1181
			bool local = w->window_number == _local_player;
1811
d5fa1c37e192 (svn r2315) - Fix: [ 1187613 ] No HQ present for competitor, disable 'View HQ' button, inspired by lucaspiller
Darkvater
parents: 1793
diff changeset
  1182
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1183
			w->SetWidgetHiddenState(PCW_WIDGET_NEW_FACE,       !local);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1184
			w->SetWidgetHiddenState(PCW_WIDGET_COLOR_SCHEME,   !local);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1185
			w->SetWidgetHiddenState(PCW_WIDGET_PRESIDENT_NAME, !local);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1186
			w->SetWidgetHiddenState(PCW_WIDGET_COMPANY_NAME,   !local);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1187
			w->widget[PCW_WIDGET_BUILD_VIEW_HQ].data = (local && p->location_of_house == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
4808
07bc43331422 (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
  1188
			if (local && p->location_of_house != 0) w->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1189
			w->SetWidgetDisabledState(PCW_WIDGET_BUILD_VIEW_HQ, !local && p->location_of_house == 0);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1190
			w->SetWidgetHiddenState(PCW_WIDGET_RELOCATE_HQ,      !local || p->location_of_house == 0);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1191
			w->SetWidgetHiddenState(PCW_WIDGET_BUY_SHARE,        local);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1192
			w->SetWidgetHiddenState(PCW_WIDGET_SELL_SHARE,       local);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1193
			w->SetWidgetHiddenState(PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
930
ab42e283749d (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
  1194
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1195
			if (!local) {
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1196
				if (_patches.allow_shares) { // Shares are allowed
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1197
					/* If all shares are owned by someone (none by nobody), disable buy button */
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1198
					w->SetWidgetDisabledState(PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 ||
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1199
							/* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */
4848
45f848b46222 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
  1200
							(GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) ||
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1201
							/* Spectators cannot do anything of course */
4848
45f848b46222 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
  1202
							_local_player == PLAYER_SPECTATOR);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1203
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1204
					/* If the player doesn't own any shares, disable sell button */
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1205
					w->SetWidgetDisabledState(PCW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(p, _local_player) == 0) ||
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1206
							/* Spectators cannot do anything of course */
4848
45f848b46222 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
  1207
							_local_player == PLAYER_SPECTATOR);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1208
				} else { // Shares are not allowed, disable buy/sell buttons
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1209
					w->DisableWidget(PCW_WIDGET_BUY_SHARE);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1210
					w->DisableWidget(PCW_WIDGET_SELL_SHARE);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1211
				}
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
  1212
			}
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1213
7058
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7002
diff changeset
  1214
			SetDParam(0, p->index);
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7002
diff changeset
  1215
			SetDParam(1, p->index);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1216
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1217
			DrawWindowWidgets(w);
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1218
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1219
			/* Player face */
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1220
			DrawPlayerFace(p->face, p->player_color, 2, 16);
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1221
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1222
			/* "xxx (Manager)" */
7058
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7002
diff changeset
  1223
			SetDParam(0, p->index);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1224
			DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94);
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1225
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1226
			/* "Inaugurated:" */
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1227
			SetDParam(0, p->inaugurated_year);
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1228
			DrawString(110, 23, STR_7038_INAUGURATED, TC_FROMSTRING);
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1229
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1230
			/* "Colour scheme:" */
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1231
			DrawString(110, 43, STR_7006_COLOR_SCHEME, TC_FROMSTRING);
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1232
			/* Draw company-colour bus */
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1233
			DrawSprite(SPR_VEH_BUS_SW_VIEW, PLAYER_SPRITE_COLOR(p->index), 215, 44);
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1234
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1235
			/* "Vehicles:" */
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1236
			DrawPlayerVehiclesAmount((PlayerID)w->window_number);
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1237
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1238
			/* "Company value:" */
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
  1239
			SetDParam(0, CalculateCompanyValue(p));
7884
46547eab1ac8 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
  1240
			DrawString(110, 106, STR_7076_COMPANY_VALUE, TC_FROMSTRING);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1241
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1242
			/* Shares list */
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1243
			DrawCompanyOwnerText(p);
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1244
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1245
			break;
773
a376cebd3dc0 (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
  1246
		}
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
  1247
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1248
		case WE_CLICK:
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1249
			switch (e->we.click.widget) {
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1250
				case PCW_WIDGET_NEW_FACE: DoSelectPlayerFace((PlayerID)w->window_number, false); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1251
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1252
				case PCW_WIDGET_COLOR_SCHEME: {
9143
029e126e3439 (svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
rubidium
parents: 9142
diff changeset
  1253
					Window *wf = AllocateWindowDescFront<Window>(_loaded_newgrf_features.has_2CC ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1254
					if (wf != NULL) {
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1255
						wf->caption_color = wf->window_number;
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6352
diff changeset
  1256
						WP(wf, livery_d).livery_class = LC_OTHER;
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6352
diff changeset
  1257
						WP(wf, livery_d).sel = 1;
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1258
						wf->LowerWidget(2);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1259
					}
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1260
					break;
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1261
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1262
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1263
				case PCW_WIDGET_PRESIDENT_NAME: {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1264
					const Player *p = GetPlayer((PlayerID)w->window_number);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1265
					WP(w, def_d).byte_1 = 0;
7058
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7002
diff changeset
  1266
					SetDParam(0, p->index);
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7002
diff changeset
  1267
					ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, 31, 94, w, CS_ALPHANUMERAL);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1268
					break;
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1269
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1270
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1271
				case PCW_WIDGET_COMPANY_NAME: {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1272
					Player *p = GetPlayer((PlayerID)w->window_number);
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6352
diff changeset
  1273
					WP(w, def_d).byte_1 = 1;
7058
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7002
diff changeset
  1274
					SetDParam(0, p->index);
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7002
diff changeset
  1275
					ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, 31, 150, w, CS_ALPHANUMERAL);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1276
					break;
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1277
				}
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1278
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1279
				case PCW_WIDGET_BUILD_VIEW_HQ: {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1280
					TileIndex tile = GetPlayer((PlayerID)w->window_number)->location_of_house;
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1281
					if (tile == 0) {
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1282
						if ((byte)w->window_number != _local_player)
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1283
							return;
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7884
diff changeset
  1284
						SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1285
						SetTileSelectSize(2, 2);
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1286
						w->LowerWidget(PCW_WIDGET_BUILD_VIEW_HQ);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7998
diff changeset
  1287
						w->InvalidateWidget(PCW_WIDGET_BUILD_VIEW_HQ);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1288
					} else {
9094
48004fcef409 (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents: 8969
diff changeset
  1289
						if (_ctrl_pressed) {
48004fcef409 (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents: 8969
diff changeset
  1290
							ShowExtraViewPortWindow(tile);
48004fcef409 (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents: 8969
diff changeset
  1291
						} else {
48004fcef409 (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents: 8969
diff changeset
  1292
							ScrollMainWindowToTile(tile);
48004fcef409 (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents: 8969
diff changeset
  1293
						}
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1294
					}
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1295
					break;
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1296
				}
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1297
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1298
				case PCW_WIDGET_RELOCATE_HQ:
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7884
diff changeset
  1299
					SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1300
					SetTileSelectSize(2, 2);
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7934
diff changeset
  1301
					w->LowerWidget(PCW_WIDGET_RELOCATE_HQ);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7998
diff changeset
  1302
					w->InvalidateWidget(PCW_WIDGET_RELOCATE_HQ);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1303
					break;
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1304
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1305
				case PCW_WIDGET_BUY_SHARE:
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1306
					DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS));
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1307
					break;
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1308
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1309
				case PCW_WIDGET_SELL_SHARE:
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1310
					DoCommandP(0, w->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN));
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1311
					break;
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1312
7998
9cf9f9153262 (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents: 7997
diff changeset
  1313
#ifdef ENABLE_NETWORK
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1314
				case PCW_WIDGET_COMPANY_PASSWORD:
7998
9cf9f9153262 (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents: 7997
diff changeset
  1315
					if (w->window_number == _local_player) ShowNetworkCompanyPasswordWindow();
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1316
					break;
7998
9cf9f9153262 (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents: 7997
diff changeset
  1317
#endif /* ENABLE_NETWORK */
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
  1318
			}
917
f30b62dce860 (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
  1319
			break;
f30b62dce860 (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
  1320
9161
fda175383e87 (svn r13024) -Codechange: do not use WE_MOUSELOOP when WE_TICK suffices, rename WE_4 to something more descriptive and correct some (completely incorrect) comments.
rubidium
parents: 9153
diff changeset
  1321
		case WE_TICK:
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1322
			/* redraw the window every now and then */
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9115
diff changeset
  1323
			if ((++w->vscroll.pos & 0x1F) == 0) w->SetDirty();
917
f30b62dce860 (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
  1324
			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
  1325
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1326
		case WE_PLACE_OBJ:
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7513
diff changeset
  1327
			if (DoCommandP(e->we.place.tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1328
				ResetObjectToPlace();
4808
07bc43331422 (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
  1329
				w->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button
8032
f35fba9bacb0 (svn r11592) -Codechange: Use the Window member RaiseButtons and remove the now useless RaiseWindowButtons function
belugas
parents: 8028
diff changeset
  1330
				w->RaiseButtons();
4808
07bc43331422 (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
  1331
			break;
07bc43331422 (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
  1332
07bc43331422 (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
  1333
		case WE_ABORT_PLACE_OBJ:
8032
f35fba9bacb0 (svn r11592) -Codechange: Use the Window member RaiseButtons and remove the now useless RaiseWindowButtons function
belugas
parents: 8028
diff changeset
  1334
			w->RaiseButtons();
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1335
			break;
773
a376cebd3dc0 (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
  1336
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1337
		case WE_DESTROY:
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1338
			DeleteWindowById(WC_PLAYER_FACE, w->window_number);
7998
9cf9f9153262 (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents: 7997
diff changeset
  1339
			if (w->window_number == _local_player) DeleteWindowById(WC_COMPANY_PASSWORD_WINDOW, 0);
773
a376cebd3dc0 (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
  1340
			break;
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1341
7998
9cf9f9153262 (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents: 7997
diff changeset
  1342
		case WE_ON_EDIT_TEXT:
9164
18e971e0b44f (svn r13027) -Codechange: use StrEmpty instead of arr[0] == '\0' and remove the need for WE_ON_EDIT_TEXT_CANCEL.
rubidium
parents: 9161
diff changeset
  1343
			if (StrEmpty(e->we.edittext.str)) break;
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1344
7998
9cf9f9153262 (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents: 7997
diff changeset
  1345
			_cmd_text = e->we.edittext.str;
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6352
diff changeset
  1346
			switch (WP(w, def_d).byte_1) {
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1347
				case 0: /* Change president name */
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1348
					DoCommandP(0, 0, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT));
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1349
					break;
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1350
				case 1: /* Change company name */
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1351
					DoCommandP(0, 0, 0, NULL, CMD_CHANGE_COMPANY_NAME | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME));
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1352
					break;
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1353
			}
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1354
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1355
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1356
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1357
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1358
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1359
static const WindowDesc _player_company_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
  1360
	WDP_AUTO, WDP_AUTO, 360, 170, 360, 170,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
  1361
	WC_COMPANY, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1362
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1363
	_player_company_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1364
	PlayerCompanyWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1365
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1366
2475
efdcc705cb61 (svn r3001) s/Player*/const Player*/
tron
parents: 2473
diff changeset
  1367
void ShowPlayerCompany(PlayerID player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1368
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1369
	Window *w;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1370
5005
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
  1371
	if (!IsValidPlayer(player)) return;
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
  1372
9143
029e126e3439 (svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
rubidium
parents: 9142
diff changeset
  1373
	w = AllocateWindowDescFront<Window>(&_player_company_desc, player);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1374
	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
  1375
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1376
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1377
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1378
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1379
static void BuyCompanyWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1380
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2725
diff changeset
  1381
	switch (e->event) {
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1382
		case WE_PAINT: {
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1383
			Player *p = GetPlayer((PlayerID)w->window_number);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1384
			SetDParam(0, STR_COMPANY_NAME);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1385
			SetDParam(1, p->index);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1386
			DrawWindowWidgets(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1387
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1388
			DrawPlayerFace(p->face, p->player_color, 2, 16);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1389
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1390
			SetDParam(0, p->index);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1391
			SetDParam(1, p->bankrupt_value);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1392
			DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1393
		} break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1394
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1395
		case WE_CLICK:
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1396
			switch (e->we.click.widget) {
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1397
				case 3:
9115
47ae980bace3 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 9111
diff changeset
  1398
					delete w;
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1399
					break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1400
				case 4: {
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1401
					DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY));
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1402
					break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1403
				}
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1404
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1405
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1406
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1407
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1408
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1409
static const Widget _buy_company_widgets[] = {
3326
00cf690a7fe1 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme
belugas
parents: 2952
diff changeset
  1410
{   WWT_CLOSEBOX,   RESIZE_NONE,     5,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
00cf690a7fe1 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme
belugas
parents: 2952
diff changeset
  1411
{    WWT_CAPTION,   RESIZE_NONE,     5,    11,   333,     0,    13, STR_00B3_MESSAGE_FROM, STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
  1412
{      WWT_PANEL,   RESIZE_NONE,     5,     0,   333,    14,   136, 0x0,                   STR_NULL},
3326
00cf690a7fe1 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme
belugas
parents: 2952
diff changeset
  1413
{    WWT_TEXTBTN,   RESIZE_NONE,     5,   148,   207,   117,   128, STR_00C9_NO,           STR_NULL},
00cf690a7fe1 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme
belugas
parents: 2952
diff changeset
  1414
{    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
  1415
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1416
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1417
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1418
static const WindowDesc _buy_company_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
  1419
	153, 171, 334, 137, 334, 137,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
  1420
	WC_BUY_COMPANY, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1421
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1422
	_buy_company_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1423
	BuyCompanyWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1424
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1425
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1426
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1427
void ShowBuyCompanyDialog(uint player)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1428
{
9143
029e126e3439 (svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
rubidium
parents: 9142
diff changeset
  1429
	AllocateWindowDescFront<Window>(&_buy_company_desc, player);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1430
}
983
4765bf636f6b (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
  1431
4765bf636f6b (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
  1432
/********** HIGHSCORE and ENDGAME windows */
4765bf636f6b (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
  1433
4765bf636f6b (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
  1434
/* Always draw a maximized window and within there the centered background */
4765bf636f6b (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
  1435
static void SetupHighScoreEndWindow(Window *w, uint *x, uint *y)
4765bf636f6b (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
  1436
{
4765bf636f6b (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
  1437
	uint i;
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
  1438
	/* resize window to "full-screen" */
983
4765bf636f6b (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
  1439
	w->width = _screen.width;
4765bf636f6b (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
  1440
	w->height = _screen.height;
4765bf636f6b (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
  1441
	w->widget[0].right = w->width - 1;
4765bf636f6b (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
  1442
	w->widget[0].bottom = w->height - 1;
4765bf636f6b (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
  1443
4765bf636f6b (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
  1444
	DrawWindowWidgets(w);
4765bf636f6b (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
  1445
4765bf636f6b (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
  1446
	/* Center Highscore/Endscreen background */
4765bf636f6b (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
  1447
	*x = max(0, (_screen.width  / 2) - (640 / 2));
4765bf636f6b (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
  1448
	*y = max(0, (_screen.height / 2) - (480 / 2));
4765bf636f6b (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
  1449
	for (i = 0; i < 10; i++) // the image is split into 10 50px high parts
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
  1450
		DrawSprite(WP(w, highscore_d).background_img + i, PAL_NONE, *x, *y + (i * 50));
983
4765bf636f6b (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
  1451
}
4765bf636f6b (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
  1452
4765bf636f6b (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
  1453
extern StringID EndGameGetPerformanceTitleFromValue(uint value);
4765bf636f6b (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
  1454
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
  1455
/** End game window shown at the end of the game */
983
4765bf636f6b (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
  1456
static void EndGameWndProc(Window *w, WindowEvent *e)
4765bf636f6b (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
  1457
{
4765bf636f6b (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
  1458
	switch (e->event) {
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1459
		case WE_PAINT: {
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1460
			const Player *p;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1461
			uint x, y;
4998
4aac6506e2ae (svn r7008) -Fix [FS#369]: Crash at game end when server company is bankrupt
Darkvater
parents: 4938
diff changeset
  1462
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1463
			SetupHighScoreEndWindow(w, &x, &y);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1464
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1465
			if (!IsValidPlayer(_local_player)) break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1466
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1467
			p = GetPlayer(_local_player);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1468
			/* We need to get performance from last year because the image is shown
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1469
			 * at the start of the new year when these things have already been copied */
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1470
			if (WP(w, highscore_d).background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1471
				SetDParam(0, p->index);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1472
				SetDParam(1, p->index);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1473
				SetDParam(2, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history));
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1474
				DrawStringMultiCenter(x + (640 / 2), y + 107, STR_021C_OF_ACHIEVES_STATUS, 640);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1475
			} else {
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1476
				SetDParam(0, p->index);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1477
				SetDParam(1, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history));
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1478
				DrawStringMultiCenter(x + (640 / 2), y + 157, STR_021B_ACHIEVES_STATUS, 640);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1479
			}
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1480
		} break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1481
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1482
		case WE_CLICK: /* Close the window (and show the highscore window) */
9115
47ae980bace3 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 9111
diff changeset
  1483
			delete w;
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1484
			break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1485
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1486
		case WE_DESTROY: /* Show the highscore window when this one is closed */
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1487
			if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1488
			ShowHighscoreTable(w->window_number, WP(w, highscore_d).rank);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1489
			break;
983
4765bf636f6b (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
  1490
	}
4765bf636f6b (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
  1491
}
4765bf636f6b (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
  1492
4765bf636f6b (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
  1493
static void HighScoreWndProc(Window *w, WindowEvent *e)
4765bf636f6b (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
  1494
{
4765bf636f6b (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
  1495
	switch (e->event) {
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1496
		case WE_PAINT: {
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1497
			const HighScore *hs = _highscore_table[w->window_number];
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1498
			uint x, y;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1499
			uint8 i;
983
4765bf636f6b (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
  1500
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1501
			SetupHighScoreEndWindow(w, &x, &y);
983
4765bf636f6b (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
  1502
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1503
			SetDParam(0, _patches.ending_year);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1504
			SetDParam(1, w->window_number + STR_6801_EASY);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1505
			DrawStringMultiCenter(x + (640 / 2), y + 62, !_networking ? STR_0211_TOP_COMPANIES_WHO_REACHED : STR_TOP_COMPANIES_NETWORK_GAME, 500);
1839
f64935a60abb (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
  1506
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1507
			/* Draw Highscore peepz */
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1508
			for (i = 0; i < lengthof(_highscore_table[0]); i++) {
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1509
				SetDParam(0, i + 1);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1510
				DrawString(x + 40, y + 140 + (i * 55), STR_0212, TC_BLACK);
1839
f64935a60abb (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
  1511
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1512
				if (hs[i].company[0] != '\0') {
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1513
					TextColour colour = (WP(w, highscore_d).rank == (int8)i) ? TC_RED : TC_BLACK; // draw new highscore in red
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1514
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1515
					DoDrawString(hs[i].company, x + 71, y + 140 + (i * 55), colour);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1516
					SetDParam(0, hs[i].title);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1517
					SetDParam(1, hs[i].score);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1518
					DrawString(x + 71, y + 160 + (i * 55), STR_HIGHSCORE_STATS, colour);
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1519
				}
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1520
			}
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1521
		} break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1522
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1523
		case WE_CLICK: /* Onclick to close window, and in destroy event handle the rest */
9115
47ae980bace3 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 9111
diff changeset
  1524
			delete w;
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1525
			break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1526
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1527
		case WE_DESTROY: /* Get back all the hidden windows */
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1528
			if (_game_mode != GM_MENU) ShowVitalWindows();
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1529
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1530
			if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1531
			break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1532
		}
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1533
}
983
4765bf636f6b (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
  1534
4765bf636f6b (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
  1535
static const Widget _highscore_widgets[] = {
4765bf636f6b (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
  1536
{      WWT_PANEL, RESIZE_NONE, 16, 0, 640, 0, 480, 0x0, STR_NULL},
4765bf636f6b (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
  1537
{   WIDGETS_END},
4765bf636f6b (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
  1538
};
4765bf636f6b (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
  1539
4765bf636f6b (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
  1540
static const WindowDesc _highscore_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
  1541
	0, 0, 641, 481, 641, 481,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
  1542
	WC_HIGHSCORE, WC_NONE,
983
4765bf636f6b (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
  1543
	0,
4765bf636f6b (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
  1544
	_highscore_widgets,
4765bf636f6b (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
  1545
	HighScoreWndProc
4765bf636f6b (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
  1546
};
4765bf636f6b (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
  1547
4765bf636f6b (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
  1548
static const WindowDesc _endgame_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
  1549
	0, 0, 641, 481, 641, 481,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
  1550
	WC_ENDSCREEN, WC_NONE,
983
4765bf636f6b (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
  1551
	0,
4765bf636f6b (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
  1552
	_highscore_widgets,
4765bf636f6b (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
  1553
	EndGameWndProc
4765bf636f6b (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
  1554
};
4765bf636f6b (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
  1555
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
  1556
/** Show the highscore table for a given difficulty. When called from
983
4765bf636f6b (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
  1557
 * endgame ranking is set to the top5 element that was newly added
4765bf636f6b (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
  1558
 * and is thus highlighted */
998
c90459c24842 (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
  1559
void ShowHighscoreTable(int difficulty, int8 ranking)
983
4765bf636f6b (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
  1560
{
4765bf636f6b (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
  1561
	Window *w;
4765bf636f6b (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
  1562
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
  1563
	/* pause game to show the chart */
1839
f64935a60abb (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
  1564
	if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
f64935a60abb (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
  1565
f64935a60abb (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
  1566
	/* Close all always on-top windows to get a clean screen */
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1567
	if (_game_mode != GM_MENU) HideVitalWindows();
983
4765bf636f6b (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
  1568
1875
f7155c837fa2 (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
  1569
	DeleteWindowByClass(WC_HIGHSCORE);
9142
858a058aa730 (svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents: 9127
diff changeset
  1570
	w = new Window(&_highscore_desc);
983
4765bf636f6b (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
  1571
4765bf636f6b (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
  1572
	if (w != NULL) {
4765bf636f6b (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
  1573
		MarkWholeScreenDirty();
4765bf636f6b (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
  1574
		w->window_number = difficulty; // show highscore chart for difficulty...
998
c90459c24842 (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
  1575
		WP(w, highscore_d).background_img = SPR_HIGHSCORE_CHART_BEGIN; // which background to show
c90459c24842 (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
  1576
		WP(w, highscore_d).rank = ranking;
983
4765bf636f6b (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
  1577
	}
4765bf636f6b (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
  1578
}
4765bf636f6b (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
  1579
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
  1580
/** Show the endgame victory screen in 2050. Update the new highscore
983
4765bf636f6b (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
  1581
 * if it was high enough */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6190
diff changeset
  1582
void ShowEndGameChart()
983
4765bf636f6b (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
  1583
{
4765bf636f6b (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
  1584
	Window *w;
4765bf636f6b (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
  1585
1839
f64935a60abb (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
  1586
	/* Dedicated server doesn't need the highscore window */
f64935a60abb (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
  1587
	if (_network_dedicated) return;
f64935a60abb (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
  1588
	/* Pause in single-player to have a look at the highscore at your own leisure */
f64935a60abb (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
  1589
	if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
983
4765bf636f6b (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
  1590
1839
f64935a60abb (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
  1591
	HideVitalWindows();
1875
f7155c837fa2 (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
  1592
	DeleteWindowByClass(WC_ENDSCREEN);
9142
858a058aa730 (svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents: 9127
diff changeset
  1593
	w = new Window(&_endgame_desc);
983
4765bf636f6b (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
  1594
4765bf636f6b (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
  1595
	if (w != NULL) {
4765bf636f6b (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
  1596
		MarkWholeScreenDirty();
1077
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1597
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1598
		WP(w, highscore_d).background_img = SPR_TYCOON_IMG1_BEGIN;
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1599
4848
45f848b46222 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
  1600
		if (_local_player != PLAYER_SPECTATOR) {
1962
8254df1b359b (svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents: 1914
diff changeset
  1601
			const Player *p = GetPlayer(_local_player);
1077
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1602
			if (p->old_economy[0].performance_history == SCORE_MAX)
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1603
				WP(w, highscore_d).background_img = SPR_TYCOON_IMG2_BEGIN;
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1604
		}
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1605
998
c90459c24842 (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
  1606
		/* In a network game show the endscores of the custom difficulty 'network' which is the last one
1077
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1607
		 * as well as generate a TOP5 of that game, and not an all-time top5. */
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1608
		if (_networking) {
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1609
			w->window_number = lengthof(_highscore_table) - 1;
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1610
			WP(w, highscore_d).rank = SaveHighScoreValueNetwork();
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1611
		} else {
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
  1612
			/* in single player _local player is always valid */
1962
8254df1b359b (svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents: 1914
diff changeset
  1613
			const Player *p = GetPlayer(_local_player);
1077
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1614
			w->window_number = _opt.diff_level;
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1615
			WP(w, highscore_d).rank = SaveHighScoreValue(p);
7da1f53526cd (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
  1616
		}
1109
ecb98f43ba2c (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents: 1077
diff changeset
  1617
	}
983
4765bf636f6b (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
  1618
}