src/player_gui.cpp
author peter1138
Thu, 29 May 2008 11:47:56 +0000
changeset 10773 88125a991761
parent 10707 81a4013a7680
child 10775 7061477bfbcf
permissions -rw-r--r--
(svn r13323) -Codechange: scrollbars are not refresh counters
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
10429
1b99254f9607 (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: 10411
diff changeset
     3
/** @file player_gui.cpp Player related GUIs. */
6678
6353b8865d42 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6585
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1875
diff changeset
     6
#include "openttd.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "gui.h"
8603
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     8
#include "window_gui.h"
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     9
#include "textbuf_gui.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8710
diff changeset
    10
#include "viewport_func.h"
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8710
diff changeset
    11
#include "gfx_func.h"
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8720
diff changeset
    12
#include "player_func.h"
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8720
diff changeset
    13
#include "player_base.h"
8612
6414fc21c2f3 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8610
diff changeset
    14
#include "command_func.h"
5720
cc0ceeafaa55 (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5682
diff changeset
    15
#include "network/network.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2064
diff changeset
    16
#include "variables.h"
7353
716c6dd9322a (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 7265
diff changeset
    17
#include "roadveh.h"
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2642
diff changeset
    18
#include "train.h"
6105
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5919
diff changeset
    19
#include "aircraft.h"
4742
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
    20
#include "newgrf.h"
5720
cc0ceeafaa55 (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5682
diff changeset
    21
#include "network/network_data.h"
cc0ceeafaa55 (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5682
diff changeset
    22
#include "network/network_client.h"
8494
88f26cafc858 (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents: 8493
diff changeset
    23
#include "network/network_gui.h"
6516
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
    24
#include "player_face.h"
8610
17cc343a23dd (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8603
diff changeset
    25
#include "strings_func.h"
8627
448ebf3a8291 (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: 8617
diff changeset
    26
#include "functions.h"
448ebf3a8291 (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: 8617
diff changeset
    27
#include "window_func.h"
8636
2b158acb649c (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8627
diff changeset
    28
#include "date_func.h"
8710
52015340050c (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8640
diff changeset
    29
#include "string_func.h"
8766
c86cfa3a7580 (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8760
diff changeset
    30
#include "settings_type.h"
8780
6f3f3ec6c69a (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: 8766
diff changeset
    31
#include "widgets/dropdown_func.h"
10145
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
    32
#include "widgets/dropdown_type.h"
10445
2dd7d9d0a957 (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 10434
diff changeset
    33
#include "tilehighlight_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    35
#include "table/sprites.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    36
#include "table/strings.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    37
10103
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
    38
enum {
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
    39
	FIRST_GUI_CALL = INT_MAX,  ///< default value to specify thuis is the first call of the resizable gui
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
    40
};
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
    41
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
    42
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied, int top = FIRST_GUI_CALL, int left = FIRST_GUI_CALL);
10563
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
    43
static void DoSelectPlayerFace(Window *parent, 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
    44
10573
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
    45
static void DrawPlayerEconomyStats(const Player *p, bool small)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
{
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6678
diff changeset
    47
	int x, y, i, j, year;
9011
d5db20f3fc90 (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8839
diff changeset
    48
	const Money (*tbl)[EXPENSES_END];
7486
d130c10f4dab (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 7448
diff changeset
    49
	Money sum, cost;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
	StringID str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
10573
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
    52
	if (!small) { // normal sized economics window
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
		/* draw categories */
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
    54
		DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, TC_FROMSTRING);
10220
56a37f555175 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 10145
diff changeset
    55
		for (i = 0; i != EXPENSES_END; i++)
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
    56
			DrawString(2, 27 + i * 10, STR_7011_CONSTRUCTION + i, TC_FROMSTRING);
10220
56a37f555175 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 10145
diff changeset
    57
		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
    58
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
		/* draw the price columns */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
		year = _cur_year - 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
		j = 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
		x = 215;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
		tbl = p->yearly_expenses + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
		do {
4329
9759d5c52010 (svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents: 4314
diff changeset
    65
			if (year >= p->inaugurated_year) {
4293
2c24234a7aec (svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents: 4286
diff changeset
    66
				SetDParam(0, year);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
    67
				DrawStringRightAlignedUnderline(x, 15, STR_7010, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
				sum = 0;
10220
56a37f555175 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 10145
diff changeset
    69
				for (i = 0; i != EXPENSES_END; i++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
					/* draw one row in the price column */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
					cost = (*tbl)[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
					if (cost != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
						sum += cost;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
    74
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
						str = STR_701E;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
						if (cost < 0) { cost = -cost; str++; }
7498
ce6588257e8d (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: 7487
diff changeset
    77
						SetDParam(0, cost);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
    78
						DrawStringRightAligned(x, 27 + i * 10, str, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
				str = STR_701E;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
				if (sum < 0) { sum = -sum; str++; }
7498
ce6588257e8d (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: 7487
diff changeset
    84
				SetDParam(0, sum);
10220
56a37f555175 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 10145
diff changeset
    85
				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
    86
10220
56a37f555175 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 10145
diff changeset
    87
				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
    88
				x += 95;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
			year++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
			tbl--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
		} while (--j != 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
10220
56a37f555175 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 10145
diff changeset
    94
		y = 27 + 10 * EXPENSES_END + 14;
186
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    95
6678
6353b8865d42 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6585
diff changeset
    96
		/* draw max loan aligned to loan below (y += 10) */
7498
ce6588257e8d (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: 7487
diff changeset
    97
		SetDParam(0, _economy.max_loan);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
    98
		DrawString(202, y + 10, STR_MAX_LOAN, TC_FROMSTRING);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    99
	} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
		y = 15;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   101
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
   103
	DrawString(2, y, STR_7026_BANK_BALANCE, TC_FROMSTRING);
7498
ce6588257e8d (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: 7487
diff changeset
   104
	SetDParam(0, p->player_money);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
   105
	DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
	y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
   109
	DrawString(2, y, STR_7027_LOAN, TC_FROMSTRING);
7498
ce6588257e8d (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: 7487
diff changeset
   110
	SetDParam(0, p->current_loan);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
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 += 12;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6678
diff changeset
   115
	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
   116
7498
ce6588257e8d (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: 7487
diff changeset
   117
	SetDParam(0, p->player_money - p->current_loan);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
   118
	DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
8835
4a8e24bfde22 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8805
diff changeset
   121
enum PlayerFinancesWindowWidgets {
4a8e24bfde22 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8805
diff changeset
   122
	PFW_WIDGET_TOGGLE_SIZE   = 2,
4a8e24bfde22 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8805
diff changeset
   123
	PFW_WIDGET_INCREASE_LOAN = 6,
4a8e24bfde22 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8805
diff changeset
   124
	PFW_WIDGET_REPAY_LOAN    = 7,
4a8e24bfde22 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8805
diff changeset
   125
};
4a8e24bfde22 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8805
diff changeset
   126
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
static const Widget _player_finances_widgets[] = {
4937
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   128
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   129
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   379,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   130
{     WWT_IMGBTN,   RESIZE_NONE,    14,   380,   394,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   131
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   395,   406,     0,    13, 0x0,                    STR_STICKY_BUTTON},
10229
fba3f9fa44d7 (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 10220
diff changeset
   132
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   406,    14, 39 + 10 * EXPENSES_END, 0x0,    STR_NULL},
10220
56a37f555175 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 10145
diff changeset
   133
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   406, 40 + 10 * EXPENSES_END, 73 + 10 * EXPENSES_END, 0x0, STR_NULL},
56a37f555175 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 10145
diff changeset
   134
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   202, 74 + 10 * EXPENSES_END, 85 + 10 * EXPENSES_END, STR_7029_BORROW,        STR_7035_INCREASE_SIZE_OF_LOAN},
56a37f555175 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 10145
diff changeset
   135
{ 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
   136
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
static const Widget _player_finances_small_widgets[] = {
4937
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   140
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   141
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   253,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   142
{     WWT_IMGBTN,   RESIZE_NONE,    14,   254,   267,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   143
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   268,   279,     0,    13, 0x0,                    STR_STICKY_BUTTON},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   144
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                    STR_NULL},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   145
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   279,    14,    47, STR_NULL,               STR_NULL},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   146
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   139,    48,    59, STR_7029_BORROW,        STR_7035_INCREASE_SIZE_OF_LOAN},
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   147
{ 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
   148
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
10573
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   151
struct PlayerFinancesWindow : Window {
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   152
	bool small;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
10573
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   154
	PlayerFinancesWindow(const WindowDesc *desc, PlayerID player, bool show_small,
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   155
					bool show_stickied, int top, int left) :
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   156
			Window(desc, player),
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   157
			small(show_small)
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   158
	{
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   159
		this->caption_color = this->window_number;
10104
29e5b919d4a1 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 10103
diff changeset
   160
10573
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   161
		if (show_stickied) this->flags4 |= WF_STICKY;
10104
29e5b919d4a1 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 10103
diff changeset
   162
10573
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   163
		/* Check if repositioning from default is required */
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   164
		if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) {
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   165
			this->top = top;
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   166
			this->left = left;
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   167
		}
10681
3aa3de4d448b (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 10680
diff changeset
   168
3aa3de4d448b (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 10680
diff changeset
   169
		this->FindWindowPlacementAndResize(desc);
10573
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   170
	}
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   171
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   172
	virtual void OnPaint()
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   173
	{
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   174
		PlayerID player = (PlayerID)this->window_number;
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   175
		const Player *p = GetPlayer(player);
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   176
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   177
		/* Recheck the size of the window as it might need to be resized due to the local player changing */
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   178
		int new_height = ((player != _local_player) ? 0 : 12) + ((this->small != 0) ? 48 : 74 + 10 * EXPENSES_END);
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   179
		if (this->height != new_height) {
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   180
			/* Make window dirty before and after resizing */
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   181
			this->SetDirty();
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   182
			this->height = new_height;
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   183
			this->SetDirty();
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   184
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   185
			this->SetWidgetHiddenState(PFW_WIDGET_INCREASE_LOAN, player != _local_player);
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   186
			this->SetWidgetHiddenState(PFW_WIDGET_REPAY_LOAN,    player != _local_player);
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   187
		}
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   188
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   189
		/* Borrow button only shows when there is any more money to loan */
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   190
		this->SetWidgetDisabledState(PFW_WIDGET_INCREASE_LOAN, p->current_loan == _economy.max_loan);
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   191
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   192
		/* Repay button only shows when there is any more money to repay */
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   193
		this->SetWidgetDisabledState(PFW_WIDGET_REPAY_LOAN, player != _local_player || p->current_loan == 0);
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   194
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   195
		SetDParam(0, p->index);
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   196
		SetDParam(1, p->index);
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   197
		SetDParam(2, LOAN_INTERVAL);
10595
7957c71b0dfe (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 10574
diff changeset
   198
		this->DrawWidgets();
10573
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   199
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   200
		DrawPlayerEconomyStats(p, this->small);
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   201
	}
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   202
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   203
	virtual void OnClick(Point pt, int widget)
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   204
	{
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   205
		switch (widget) {
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   206
			case PFW_WIDGET_TOGGLE_SIZE: {/* toggle size */
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   207
				bool new_mode = !this->small;
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   208
				bool stickied = !!(this->flags4 & WF_STICKY);
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   209
				int oldtop = this->top;   ///< current top position of the window before closing it
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   210
				int oldleft = this->left; ///< current left position of the window before closing it
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   211
				PlayerID player = (PlayerID)this->window_number;
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   212
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   213
				delete this;
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   214
				/* Open up the (toggled size) Finance window at the same position as the previous */
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   215
				DoShowPlayerFinances(player, new_mode, stickied, oldtop, oldleft);
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   216
			}
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   217
			break;
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   218
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   219
			case PFW_WIDGET_INCREASE_LOAN: /* increase loan */
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   220
				DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY));
10104
29e5b919d4a1 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 10103
diff changeset
   221
				break;
29e5b919d4a1 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 10103
diff changeset
   222
10573
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   223
			case PFW_WIDGET_REPAY_LOAN: /* repay loan */
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   224
				DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN));
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   225
				break;
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   226
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
	}
10573
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   228
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
static const WindowDesc _player_finances_desc = {
10220
56a37f555175 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 10145
diff changeset
   231
	WDP_AUTO, WDP_AUTO, 407, 86 + 10 * EXPENSES_END, 407, 86 + 10 * EXPENSES_END,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
   232
	WC_FINANCES, WC_NONE,
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   233
	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
   234
	_player_finances_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
static const WindowDesc _player_finances_small_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
   238
	WDP_AUTO, WDP_AUTO, 280, 60, 280, 60,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
   239
	WC_FINANCES, WC_NONE,
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   240
	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
   241
	_player_finances_small_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
10103
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
   244
/**
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
   245
 * Open the small/large finance window of the player
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
   246
 *
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
   247
 * @param player         the player who's finances are requested to be seen
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
   248
 * @param show_small     show large or small version opf the window
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
   249
 * @param show_stickied  previous "stickyness" of the window
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
   250
 * @param top            previous top position of the window
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
   251
 * @param left           previous left position of the window
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
   252
 *
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
   253
 * @pre is player a valid player
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
   254
 */
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
   255
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
   256
{
5005
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   257
	if (!IsValidPlayer(player)) return;
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   258
10573
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   259
	if (BringWindowToFrontById(WC_FINANCES, player)) return;
ccd86de2c268 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 10563
diff changeset
   260
	new PlayerFinancesWindow(show_small ? &_player_finances_small_desc : &_player_finances_desc, player, show_small, show_stickied, top, left);
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
2475
8443e1eefe1b (svn r3001) s/Player*/const Player*/
tron
parents: 2473
diff changeset
   263
void ShowPlayerFinances(PlayerID player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
{
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   265
	DoShowPlayerFinances(player, false, false);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   268
/* List of colours for the livery window */
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   269
static const StringID _colour_dropdown[] = {
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   270
	STR_00D1_DARK_BLUE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   271
	STR_00D2_PALE_GREEN,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   272
	STR_00D3_PINK,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   273
	STR_00D4_YELLOW,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   274
	STR_00D5_RED,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   275
	STR_00D6_LIGHT_BLUE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   276
	STR_00D7_GREEN,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   277
	STR_00D8_DARK_GREEN,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   278
	STR_00D9_BLUE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   279
	STR_00DA_CREAM,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   280
	STR_00DB_MAUVE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   281
	STR_00DC_PURPLE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   282
	STR_00DD_ORANGE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   283
	STR_00DE_BROWN,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   284
	STR_00DF_GREY,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   285
	STR_00E0_WHITE,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   286
};
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   287
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   288
/* Association of liveries to livery classes */
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   289
static const LiveryClass _livery_class[LS_END] = {
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   290
	LC_OTHER,
8805
7269d54ce5dc (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: 8780
diff changeset
   291
	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
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   292
	LC_ROAD, LC_ROAD,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   293
	LC_SHIP, LC_SHIP,
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   294
	LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT,
7220
a8d6abc0981f (svn r9956) -Codechange: Add tram livery schemes
peter1138
parents: 6987
diff changeset
   295
	LC_ROAD, LC_ROAD,
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   296
};
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   297
10145
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   298
class DropDownListColourItem : public DropDownListItem {
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   299
public:
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   300
	DropDownListColourItem(int result, bool masked) : DropDownListItem(result, masked) {}
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   301
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   302
	virtual ~DropDownListColourItem() {}
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   303
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   304
	virtual StringID String() const
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   305
	{
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   306
		return _colour_dropdown[this->result];
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   307
	}
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   308
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   309
	virtual uint Height(uint width) const
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   310
	{
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   311
		return 14;
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   312
	}
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   313
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   314
	virtual void Draw(int x, int y, uint width, uint height, bool sel) const
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   315
	{
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   316
		DrawSprite(SPR_VEH_BUS_SIDE_VIEW, PALETTE_RECOLOR_START + this->result, x + 16, y + 7);
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   317
		DrawStringTruncated(x + 32, y + 3, this->String(), sel ? TC_WHITE : TC_BLACK, x + width - 30);
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   318
	}
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   319
};
b99176833a38 (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 10104
diff changeset
   320
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   321
struct SelectPlayerLiveryWindow : public Window {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   322
private:
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   323
	uint32 sel;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   324
	LiveryClass livery_class;
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   325
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   326
	enum PlayerLiveryWindowWidgets {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   327
		PLW_WIDGET_CLOSE,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   328
		PLW_WIDGET_CAPTION,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   329
		PLW_WIDGET_CLASS_GENERAL,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   330
		PLW_WIDGET_CLASS_RAIL,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   331
		PLW_WIDGET_CLASS_ROAD,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   332
		PLW_WIDGET_CLASS_SHIP,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   333
		PLW_WIDGET_CLASS_AIRCRAFT,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   334
		PLW_WIDGET_SPACER_CLASS,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   335
		PLW_WIDGET_SPACER_DROPDOWN,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   336
		PLW_WIDGET_PRI_COL_DROPDOWN,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   337
		PLW_WIDGET_SEC_COL_DROPDOWN,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   338
		PLW_WIDGET_MATRIX,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   339
	};
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   340
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   341
	void ShowColourDropDownMenu(uint32 widget)
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   342
	{
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   343
		uint32 used_colours = 0;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   344
		const Livery *livery;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   345
		LiveryScheme scheme;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   346
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   347
		/* Disallow other player colours for the primary colour */
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   348
		if (HasBit(this->sel, LS_DEFAULT) && widget == PLW_WIDGET_PRI_COL_DROPDOWN) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   349
			const Player *p;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   350
			FOR_ALL_PLAYERS(p) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   351
				if (p->is_active && p->index != _local_player) SetBit(used_colours, p->player_color);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   352
			}
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   353
		}
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   354
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   355
		/* Get the first selected livery to use as the default dropdown item */
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   356
		for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   357
			if (HasBit(this->sel, scheme)) break;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   358
		}
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   359
		if (scheme == LS_END) scheme = LS_DEFAULT;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   360
		livery = &GetPlayer((PlayerID)this->window_number)->livery[scheme];
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   361
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   362
		DropDownList *list = new DropDownList();
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   363
		for (uint i = 0; i < lengthof(_colour_dropdown); i++) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   364
			list->push_back(new DropDownListColourItem(i, HasBit(used_colours, i)));
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   365
		}
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   366
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   367
		ShowDropDownList(this, list, widget == PLW_WIDGET_PRI_COL_DROPDOWN ? livery->colour1 : livery->colour2, widget);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   368
	}
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   369
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   370
public:
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   371
	SelectPlayerLiveryWindow(const WindowDesc *desc, PlayerID player) : Window(desc, player)
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   372
	{
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   373
		this->caption_color = player;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   374
		this->livery_class = LC_OTHER;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   375
		this->sel = 1;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   376
		this->LowerWidget(PLW_WIDGET_CLASS_GENERAL);
10552
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   377
		this->OnInvalidateData(_loaded_newgrf_features.has_2CC);
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   378
		this->FindWindowPlacementAndResize(desc);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   379
	}
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   380
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   381
	virtual void OnPaint()
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   382
	{
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   383
		const Player *p = GetPlayer((PlayerID)this->window_number);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   384
		LiveryScheme scheme = LS_DEFAULT;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   385
		int y = 51;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   386
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   387
		/* Disable dropdown controls if no scheme is selected */
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   388
		this->SetWidgetDisabledState(PLW_WIDGET_PRI_COL_DROPDOWN, this->sel == 0);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   389
		this->SetWidgetDisabledState(PLW_WIDGET_SEC_COL_DROPDOWN, this->sel == 0);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   390
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   391
		if (this->sel != 0) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   392
			for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   393
				if (HasBit(this->sel, scheme)) break;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   394
			}
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   395
			if (scheme == LS_END) scheme = LS_DEFAULT;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   396
		}
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   397
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   398
		SetDParam(0, STR_00D1_DARK_BLUE + p->livery[scheme].colour1);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   399
		SetDParam(1, STR_00D1_DARK_BLUE + p->livery[scheme].colour2);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   400
10595
7957c71b0dfe (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 10574
diff changeset
   401
		this->DrawWidgets();
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   402
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   403
		for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   404
			if (_livery_class[scheme] == this->livery_class) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   405
				bool sel = HasBit(this->sel, scheme) != 0;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   406
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   407
				if (scheme != LS_DEFAULT) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   408
					DrawSprite(p->livery[scheme].in_use ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, 2, y);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   409
				}
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   410
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   411
				DrawString(15, y, STR_LIVERY_DEFAULT + scheme, sel ? TC_WHITE : TC_BLACK);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   412
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   413
				DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour1), 152, y);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   414
				DrawString(165, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour1, sel ? TC_WHITE : TC_GOLD);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   415
10552
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   416
				if (!this->IsWidgetHidden(PLW_WIDGET_SEC_COL_DROPDOWN)) {
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   417
					DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour2), 277, y);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   418
					DrawString(290, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour2, sel ? TC_WHITE : TC_GOLD);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   419
				}
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   420
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   421
				y += 14;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   422
			}
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   423
		}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   424
	}
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   425
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   426
	virtual void OnClick(Point pt, int widget)
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   427
	{
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   428
		/* Number of liveries in each class, used to determine the height of the livery window */
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   429
		static const byte livery_height[] = {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   430
			1,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   431
			13,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   432
			4,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   433
			2,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   434
			3,
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   435
		};
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   436
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   437
		switch (widget) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   438
			/* Livery Class buttons */
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   439
			case PLW_WIDGET_CLASS_GENERAL:
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   440
			case PLW_WIDGET_CLASS_RAIL:
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   441
			case PLW_WIDGET_CLASS_ROAD:
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   442
			case PLW_WIDGET_CLASS_SHIP:
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   443
			case PLW_WIDGET_CLASS_AIRCRAFT: {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   444
				LiveryScheme scheme;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   445
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   446
				this->RaiseWidget(this->livery_class + PLW_WIDGET_CLASS_GENERAL);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   447
				this->livery_class = (LiveryClass)(widget - PLW_WIDGET_CLASS_GENERAL);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   448
				this->sel = 0;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   449
				this->LowerWidget(this->livery_class + PLW_WIDGET_CLASS_GENERAL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   451
				/* Select the first item in the list */
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   452
				for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   453
					if (_livery_class[scheme] == this->livery_class) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   454
						this->sel = 1 << scheme;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   455
						break;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   456
					}
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   457
				}
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   458
				this->height = 49 + livery_height[this->livery_class] * 14;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   459
				this->widget[PLW_WIDGET_MATRIX].bottom = this->height - 1;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   460
				this->widget[PLW_WIDGET_MATRIX].data = livery_height[this->livery_class] << 8 | 1;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   461
				MarkWholeScreenDirty();
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   462
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
			}
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   464
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   465
			case PLW_WIDGET_PRI_COL_DROPDOWN: /* First colour dropdown */
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   466
				ShowColourDropDownMenu(PLW_WIDGET_PRI_COL_DROPDOWN);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   467
				break;
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   468
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   469
			case PLW_WIDGET_SEC_COL_DROPDOWN: /* Second colour dropdown */
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   470
				ShowColourDropDownMenu(PLW_WIDGET_SEC_COL_DROPDOWN);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   471
				break;
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   472
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   473
			case PLW_WIDGET_MATRIX: {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   474
				LiveryScheme scheme;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   475
				LiveryScheme j = (LiveryScheme)((pt.y - 48) / 14);
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   476
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   477
				for (scheme = LS_BEGIN; scheme <= j; scheme++) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   478
					if (_livery_class[scheme] != this->livery_class) j++;
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   479
					if (scheme >= LS_END) return;
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   480
				}
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   481
				if (j >= LS_END) return;
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   482
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   483
				/* If clicking on the left edge, toggle using the livery */
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   484
				if (pt.x < 10) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   485
					DoCommandP(0, j | (2 << 8), !GetPlayer((PlayerID)this->window_number)->livery[j].in_use, NULL, CMD_SET_PLAYER_COLOR);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   486
				}
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   487
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   488
				if (_ctrl_pressed) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   489
					ToggleBit(this->sel, j);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   490
				} else {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   491
					this->sel = 1 << j;
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   492
				}
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   493
				this->SetDirty();
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   494
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
			}
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   496
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
	}
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   498
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   499
	virtual void OnDropdownSelect(int widget, int index)
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   500
	{
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   501
		for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   502
			if (HasBit(this->sel, scheme)) {
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   503
				DoCommandP(0, scheme | (widget == PLW_WIDGET_PRI_COL_DROPDOWN ? 0 : 256), index, NULL, CMD_SET_PLAYER_COLOR);
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   504
			}
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   505
		}
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   506
	}
10552
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   507
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   508
	virtual void OnInvalidateData(int data = 0)
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   509
	{
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   510
		static bool has2cc = true;
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   511
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   512
		if (has2cc == !!data) return;
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   513
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   514
		has2cc = !!data;
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   515
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   516
		int r = this->widget[has2cc ? PLW_WIDGET_SEC_COL_DROPDOWN : PLW_WIDGET_PRI_COL_DROPDOWN].right;
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   517
		this->SetWidgetHiddenState(PLW_WIDGET_SEC_COL_DROPDOWN, !has2cc);
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   518
		this->widget[PLW_WIDGET_CAPTION].right = r;
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   519
		this->widget[PLW_WIDGET_SPACER_CLASS].right = r;
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   520
		this->widget[PLW_WIDGET_MATRIX].right = r;
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   521
		this->width = r + 1;
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   522
	}
10551
a5c3882d845b (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 10526
diff changeset
   523
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
10552
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   525
static const Widget _select_player_livery_widgets[] = {
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   526
{ WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,                  STR_018B_CLOSE_WINDOW },
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   527
{  WWT_CAPTION, RESIZE_NONE, 14,  11, 399,   0,  13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
4647
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   528
{   WWT_IMGBTN, RESIZE_NONE, 14,   0,  21,  14,  35, SPR_IMG_COMPANY_GENERAL,   STR_LIVERY_GENERAL_TIP },
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   529
{   WWT_IMGBTN, RESIZE_NONE, 14,  22,  43,  14,  35, SPR_IMG_TRAINLIST,         STR_LIVERY_TRAIN_TIP },
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   530
{   WWT_IMGBTN, RESIZE_NONE, 14,  44,  65,  14,  35, SPR_IMG_TRUCKLIST,         STR_LIVERY_ROADVEH_TIP },
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   531
{   WWT_IMGBTN, RESIZE_NONE, 14,  66,  87,  14,  35, SPR_IMG_SHIPLIST,          STR_LIVERY_SHIP_TIP },
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   532
{   WWT_IMGBTN, RESIZE_NONE, 14,  88, 109,  14,  35, SPR_IMG_AIRPLANESLIST,     STR_LIVERY_AIRCRAFT_TIP },
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   533
{    WWT_PANEL, RESIZE_NONE, 14, 110, 399,  14,  35, 0x0,                       STR_NULL },
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   534
{    WWT_PANEL, RESIZE_NONE, 14,   0, 149,  36,  47, 0x0,                       STR_NULL },
8839
bd8a5bb77cd7 (svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents: 8835
diff changeset
   535
{ WWT_DROPDOWN, RESIZE_NONE, 14, 150, 274,  36,  47, STR_02BD,                  STR_LIVERY_PRIMARY_TIP },
bd8a5bb77cd7 (svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents: 8835
diff changeset
   536
{ WWT_DROPDOWN, RESIZE_NONE, 14, 275, 399,  36,  47, STR_02E1,                  STR_LIVERY_SECONDARY_TIP },
4647
348ce824c439 (svn r6523) - 'Feature'/'Fix': Add tooltips to the new company colour window
peter1138
parents: 4634
diff changeset
   537
{   WWT_MATRIX, RESIZE_NONE, 14,   0, 399,  48,  48 + 1 * 14, (1 << 8) | 1,     STR_LIVERY_PANEL_TIP },
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   538
{ WIDGETS_END },
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   539
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
10552
9afd20b2effd (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 10551
diff changeset
   541
static const WindowDesc _select_player_livery_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
   542
	WDP_AUTO, WDP_AUTO, 400, 49 + 1 * 14, 400, 49 + 1 * 14,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
   543
	WC_PLAYER_COLOR, WC_NONE,
4742
d5a2d3da5002 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   544
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
4603
3ccd4ee0a2e2 (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   545
	_select_player_livery_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   546
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   547
6516
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   548
/**
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   549
 * Draws the face of a player.
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   550
 * @param pf    the player's face
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   551
 * @param color the (background) color of the gradient
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   552
 * @param x     x-position to draw the face
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   553
 * @param y     y-position to draw the face
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   554
 */
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   555
void DrawPlayerFace(PlayerFace pf, int color, int x, int y)
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   556
{
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   557
	GenderEthnicity ge = (GenderEthnicity)GetPlayerFaceBits(pf, PFV_GEN_ETHN, GE_WM);
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   558
8424
4a488a90ccab (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 8385
diff changeset
   559
	bool has_moustache   = !HasBit(ge, GENDER_FEMALE) && GetPlayerFaceBits(pf, PFV_HAS_MOUSTACHE,   ge) != 0;
4a488a90ccab (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 8385
diff changeset
   560
	bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetPlayerFaceBits(pf, PFV_HAS_TIE_EARRING, ge) != 0;
6516
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   561
	bool has_glasses     = GetPlayerFaceBits(pf, PFV_HAS_GLASSES, ge) != 0;
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   562
	SpriteID pal;
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   563
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   564
	/* Modify eye colour palette only if 2 or more valid values exist */
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   565
	if (_pf_info[PFV_EYE_COLOUR].valid_values[ge] < 2) {
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   566
		pal = PAL_NONE;
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   567
	} else {
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   568
		switch (GetPlayerFaceBits(pf, PFV_EYE_COLOUR, ge)) {
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   569
			default: NOT_REACHED();
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   570
			case 0: pal = PALETTE_TO_BROWN; break;
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   571
			case 1: pal = PALETTE_TO_BLUE;  break;
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   572
			case 2: pal = PALETTE_TO_GREEN; break;
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   573
		}
6516
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   574
	}
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   575
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   576
	/* Draw the gradient (background) */
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   577
	DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOR(color), x, y);
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   578
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   579
	for (PlayerFaceVariable pfv = PFV_CHEEKS; pfv < PFV_END; pfv++) {
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   580
		switch (pfv) {
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   581
			case PFV_MOUSTACHE:   if (!has_moustache)   continue; break;
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   582
			case PFV_LIPS:        /* FALL THROUGH */
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   583
			case PFV_NOSE:        if (has_moustache)    continue; break;
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   584
			case PFV_TIE_EARRING: if (!has_tie_earring) continue; break;
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   585
			case PFV_GLASSES:     if (!has_glasses)     continue; break;
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   586
			default: break;
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   587
		}
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   588
		DrawSprite(GetPlayerFaceSprite(pf, pfv, ge), (pfv == PFV_EYEBROWS) ? pal : PAL_NONE, x, y);
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   589
	}
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   590
}
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6144
diff changeset
   591
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   592
/** Widget description for the normal/simple player face selection dialog */
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   593
static const Widget _select_player_face_widgets[] = {
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   594
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},              // PFW_WIDGET_CLOSEBOX
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   595
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   174,     0,    13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // PFW_WIDGET_CAPTION
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   596
{     WWT_IMGBTN,   RESIZE_NONE,    14,   175,   189,     0,    13, SPR_LARGE_SMALL_WINDOW,  STR_FACE_ADVANCED_TIP},              // PFW_WIDGET_TOGGLE_LARGE_SMALL
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   597
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   189,    14,   150, 0x0,                     STR_NULL},                           // PFW_WIDGET_SELECT_FACE
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   598
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    94,   151,   162, STR_012E_CANCEL,         STR_7047_CANCEL_NEW_FACE_SELECTION}, // PFW_WIDGET_CANCEL
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   599
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    95,   189,   151,   162, STR_012F_OK,             STR_7048_ACCEPT_NEW_FACE_SELECTION}, // PFW_WIDGET_ACCEPT
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   600
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    95,   187,    75,    86, STR_7044_MALE,           STR_7049_SELECT_MALE_FACES},         // PFW_WIDGET_MALE
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   601
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    95,   187,    87,    98, STR_7045_FEMALE,         STR_704A_SELECT_FEMALE_FACES},       // PFW_WIDGET_FEMALE
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   602
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     2,    93,   137,   148, STR_7046_NEW_FACE,       STR_704B_GENERATE_RANDOM_NEW_FACE},  // PFW_WIDGET_RANDOM_NEW_FACE
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   603
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    95,   187,    16,    27, STR_FACE_ADVANCED,       STR_FACE_ADVANCED_TIP},              // PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   604
{   WIDGETS_END},
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   605
};
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   606
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   607
/** Widget description for the advanced player face selection dialog */
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   608
static const Widget _select_player_face_adv_widgets[] = {
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   609
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},              // PFW_WIDGET_CLOSEBOX
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   610
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   204,     0,    13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // PFW_WIDGET_CAPTION
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   611
{     WWT_IMGBTN,   RESIZE_NONE,    14,   205,   219,     0,    13, SPR_LARGE_SMALL_WINDOW,  STR_FACE_SIMPLE_TIP},                // PFW_WIDGET_TOGGLE_LARGE_SMALL
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   612
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   219,    14,   207, 0x0,                     STR_NULL},                           // PFW_WIDGET_SELECT_FACE
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   613
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    94,   208,   219, STR_012E_CANCEL,         STR_7047_CANCEL_NEW_FACE_SELECTION}, // PFW_WIDGET_CANCEL
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   614
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    95,   219,   208,   219, STR_012F_OK,             STR_7048_ACCEPT_NEW_FACE_SELECTION}, // PFW_WIDGET_ACCEPT
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   615
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    96,   156,    32,    43, STR_7044_MALE,           STR_7049_SELECT_MALE_FACES},         // PFW_WIDGET_MALE
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   616
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   157,   217,    32,    43, STR_7045_FEMALE,         STR_704A_SELECT_FEMALE_FACES},       // PFW_WIDGET_FEMALE
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   617
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     2,    93,   137,   148, STR_RANDOM,              STR_704B_GENERATE_RANDOM_NEW_FACE},  // PFW_WIDGET_RANDOM_NEW_FACE
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   618
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    95,   217,    16,    27, STR_FACE_SIMPLE,         STR_FACE_SIMPLE_TIP},                // PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   619
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     2,    93,   158,   169, STR_FACE_LOAD,           STR_FACE_LOAD_TIP},                  // PFW_WIDGET_LOAD
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   620
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     2,    93,   170,   181, STR_FACE_FACECODE,       STR_FACE_FACECODE_TIP},              // PFW_WIDGET_FACECODE
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   621
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     2,    93,   182,   193, STR_FACE_SAVE,           STR_FACE_SAVE_TIP},                  // PFW_WIDGET_SAVE
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   622
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    96,   156,    46,    57, STR_FACE_EUROPEAN,       STR_FACE_SELECT_EUROPEAN},           // PFW_WIDGET_ETHNICITY_EUR
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   623
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   157,   217,    46,    57, STR_FACE_AFRICAN,        STR_FACE_SELECT_AFRICAN},            // PFW_WIDGET_ETHNICITY_AFR
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   624
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   175,   217,    60,    71, STR_EMPTY,               STR_FACE_MOUSTACHE_EARRING_TIP},     // PFW_WIDGET_HAS_MOUSTACHE_EARRING
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   625
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   175,   217,    72,    83, STR_EMPTY,               STR_FACE_GLASSES_TIP},               // PFW_WIDGET_HAS_GLASSES
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   626
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   110,   121, SPR_ARROW_LEFT,          STR_FACE_EYECOLOUR_TIP},             // PFW_WIDGET_EYECOLOUR_L
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   627
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   110,   121, STR_EMPTY,               STR_FACE_EYECOLOUR_TIP},             // PFW_WIDGET_EYECOLOUR
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   628
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   110,   121, SPR_ARROW_RIGHT,         STR_FACE_EYECOLOUR_TIP},             // PFW_WIDGET_EYECOLOUR_R
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   629
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   158,   169, SPR_ARROW_LEFT,          STR_FACE_CHIN_TIP},                  // PFW_WIDGET_CHIN_L
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   630
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   158,   169, STR_EMPTY,               STR_FACE_CHIN_TIP},                  // PFW_WIDGET_CHIN
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   631
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   158,   169, SPR_ARROW_RIGHT,         STR_FACE_CHIN_TIP},                  // PFW_WIDGET_CHIN_R
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   632
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,    98,   109, SPR_ARROW_LEFT,          STR_FACE_EYEBROWS_TIP},              // PFW_WIDGET_EYEBROWS_L
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   633
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,    98,   109, STR_EMPTY,               STR_FACE_EYEBROWS_TIP},              // PFW_WIDGET_EYEBROWS
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   634
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,    98,   109, SPR_ARROW_RIGHT,         STR_FACE_EYEBROWS_TIP},              // PFW_WIDGET_EYEBROWS_R
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   635
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   146,   157, SPR_ARROW_LEFT,          STR_FACE_LIPS_MOUSTACHE_TIP},        // PFW_WIDGET_LIPS_MOUSTACHE_L
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   636
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   146,   157, STR_EMPTY,               STR_FACE_LIPS_MOUSTACHE_TIP},        // PFW_WIDGET_LIPS_MOUSTACHE
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   637
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   146,   157, SPR_ARROW_RIGHT,         STR_FACE_LIPS_MOUSTACHE_TIP},        // PFW_WIDGET_LIPS_MOUSTACHE_R
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   638
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   134,   145, SPR_ARROW_LEFT,          STR_FACE_NOSE_TIP},                  // PFW_WIDGET_NOSE_L
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   639
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   134,   145, STR_EMPTY,               STR_FACE_NOSE_TIP},                  // PFW_WIDGET_NOSE
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   640
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   134,   145, SPR_ARROW_RIGHT,         STR_FACE_NOSE_TIP},                  // PFW_WIDGET_NOSE_R
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   641
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,    86,    97, SPR_ARROW_LEFT,          STR_FACE_HAIR_TIP},                  // PFW_WIDGET_HAIR_L
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   642
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,    86,    97, STR_EMPTY,               STR_FACE_HAIR_TIP},                  // PFW_WIDGET_HAIR
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   643
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,    86,    97, SPR_ARROW_RIGHT,         STR_FACE_HAIR_TIP},                  // PFW_WIDGET_HAIR_R
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   644
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   170,   181, SPR_ARROW_LEFT,          STR_FACE_JACKET_TIP},                // PFW_WIDGET_JACKET_L
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   645
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   170,   181, STR_EMPTY,               STR_FACE_JACKET_TIP},                // PFW_WIDGET_JACKET
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   646
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   170,   181, SPR_ARROW_RIGHT,         STR_FACE_JACKET_TIP},                // PFW_WIDGET_JACKET_R
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   647
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   182,   193, SPR_ARROW_LEFT,          STR_FACE_COLLAR_TIP},                // PFW_WIDGET_COLLAR_L
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   648
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   182,   193, STR_EMPTY,               STR_FACE_COLLAR_TIP},                // PFW_WIDGET_COLLAR
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   649
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   182,   193, SPR_ARROW_RIGHT,         STR_FACE_COLLAR_TIP},                // PFW_WIDGET_COLLAR_R
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   650
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   194,   205, SPR_ARROW_LEFT,          STR_FACE_TIE_EARRING_TIP},           // PFW_WIDGET_TIE_EARRING_L
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   651
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   194,   205, STR_EMPTY,               STR_FACE_TIE_EARRING_TIP},           // PFW_WIDGET_TIE_EARRING
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   652
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   194,   205, SPR_ARROW_RIGHT,         STR_FACE_TIE_EARRING_TIP},           // PFW_WIDGET_TIE_EARRING_R
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   653
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    175,  183,   122,   133, SPR_ARROW_LEFT,          STR_FACE_GLASSES_TIP_2},             // PFW_WIDGET_GLASSES_L
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   654
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    184,  208,   122,   133, STR_EMPTY,               STR_FACE_GLASSES_TIP_2},             // PFW_WIDGET_GLASSES
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   655
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    209,  217,   122,   133, SPR_ARROW_RIGHT,         STR_FACE_GLASSES_TIP_2},             // PFW_WIDGET_GLASSES_R
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   656
{   WIDGETS_END},
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   657
};
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   658
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   659
class SelectPlayerFaceWindow : public Window
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   660
{
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   661
	PlayerFace face; // player face bits
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   662
	bool advanced;   // advance player face selection window
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   663
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   664
	GenderEthnicity ge;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   665
	bool is_female;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   666
	bool is_moust_male;
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   667
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   668
	/**
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   669
	 * Names of the widgets. Keep them in the same order as in the widget array.
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   670
	 * Do not change the order of the widgets from PFW_WIDGET_HAS_MOUSTACHE_EARRING to PFW_WIDGET_GLASSES_R,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   671
	 * this order is needed for the WE_CLICK event of DrawFaceStringLabel().
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   672
	 */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   673
	enum PlayerFaceWindowWidgets {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   674
		PFW_WIDGET_CLOSEBOX = 0,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   675
		PFW_WIDGET_CAPTION,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   676
		PFW_WIDGET_TOGGLE_LARGE_SMALL,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   677
		PFW_WIDGET_SELECT_FACE,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   678
		PFW_WIDGET_CANCEL,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   679
		PFW_WIDGET_ACCEPT,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   680
		PFW_WIDGET_MALE,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   681
		PFW_WIDGET_FEMALE,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   682
		PFW_WIDGET_RANDOM_NEW_FACE,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   683
		PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   684
		/* from here is the advanced player face selection window */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   685
		PFW_WIDGET_LOAD,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   686
		PFW_WIDGET_FACECODE,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   687
		PFW_WIDGET_SAVE,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   688
		PFW_WIDGET_ETHNICITY_EUR,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   689
		PFW_WIDGET_ETHNICITY_AFR,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   690
		PFW_WIDGET_HAS_MOUSTACHE_EARRING,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   691
		PFW_WIDGET_HAS_GLASSES,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   692
		PFW_WIDGET_EYECOLOUR_L,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   693
		PFW_WIDGET_EYECOLOUR,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   694
		PFW_WIDGET_EYECOLOUR_R,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   695
		PFW_WIDGET_CHIN_L,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   696
		PFW_WIDGET_CHIN,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   697
		PFW_WIDGET_CHIN_R,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   698
		PFW_WIDGET_EYEBROWS_L,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   699
		PFW_WIDGET_EYEBROWS,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   700
		PFW_WIDGET_EYEBROWS_R,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   701
		PFW_WIDGET_LIPS_MOUSTACHE_L,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   702
		PFW_WIDGET_LIPS_MOUSTACHE,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   703
		PFW_WIDGET_LIPS_MOUSTACHE_R,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   704
		PFW_WIDGET_NOSE_L,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   705
		PFW_WIDGET_NOSE,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   706
		PFW_WIDGET_NOSE_R,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   707
		PFW_WIDGET_HAIR_L,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   708
		PFW_WIDGET_HAIR,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   709
		PFW_WIDGET_HAIR_R,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   710
		PFW_WIDGET_JACKET_L,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   711
		PFW_WIDGET_JACKET,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   712
		PFW_WIDGET_JACKET_R,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   713
		PFW_WIDGET_COLLAR_L,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   714
		PFW_WIDGET_COLLAR,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   715
		PFW_WIDGET_COLLAR_R,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   716
		PFW_WIDGET_TIE_EARRING_L,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   717
		PFW_WIDGET_TIE_EARRING,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   718
		PFW_WIDGET_TIE_EARRING_R,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   719
		PFW_WIDGET_GLASSES_L,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   720
		PFW_WIDGET_GLASSES,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   721
		PFW_WIDGET_GLASSES_R,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   722
	};
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   723
	/**
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   724
	 * Draw dynamic a label to the left of the button and a value in the button
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   725
	 *
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   726
	 * @param widget_index   index of this widget in the window
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   727
	 * @param str            the label which will be draw
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   728
	 * @param val            the value which will be draw
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   729
	 * @param is_bool_widget is it a bool button
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   730
	 */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   731
	void DrawFaceStringLabel(byte widget_index, StringID str, uint8 val, bool is_bool_widget)
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   732
	{
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   733
		/* Write the label in gold (0x2) to the left of the button. */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   734
		DrawStringRightAligned(this->widget[widget_index].left - (is_bool_widget ? 5 : 14), this->widget[widget_index].top + 1, str, TC_GOLD);
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   735
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   736
		if (!this->IsWidgetDisabled(widget_index)) {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   737
			if (is_bool_widget) {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   738
				/* if it a bool button write yes or no */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   739
				str = (val != 0) ? STR_FACE_YES : STR_FACE_NO;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   740
			} else {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   741
				/* else write the value + 1 */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   742
				SetDParam(0, val + 1);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   743
				str = STR_JUST_INT;
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   744
			}
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   745
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   746
			/* Draw the value/bool in white (0xC). If the button clicked adds 1px to x and y text coordinates (IsWindowWidgetLowered()). */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   747
			DrawStringCentered(this->widget[widget_index].left + (this->widget[widget_index].right - this->widget[widget_index].left) / 2 +
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   748
				this->IsWidgetLowered(widget_index), this->widget[widget_index].top + 1 + this->IsWidgetLowered(widget_index), str, TC_WHITE);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   749
		}
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   750
	}
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   751
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   752
	void UpdateData()
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   753
	{
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   754
		this->ge = (GenderEthnicity)GB(this->face, _pf_info[PFV_GEN_ETHN].offset, _pf_info[PFV_GEN_ETHN].length); // get the gender and ethnicity
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   755
		this->is_female = HasBit(this->ge, GENDER_FEMALE); // get the gender: 0 == male and 1 == female
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   756
		this->is_moust_male = !is_female && GetPlayerFaceBits(this->face, PFV_HAS_MOUSTACHE, this->ge) != 0; // is a male face with moustache
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   757
	}
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   758
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   759
public:
10680
66a611e5bc07 (svn r13224) -Fix (r13107): set the location of the old SelectPlayerFaceWindow when switching from simple to advanced or vice versa instead of letting the new window popup somewhere 'randomly'.
rubidium
parents: 10641
diff changeset
   760
	SelectPlayerFaceWindow(const WindowDesc *desc, Window *parent, bool advanced, int top, int left) : Window(desc, parent->window_number)
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   761
	{
10563
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
   762
		this->parent = parent;
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   763
		this->caption_color = this->window_number;
10563
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
   764
		this->face = GetPlayer((PlayerID)this->window_number)->face;
10525
da5bc725cda4 (svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
rubidium
parents: 10520
diff changeset
   765
		this->advanced = advanced;
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   766
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   767
		this->UpdateData();
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   768
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   769
		/* Check if repositioning from default is required */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   770
		if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   771
			this->top = top;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   772
			this->left = left;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   773
		}
10681
3aa3de4d448b (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 10680
diff changeset
   774
3aa3de4d448b (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 10680
diff changeset
   775
		this->FindWindowPlacementAndResize(desc);
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   776
	}
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   777
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   778
	virtual void OnPaint()
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   779
	{
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   780
		/* lower the non-selected gender button */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   781
		this->SetWidgetLoweredState(PFW_WIDGET_MALE,  !this->is_female);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   782
		this->SetWidgetLoweredState(PFW_WIDGET_FEMALE, this->is_female);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   783
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   784
		/* advanced player face selection window */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   785
		if (this->advanced) {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   786
			/* lower the non-selected ethnicity button */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   787
			this->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_EUR, !HasBit(this->ge, ETHNICITY_BLACK));
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   788
			this->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_AFR,  HasBit(this->ge, ETHNICITY_BLACK));
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   789
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   790
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   791
			/* Disable dynamically the widgets which PlayerFaceVariable has less than 2 options
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   792
			* (or in other words you haven't any choice).
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   793
			* If the widgets depend on a HAS-variable and this is false the widgets will be disabled, too. */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   794
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   795
			/* Eye colour buttons */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   796
			this->SetWidgetsDisabledState(_pf_info[PFV_EYE_COLOUR].valid_values[this->ge] < 2,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   797
				PFW_WIDGET_EYECOLOUR, PFW_WIDGET_EYECOLOUR_L, PFW_WIDGET_EYECOLOUR_R, WIDGET_LIST_END);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   798
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   799
			/* Chin buttons */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   800
			this->SetWidgetsDisabledState(_pf_info[PFV_CHIN].valid_values[this->ge] < 2,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   801
				PFW_WIDGET_CHIN, PFW_WIDGET_CHIN_L, PFW_WIDGET_CHIN_R, WIDGET_LIST_END);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   802
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   803
			/* Eyebrows buttons */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   804
			this->SetWidgetsDisabledState(_pf_info[PFV_EYEBROWS].valid_values[this->ge] < 2,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   805
				PFW_WIDGET_EYEBROWS, PFW_WIDGET_EYEBROWS_L, PFW_WIDGET_EYEBROWS_R, WIDGET_LIST_END);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   806
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   807
			/* Lips or (if it a male face with a moustache) moustache buttons */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   808
			this->SetWidgetsDisabledState(_pf_info[this->is_moust_male ? PFV_MOUSTACHE : PFV_LIPS].valid_values[this->ge] < 2,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   809
				PFW_WIDGET_LIPS_MOUSTACHE, PFW_WIDGET_LIPS_MOUSTACHE_L, PFW_WIDGET_LIPS_MOUSTACHE_R, WIDGET_LIST_END);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   810
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   811
			/* Nose buttons | male faces with moustache haven't any nose options */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   812
			this->SetWidgetsDisabledState(_pf_info[PFV_NOSE].valid_values[this->ge] < 2 || this->is_moust_male,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   813
				PFW_WIDGET_NOSE, PFW_WIDGET_NOSE_L, PFW_WIDGET_NOSE_R, WIDGET_LIST_END);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   814
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   815
			/* Hair buttons */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   816
			this->SetWidgetsDisabledState(_pf_info[PFV_HAIR].valid_values[this->ge] < 2,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   817
				PFW_WIDGET_HAIR, PFW_WIDGET_HAIR_L, PFW_WIDGET_HAIR_R, WIDGET_LIST_END);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   818
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   819
			/* Jacket buttons */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   820
			this->SetWidgetsDisabledState(_pf_info[PFV_JACKET].valid_values[this->ge] < 2,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   821
				PFW_WIDGET_JACKET, PFW_WIDGET_JACKET_L, PFW_WIDGET_JACKET_R, WIDGET_LIST_END);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   822
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   823
			/* Collar buttons */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   824
			this->SetWidgetsDisabledState(_pf_info[PFV_COLLAR].valid_values[this->ge] < 2,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   825
				PFW_WIDGET_COLLAR, PFW_WIDGET_COLLAR_L, PFW_WIDGET_COLLAR_R, WIDGET_LIST_END);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   826
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   827
			/* Tie/earring buttons | female faces without earring haven't any earring options */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   828
			this->SetWidgetsDisabledState(_pf_info[PFV_TIE_EARRING].valid_values[this->ge] < 2 ||
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   829
					(this->is_female && GetPlayerFaceBits(this->face, PFV_HAS_TIE_EARRING, this->ge) == 0),
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   830
				PFW_WIDGET_TIE_EARRING, PFW_WIDGET_TIE_EARRING_L, PFW_WIDGET_TIE_EARRING_R, WIDGET_LIST_END);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   831
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   832
			/* Glasses buttons | faces without glasses haven't any glasses options */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   833
			this->SetWidgetsDisabledState(_pf_info[PFV_GLASSES].valid_values[this->ge] < 2 || GetPlayerFaceBits(this->face, PFV_HAS_GLASSES, this->ge) == 0,
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   834
				PFW_WIDGET_GLASSES, PFW_WIDGET_GLASSES_L, PFW_WIDGET_GLASSES_R, WIDGET_LIST_END);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   835
		}
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   836
10595
7957c71b0dfe (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 10574
diff changeset
   837
		this->DrawWidgets();
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   838
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   839
		/* Draw dynamic button value and labels for the advanced player face selection window */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   840
		if (this->advanced) {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   841
			if (this->is_female) {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   842
				/* Only for female faces */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   843
				this->DrawFaceStringLabel(PFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_EARRING,   GetPlayerFaceBits(this->face, PFV_HAS_TIE_EARRING, this->ge), true );
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   844
				this->DrawFaceStringLabel(PFW_WIDGET_TIE_EARRING,           STR_FACE_EARRING,   GetPlayerFaceBits(this->face, PFV_TIE_EARRING,     this->ge), false);
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   845
			} else {
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   846
				/* Only for male faces */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   847
				this->DrawFaceStringLabel(PFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_MOUSTACHE, GetPlayerFaceBits(this->face, PFV_HAS_MOUSTACHE,   this->ge), true );
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   848
				this->DrawFaceStringLabel(PFW_WIDGET_TIE_EARRING,           STR_FACE_TIE,       GetPlayerFaceBits(this->face, PFV_TIE_EARRING,     this->ge), false);
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   849
			}
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   850
			if (this->is_moust_male) {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   851
				/* Only for male faces with moustache */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   852
				this->DrawFaceStringLabel(PFW_WIDGET_LIPS_MOUSTACHE,        STR_FACE_MOUSTACHE, GetPlayerFaceBits(this->face, PFV_MOUSTACHE,       this->ge), false);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   853
			} else {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   854
				/* Only for female faces or male faces without moustache */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   855
				this->DrawFaceStringLabel(PFW_WIDGET_LIPS_MOUSTACHE,        STR_FACE_LIPS,      GetPlayerFaceBits(this->face, PFV_LIPS,            this->ge), false);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   856
			}
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   857
			/* For all faces */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   858
			this->DrawFaceStringLabel(PFW_WIDGET_HAS_GLASSES,           STR_FACE_GLASSES,     GetPlayerFaceBits(this->face, PFV_HAS_GLASSES,     this->ge), true );
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   859
			this->DrawFaceStringLabel(PFW_WIDGET_HAIR,                  STR_FACE_HAIR,        GetPlayerFaceBits(this->face, PFV_HAIR,            this->ge), false);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   860
			this->DrawFaceStringLabel(PFW_WIDGET_EYEBROWS,              STR_FACE_EYEBROWS,    GetPlayerFaceBits(this->face, PFV_EYEBROWS,        this->ge), false);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   861
			this->DrawFaceStringLabel(PFW_WIDGET_EYECOLOUR,             STR_FACE_EYECOLOUR,   GetPlayerFaceBits(this->face, PFV_EYE_COLOUR,      this->ge), false);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   862
			this->DrawFaceStringLabel(PFW_WIDGET_GLASSES,               STR_FACE_GLASSES,     GetPlayerFaceBits(this->face, PFV_GLASSES,         this->ge), false);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   863
			this->DrawFaceStringLabel(PFW_WIDGET_NOSE,                  STR_FACE_NOSE,        GetPlayerFaceBits(this->face, PFV_NOSE,            this->ge), false);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   864
			this->DrawFaceStringLabel(PFW_WIDGET_CHIN,                  STR_FACE_CHIN,        GetPlayerFaceBits(this->face, PFV_CHIN,            this->ge), false);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   865
			this->DrawFaceStringLabel(PFW_WIDGET_JACKET,                STR_FACE_JACKET,      GetPlayerFaceBits(this->face, PFV_JACKET,          this->ge), false);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   866
			this->DrawFaceStringLabel(PFW_WIDGET_COLLAR,                STR_FACE_COLLAR,      GetPlayerFaceBits(this->face, PFV_COLLAR,          this->ge), false);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   867
		}
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   868
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   869
		/* Draw the player face picture */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   870
		DrawPlayerFace(this->face, GetPlayer((PlayerID)this->window_number)->player_color, 2, 16);
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
   871
	}
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   872
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   873
	virtual void OnClick(Point pt, int widget)
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   874
	{
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   875
		switch (widget) {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   876
			/* Toggle size, advanced/simple face selection */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   877
			case PFW_WIDGET_TOGGLE_LARGE_SMALL:
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   878
			case PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON: {
10563
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
   879
				DoCommandP(0, 0, this->face, NULL, CMD_SET_PLAYER_FACE);
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
   880
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
   881
				/* Backup some data before deletion */
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   882
				int oldtop = this->top;     ///< current top position of the window before closing it
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   883
				int oldleft = this->left;   ///< current top position of the window before closing it
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   884
				bool adv = !this->advanced;
10563
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
   885
				Window *parent = this->parent;
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   886
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   887
				delete this;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   888
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   889
				/* Open up the (toggled size) Face selection window at the same position as the previous */
10563
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
   890
				DoSelectPlayerFace(parent, adv, oldtop, oldleft);
10520
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   891
			} break;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   892
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   893
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   894
			/* OK button */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   895
			case PFW_WIDGET_ACCEPT:
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   896
				DoCommandP(0, 0, this->face, NULL, CMD_SET_PLAYER_FACE);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   897
				/* Fall-Through */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   898
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   899
			/* Cancel button */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   900
			case PFW_WIDGET_CANCEL:
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   901
				delete this;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   902
				break;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   903
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   904
			/* Load button */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   905
			case PFW_WIDGET_LOAD:
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   906
				this->face = _player_face;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   907
				ScaleAllPlayerFaceBits(this->face);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   908
				ShowErrorMessage(INVALID_STRING_ID, STR_FACE_LOAD_DONE, 0, 0);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   909
				this->UpdateData();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   910
				this->SetDirty();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   911
				break;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   912
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   913
			/* 'Player face number' button, view and/or set player face number */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   914
			case PFW_WIDGET_FACECODE:
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   915
				SetDParam(0, this->face);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   916
				ShowQueryString(STR_JUST_INT, STR_FACE_FACECODE_CAPTION, 10 + 1, 0, this, CS_NUMERAL);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   917
				break;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   918
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   919
			/* Save button */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   920
			case PFW_WIDGET_SAVE:
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   921
				_player_face = this->face;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   922
				ShowErrorMessage(INVALID_STRING_ID, STR_FACE_SAVE_DONE, 0, 0);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   923
				break;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   924
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   925
			/* Toggle gender (male/female) button */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   926
			case PFW_WIDGET_MALE:
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   927
			case PFW_WIDGET_FEMALE:
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   928
				SetPlayerFaceBits(this->face, PFV_GENDER, this->ge, widget - PFW_WIDGET_MALE);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   929
				ScaleAllPlayerFaceBits(this->face);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   930
				this->UpdateData();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   931
				this->SetDirty();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   932
				break;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   933
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   934
			/* Randomize face button */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   935
			case PFW_WIDGET_RANDOM_NEW_FACE:
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   936
				RandomPlayerFaceBits(this->face, this->ge, this->advanced);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   937
				this->UpdateData();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   938
				this->SetDirty();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   939
				break;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   940
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   941
			/* Toggle ethnicity (european/african) button */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   942
			case PFW_WIDGET_ETHNICITY_EUR:
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   943
			case PFW_WIDGET_ETHNICITY_AFR:
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   944
				SetPlayerFaceBits(this->face, PFV_ETHNICITY, this->ge, widget - PFW_WIDGET_ETHNICITY_EUR);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   945
				ScaleAllPlayerFaceBits(this->face);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   946
				this->UpdateData();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   947
				this->SetDirty();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   948
				break;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   949
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   950
			default:
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   951
				/* For all buttons from PFW_WIDGET_HAS_MOUSTACHE_EARRING to PFW_WIDGET_GLASSES_R is the same function.
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   952
				* Therefor is this combined function.
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   953
				* First it checks which PlayerFaceVariable will be change and then
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   954
				* a: invert the value for boolean variables
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   955
				* or b: it checks inside of IncreasePlayerFaceBits() if a left (_L) butten is pressed and then decrease else increase the variable */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   956
				if (this->advanced && widget >= PFW_WIDGET_HAS_MOUSTACHE_EARRING && widget <= PFW_WIDGET_GLASSES_R) {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   957
					PlayerFaceVariable pfv; // which PlayerFaceVariable shall be edited
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   958
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   959
					if (widget < PFW_WIDGET_EYECOLOUR_L) { // Bool buttons
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   960
						switch (widget - PFW_WIDGET_HAS_MOUSTACHE_EARRING) {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   961
							default: NOT_REACHED();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   962
							case 0: pfv = this->is_female ? PFV_HAS_TIE_EARRING : PFV_HAS_MOUSTACHE; break; // Has earring/moustache button
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   963
							case 1: pfv = PFV_HAS_GLASSES; break; // Has glasses button
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   964
						}
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   965
						SetPlayerFaceBits(this->face, pfv, this->ge, !GetPlayerFaceBits(this->face, pfv, this->ge));
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   966
						ScaleAllPlayerFaceBits(this->face);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   967
					} else { // Value buttons
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   968
						switch ((widget - PFW_WIDGET_EYECOLOUR_L) / 3) {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   969
							default: NOT_REACHED();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   970
							case 0: pfv = PFV_EYE_COLOUR; break;  // Eye colour buttons
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   971
							case 1: pfv = PFV_CHIN; break;        // Chin buttons
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   972
							case 2: pfv = PFV_EYEBROWS; break;    // Eyebrows buttons
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   973
							case 3: pfv = this->is_moust_male ? PFV_MOUSTACHE : PFV_LIPS; break; // Moustache or lips buttons
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   974
							case 4: pfv = PFV_NOSE; break;        // Nose buttons
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   975
							case 5: pfv = PFV_HAIR; break;        // Hair buttons
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   976
							case 6: pfv = PFV_JACKET; break;      // Jacket buttons
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   977
							case 7: pfv = PFV_COLLAR; break;      // Collar buttons
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   978
							case 8: pfv = PFV_TIE_EARRING; break; // Tie/earring buttons
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   979
							case 9: pfv = PFV_GLASSES; break;     // Glasses buttons
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   980
						}
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   981
						/* 0 == left (_L), 1 == middle or 2 == right (_R) - button click */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   982
						IncreasePlayerFaceBits(this->face, pfv, this->ge, (((widget - PFW_WIDGET_EYECOLOUR_L) % 3) != 0) ? 1 : -1);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   983
					}
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   984
					this->UpdateData();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   985
					this->SetDirty();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   986
				}
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   987
				break;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   988
		}
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   989
	}
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   990
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   991
	virtual void OnQueryTextFinished(char *str)
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   992
	{
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   993
		if (str == NULL) return;
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   994
		/* Set a new player face number */
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   995
		if (!StrEmpty(str)) {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   996
			this->face = strtoul(str, NULL, 10);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   997
			ScaleAllPlayerFaceBits(this->face);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   998
			ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_SET, 0, 0);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
   999
			this->UpdateData();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
  1000
			this->SetDirty();
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
  1001
		} else {
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
  1002
			ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_ERR, 0, 0);
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
  1003
		}
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
  1004
	}
6b463aae1d92 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 10484
diff changeset
  1005
};
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1006
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1007
/** normal/simple player face selection window description */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1008
static const WindowDesc _select_player_face_desc = {
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1009
	WDP_AUTO, WDP_AUTO, 190, 163, 190, 163,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
  1010
	WC_PLAYER_FACE, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1011
	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
  1012
	_select_player_face_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1013
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1014
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1015
/** advanced player face selection window description */
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1016
static const WindowDesc _select_player_face_adv_desc = {
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1017
	WDP_AUTO, WDP_AUTO, 220, 220, 220, 220,
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1018
	WC_PLAYER_FACE, WC_NONE,
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1019
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1020
	_select_player_face_adv_widgets,
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1021
};
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1022
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1023
/**
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1024
 * Open the simple/advanced player face selection window
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1025
 *
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1026
 * @param player the player which face shall be edited
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1027
 * @param adv    simple or advanced player face selection window
10103
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
  1028
 * @param top    previous top position of the window
6dee731b0b1d (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 9011
diff changeset
  1029
 * @param left   previous left position of the window
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1030
 *
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1031
 * @pre is player a valid player
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1032
 */
10563
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
  1033
static void DoSelectPlayerFace(Window *parent, bool adv, int top, int left)
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1034
{
10563
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
  1035
	if (!IsValidPlayer((PlayerID)parent->window_number)) return;
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1036
10563
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
  1037
	if (BringWindowToFrontById(WC_PLAYER_FACE, parent->window_number)) return;
10680
66a611e5bc07 (svn r13224) -Fix (r13107): set the location of the old SelectPlayerFaceWindow when switching from simple to advanced or vice versa instead of letting the new window popup somewhere 'randomly'.
rubidium
parents: 10641
diff changeset
  1038
	new SelectPlayerFaceWindow(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, parent, adv, top, left); // simple or advanced window
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1039
}
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1040
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1041
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1042
/* Names of the widgets. Keep them in the same order as in the widget array */
5273
5fde4b8c94c4 (svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents: 5070
diff changeset
  1043
enum PlayerCompanyWindowWidgets {
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1044
	PCW_WIDGET_CLOSEBOX = 0,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1045
	PCW_WIDGET_CAPTION,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1046
	PCW_WIDGET_FACE,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1047
	PCW_WIDGET_NEW_FACE,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1048
	PCW_WIDGET_COLOR_SCHEME,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1049
	PCW_WIDGET_PRESIDENT_NAME,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1050
	PCW_WIDGET_COMPANY_NAME,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1051
	PCW_WIDGET_BUILD_VIEW_HQ,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1052
	PCW_WIDGET_RELOCATE_HQ,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1053
	PCW_WIDGET_BUY_SHARE,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1054
	PCW_WIDGET_SELL_SHARE,
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1055
	PCW_WIDGET_COMPANY_PASSWORD,
5273
5fde4b8c94c4 (svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents: 5070
diff changeset
  1056
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1057
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1058
static const Widget _player_company_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
  1059
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
  1060
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   359,     0,    13, STR_7001,                          STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
  1061
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   359,    14,   157, 0x0,                               STR_NULL},
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1062
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    89,   158,   169, STR_7004_NEW_FACE,                 STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT},
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1063
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    90,   179,   158,   169, STR_7005_COLOR_SCHEME,             STR_7031_CHANGE_THE_COMPANY_VEHICLE},
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1064
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   180,   269,   158,   169, STR_7009_PRESIDENT_NAME,           STR_7032_CHANGE_THE_PRESIDENT_S},
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1065
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   270,   359,   158,   169, STR_7008_COMPANY_NAME,             STR_7033_CHANGE_THE_COMPANY_NAME},
4808
9043553faa1c (svn r6730) Fix: Make Build HQ and Relocate HQ buttons of Player window behave as normal placement buttons, and not as push buttons.
belugas
parents: 4805
diff changeset
  1066
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   266,   355,    18,    29, STR_7072_VIEW_HQ,                  STR_7070_BUILD_COMPANY_HEADQUARTERS},
9043553faa1c (svn r6730) Fix: Make Build HQ and Relocate HQ buttons of Player window behave as normal placement buttons, and not as push buttons.
belugas
parents: 4805
diff changeset
  1067
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   266,   355,    32,    43, STR_RELOCATE_HQ,                   STR_RELOCATE_COMPANY_HEADQUARTERS},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
  1068
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   179,   158,   169, STR_7077_BUY_25_SHARE_IN_COMPANY,  STR_7079_BUY_25_SHARE_IN_THIS_COMPANY},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4329
diff changeset
  1069
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   180,   359,   158,   169, STR_7078_SELL_25_SHARE_IN_COMPANY, STR_707A_SELL_25_SHARE_IN_THIS_COMPANY},
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1070
{ 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
  1071
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1072
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1073
8430
9f32cec597ed (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 8428
diff changeset
  1074
9f32cec597ed (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 8428
diff changeset
  1075
/**
9f32cec597ed (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 8428
diff changeset
  1076
 * Draws text "Vehicles:" and number of all vehicle types, or "(none)"
9f32cec597ed (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 8428
diff changeset
  1077
 * @param player ID of player to print statistics of
9f32cec597ed (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 8428
diff changeset
  1078
 */
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
  1079
static void DrawPlayerVehiclesAmount(PlayerID player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1080
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1081
	const int x = 110;
8430
9f32cec597ed (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 8428
diff changeset
  1082
	int y = 63;
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1083
	const Vehicle *v;
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1084
	uint train = 0;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1085
	uint road  = 0;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1086
	uint air   = 0;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1087
	uint ship  = 0;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
  1088
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
  1089
	DrawString(x, y, STR_7039_VEHICLES, TC_FROMSTRING);
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
	FOR_ALL_VEHICLES(v) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1092
		if (v->owner == player) {
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1093
			switch (v->type) {
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
  1094
				case VEH_TRAIN:    if (IsFrontEngine(v)) train++; break;
7353
716c6dd9322a (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 7265
diff changeset
  1095
				case VEH_ROAD:     if (IsRoadVehFront(v)) road++; break;
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
  1096
				case VEH_AIRCRAFT: if (IsNormalAircraft(v)) air++; break;
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
  1097
				case VEH_SHIP:     ship++; break;
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1098
				default: break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1099
			}
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
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1102
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6678
diff changeset
  1103
	if (train + road + air + ship == 0) {
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
  1104
		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
  1105
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1106
		if (train != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1107
			SetDParam(0, train);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
  1108
			DrawString(x + 70, y, STR_TRAINS, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1109
			y += 10;
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
		if (road != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1113
			SetDParam(0, road);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
  1114
			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
  1115
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1116
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1117
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1118
		if (air != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1119
			SetDParam(0, air);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
  1120
			DrawString(x + 70, y, STR_AIRCRAFT, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1121
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1122
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1123
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1124
		if (ship != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1125
			SetDParam(0, ship);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8230
diff changeset
  1126
			DrawString(x + 70, y, STR_SHIPS, TC_FROMSTRING);
0
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
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1129
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1130
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
  1131
int GetAmountOwnedBy(const Player *p, PlayerID owner)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1132
{
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
  1133
	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
  1134
				 (p->share_owners[1] == owner) +
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
  1135
				 (p->share_owners[2] == owner) +
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1136
				 (p->share_owners[3] == owner);
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
8430
9f32cec597ed (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 8428
diff changeset
  1139
/**
9f32cec597ed (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 8428
diff changeset
  1140
 * Draws list of all companies with shares
9f32cec597ed (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 8428
diff changeset
  1141
 * @param p pointer to the Player structure
9f32cec597ed (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 8428
diff changeset
  1142
 */
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2246
diff changeset
  1143
static void DrawCompanyOwnerText(const Player *p)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1144
{
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1145
	const Player *p2;
8380
3cfc70720667 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 8320
diff changeset
  1146
	uint num = 0;
3cfc70720667 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 8320
diff changeset
  1147
	const byte height = GetCharacterHeight(FS_NORMAL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1148
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1149
	FOR_ALL_PLAYERS(p2) {
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
  1150
		uint amt = GetAmountOwnedBy(p, p2->index);
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
  1151
		if (amt != 0) {
8380
3cfc70720667 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 8320
diff changeset
  1152
			SetDParam(0, amt * 25);
3cfc70720667 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 8320
diff changeset
  1153
			SetDParam(1, p2->index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1154
8380
3cfc70720667 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 8320
diff changeset
  1155
			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
  1156
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1157
	}
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
8230
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1160
/**
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1161
 * Player company window event definition
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1162
 *
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1163
 * @param w window pointer
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1164
 * @param e event been triggered
7b40f75cba12 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 8017
diff changeset
  1165
 */
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1166
struct PlayerCompanyWindow : Window
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1167
{
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1168
	PlayerCompanyWindowWidgets query_widget;
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1169
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1170
	PlayerCompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1171
	{
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1172
		this->caption_color = this->window_number;
10681
3aa3de4d448b (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 10680
diff changeset
  1173
		this->FindWindowPlacementAndResize(desc);
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1174
	}
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1175
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1176
	virtual void OnPaint()
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1177
	{
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1178
		const Player *p = GetPlayer((PlayerID)this->window_number);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1179
		bool local = this->window_number == _local_player;
8430
9f32cec597ed (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 8428
diff changeset
  1180
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1181
		this->SetWidgetHiddenState(PCW_WIDGET_NEW_FACE,       !local);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1182
		this->SetWidgetHiddenState(PCW_WIDGET_COLOR_SCHEME,   !local);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1183
		this->SetWidgetHiddenState(PCW_WIDGET_PRESIDENT_NAME, !local);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1184
		this->SetWidgetHiddenState(PCW_WIDGET_COMPANY_NAME,   !local);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1185
		this->widget[PCW_WIDGET_BUILD_VIEW_HQ].data = (local && p->location_of_house == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1186
		if (local && p->location_of_house != 0) this->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1187
		this->SetWidgetDisabledState(PCW_WIDGET_BUILD_VIEW_HQ, !local && p->location_of_house == 0);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1188
		this->SetWidgetHiddenState(PCW_WIDGET_RELOCATE_HQ,      !local || p->location_of_house == 0);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1189
		this->SetWidgetHiddenState(PCW_WIDGET_BUY_SHARE,        local);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1190
		this->SetWidgetHiddenState(PCW_WIDGET_SELL_SHARE,       local);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1191
		this->SetWidgetHiddenState(PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1192
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1193
		if (!local) {
10703
2c998f3776d1 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 10681
diff changeset
  1194
			if (_settings.economy.allow_shares) { // Shares are allowed
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1195
				/* If all shares are owned by someone (none by nobody), disable buy button */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1196
				this->SetWidgetDisabledState(PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 ||
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1197
						/* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1198
						(GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) ||
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1199
						/* Spectators cannot do anything of course */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1200
						_local_player == PLAYER_SPECTATOR);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1201
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1202
				/* If the player doesn't own any shares, disable sell button */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1203
				this->SetWidgetDisabledState(PCW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(p, _local_player) == 0) ||
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1204
						/* Spectators cannot do anything of course */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1205
						_local_player == PLAYER_SPECTATOR);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1206
			} else { // Shares are not allowed, disable buy/sell buttons
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1207
				this->DisableWidget(PCW_WIDGET_BUY_SHARE);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1208
				this->DisableWidget(PCW_WIDGET_SELL_SHARE);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1209
			}
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
  1210
		}
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
  1211
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1212
		SetDParam(0, p->index);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1213
		SetDParam(1, p->index);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1214
10595
7957c71b0dfe (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 10574
diff changeset
  1215
		this->DrawWidgets();
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1216
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1217
		/* Player face */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1218
		DrawPlayerFace(p->face, p->player_color, 2, 16);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1219
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1220
		/* "xxx (Manager)" */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1221
		SetDParam(0, p->index);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1222
		DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1223
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1224
		/* "Inaugurated:" */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1225
		SetDParam(0, p->inaugurated_year);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1226
		DrawString(110, 23, STR_7038_INAUGURATED, TC_FROMSTRING);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1227
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1228
		/* "Colour scheme:" */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1229
		DrawString(110, 43, STR_7006_COLOR_SCHEME, TC_FROMSTRING);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1230
		/* Draw company-colour bus */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1231
		DrawSprite(SPR_VEH_BUS_SW_VIEW, PLAYER_SPRITE_COLOR(p->index), 215, 44);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1232
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1233
		/* "Vehicles:" */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1234
		DrawPlayerVehiclesAmount((PlayerID)this->window_number);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1235
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1236
		/* "Company value:" */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1237
		SetDParam(0, CalculateCompanyValue(p));
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1238
		DrawString(110, 106, STR_7076_COMPANY_VALUE, TC_FROMSTRING);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1239
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1240
		/* Shares list */
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1241
		DrawCompanyOwnerText(p);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1242
	}
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1243
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1244
	virtual void OnClick(Point pt, int widget)
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1245
	{
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1246
		switch (widget) {
10563
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
  1247
			case PCW_WIDGET_NEW_FACE: DoSelectPlayerFace(this, false); break;
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1248
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1249
			case PCW_WIDGET_COLOR_SCHEME:
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1250
				if (BringWindowToFrontById(WC_PLAYER_COLOR, this->window_number)) break;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1251
				new SelectPlayerLiveryWindow(&_select_player_livery_desc, (PlayerID)this->window_number);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1252
				break;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1253
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1254
			case PCW_WIDGET_PRESIDENT_NAME:
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1255
				this->query_widget = PCW_WIDGET_PRESIDENT_NAME;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1256
				SetDParam(0, this->window_number);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1257
				ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, 31, 94, this, CS_ALPHANUMERAL);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1258
				break;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1259
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1260
			case PCW_WIDGET_COMPANY_NAME:
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1261
				this->query_widget = PCW_WIDGET_COMPANY_NAME;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1262
				SetDParam(0, this->window_number);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1263
				ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, 31, 150, this, CS_ALPHANUMERAL);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1264
				break;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1265
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1266
			case PCW_WIDGET_BUILD_VIEW_HQ: {
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1267
				TileIndex tile = GetPlayer((PlayerID)this->window_number)->location_of_house;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1268
				if (tile == 0) {
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1269
					if ((byte)this->window_number != _local_player) return;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1270
					SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1271
					SetTileSelectSize(2, 2);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1272
					this->LowerWidget(PCW_WIDGET_BUILD_VIEW_HQ);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1273
					this->InvalidateWidget(PCW_WIDGET_BUILD_VIEW_HQ);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1274
				} else {
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1275
					if (_ctrl_pressed) {
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1276
						ShowExtraViewPortWindow(tile);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1277
					} else {
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1278
						ScrollMainWindowToTile(tile);
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1279
					}
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1280
				}
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1281
				break;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1282
			}
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1283
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1284
			case PCW_WIDGET_RELOCATE_HQ:
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1285
				SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1286
				SetTileSelectSize(2, 2);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1287
				this->LowerWidget(PCW_WIDGET_RELOCATE_HQ);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1288
				this->InvalidateWidget(PCW_WIDGET_RELOCATE_HQ);
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1289
				break;
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1290
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1291
			case PCW_WIDGET_BUY_SHARE:
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1292
				DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS));
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1293
				break;
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1294
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1295
			case PCW_WIDGET_SELL_SHARE:
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1296
				DoCommandP(0, this->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN));
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1297
				break;
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1298
8494
88f26cafc858 (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents: 8493
diff changeset
  1299
#ifdef ENABLE_NETWORK
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1300
			case PCW_WIDGET_COMPANY_PASSWORD:
10563
76819f7c2dc2 (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 10559
diff changeset
  1301
				if (this->window_number == _local_player) ShowNetworkCompanyPasswordWindow(this);
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1302
				break;
8494
88f26cafc858 (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents: 8493
diff changeset
  1303
#endif /* ENABLE_NETWORK */
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1304
		}
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1305
	}
4808
9043553faa1c (svn r6730) Fix: Make Build HQ and Relocate HQ buttons of Player window behave as normal placement buttons, and not as push buttons.
belugas
parents: 4805
diff changeset
  1306
10773
88125a991761 (svn r13323) -Codechange: scrollbars are not refresh counters
peter1138
parents: 10707
diff changeset
  1307
	virtual void OnHundredthTick()
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1308
	{
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1309
		/* redraw the window every now and then */
10773
88125a991761 (svn r13323) -Codechange: scrollbars are not refresh counters
peter1138
parents: 10707
diff changeset
  1310
		this->SetDirty();
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1311
	}
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1312
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1313
	virtual void OnPlaceObject(Point pt, TileIndex tile)
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1314
	{
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1315
		if (DoCommandP(tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1316
			ResetObjectToPlace();
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1317
			this->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1318
			this->RaiseButtons();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1319
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1320
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1321
	virtual void OnPlaceObjectAbort()
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1322
	{
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1323
		this->RaiseButtons();
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1324
	}
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1325
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1326
	virtual void OnQueryTextFinished(char *str)
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1327
	{
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1328
		if (StrEmpty(str)) return;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1329
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1330
		_cmd_text = str;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1331
		switch (this->query_widget) {
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1332
			default: NOT_REACHED();
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1333
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1334
			case PCW_WIDGET_PRESIDENT_NAME:
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1335
				DoCommandP(0, 0, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT));
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1336
				break;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1337
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1338
			case PCW_WIDGET_COMPANY_NAME:
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1339
				DoCommandP(0, 0, 0, NULL, CMD_CHANGE_COMPANY_NAME | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME));
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1340
				break;
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1341
		}
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1342
	}
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1343
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1344
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1345
static const WindowDesc _player_company_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
  1346
	WDP_AUTO, WDP_AUTO, 360, 170, 360, 170,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
  1347
	WC_COMPANY, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1348
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4746
693a7e43596d (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1349
	_player_company_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1350
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1351
2475
8443e1eefe1b (svn r3001) s/Player*/const Player*/
tron
parents: 2473
diff changeset
  1352
void ShowPlayerCompany(PlayerID player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1353
{
5005
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
  1354
	if (!IsValidPlayer(player)) return;
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
  1355
10559
0e5480e9af1e (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 10552
diff changeset
  1356
	AllocateWindowDescFront<PlayerCompanyWindow>(&_player_company_desc, player);
0
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1359
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1360
10626
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1361
struct BuyCompanyWindow : Window {
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1362
	BuyCompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1363
	{
10681
3aa3de4d448b (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 10680
diff changeset
  1364
		this->FindWindowPlacementAndResize(desc);
10626
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1365
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1366
10626
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1367
	virtual void OnPaint()
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1368
	{
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1369
		Player *p = GetPlayer((PlayerID)this->window_number);
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1370
		SetDParam(0, STR_COMPANY_NAME);
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1371
		SetDParam(1, p->index);
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1372
		this->DrawWidgets();
10104
29e5b919d4a1 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 10103
diff changeset
  1373
10626
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1374
		DrawPlayerFace(p->face, p->player_color, 2, 16);
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1375
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1376
		SetDParam(0, p->index);
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1377
		SetDParam(1, p->bankrupt_value);
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1378
		DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1379
	}
10626
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1380
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1381
	virtual void OnClick(Point pt, int widget)
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1382
	{
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1383
		switch (widget) {
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1384
			case 3:
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1385
				delete this;
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1386
				break;
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1387
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1388
			case 4:
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1389
				DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY));
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1390
				break;
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1391
		}
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1392
	}
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1393
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1394
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1395
static const Widget _buy_company_widgets[] = {
3326
b5ce3e805425 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme
belugas
parents: 2952
diff changeset
  1396
{   WWT_CLOSEBOX,   RESIZE_NONE,     5,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
b5ce3e805425 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme
belugas
parents: 2952
diff changeset
  1397
{    WWT_CAPTION,   RESIZE_NONE,     5,    11,   333,     0,    13, STR_00B3_MESSAGE_FROM, STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
  1398
{      WWT_PANEL,   RESIZE_NONE,     5,     0,   333,    14,   136, 0x0,                   STR_NULL},
3326
b5ce3e805425 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme
belugas
parents: 2952
diff changeset
  1399
{    WWT_TEXTBTN,   RESIZE_NONE,     5,   148,   207,   117,   128, STR_00C9_NO,           STR_NULL},
b5ce3e805425 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme
belugas
parents: 2952
diff changeset
  1400
{    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
  1401
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1402
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1403
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1404
static const WindowDesc _buy_company_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
  1405
	153, 171, 334, 137, 334, 137,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
  1406
	WC_BUY_COMPANY, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1407
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1408
	_buy_company_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1409
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1410
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1411
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1412
void ShowBuyCompanyDialog(uint player)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1413
{
10626
557ccb284c8c (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 10595
diff changeset
  1414
	AllocateWindowDescFront<BuyCompanyWindow>(&_buy_company_desc, player);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1415
}
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1416
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1417
/********** HIGHSCORE and ENDGAME windows */
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1418
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1419
extern StringID EndGameGetPerformanceTitleFromValue(uint value);
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1420
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1421
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1422
struct EndGameHighScoreBaseWindow : Window
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1423
{
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1424
	uint32 background_img;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1425
	int8 rank;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1426
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1427
	EndGameHighScoreBaseWindow(const WindowDesc *desc) : Window(desc)
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1428
	{
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1429
	}
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1430
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1431
	/* Always draw a maximized window and within there the centered background */
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1432
	void SetupHighScoreEndWindow(uint *x, uint *y)
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1433
	{
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1434
		/* resize window to "full-screen" */
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1435
		this->width = _screen.width;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1436
		this->height = _screen.height;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1437
		this->widget[0].right = this->width - 1;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1438
		this->widget[0].bottom = this->height - 1;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1439
10595
7957c71b0dfe (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 10574
diff changeset
  1440
		this->DrawWidgets();
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1441
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1442
		/* Center Highscore/Endscreen background */
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1443
		*x = max(0, (_screen.width  / 2) - (640 / 2));
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1444
		*y = max(0, (_screen.height / 2) - (480 / 2));
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1445
		for (uint i = 0; i < 10; i++) { // the image is split into 10 50px high parts
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1446
			DrawSprite(this->background_img + i, PAL_NONE, *x, *y + (i * 50));
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1447
		}
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1448
	}
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1449
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1450
	virtual void OnClick(Point pt, int widget)
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1451
	{
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1452
		delete this;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1453
	}
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1454
};
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1455
6678
6353b8865d42 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6585
diff changeset
  1456
/** End game window shown at the end of the game */
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1457
struct EndGameWindow : EndGameHighScoreBaseWindow {
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1458
	EndGameWindow(const WindowDesc *desc) : EndGameHighScoreBaseWindow(desc)
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1459
	{
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1460
		/* Pause in single-player to have a look at the highscore at your own leisure */
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1461
		if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
10104
29e5b919d4a1 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 10103
diff changeset
  1462
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1463
		this->background_img = SPR_TYCOON_IMG1_BEGIN;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1464
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1465
		if (_local_player != PLAYER_SPECTATOR) {
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1466
			const Player *p = GetPlayer(_local_player);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1467
			if (p->old_economy[0].performance_history == SCORE_MAX) {
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1468
				this->background_img = SPR_TYCOON_IMG2_BEGIN;
10104
29e5b919d4a1 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 10103
diff changeset
  1469
			}
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1470
		}
10104
29e5b919d4a1 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 10103
diff changeset
  1471
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1472
		/* In a network game show the endscores of the custom difficulty 'network' which is the last one
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1473
		 * as well as generate a TOP5 of that game, and not an all-time top5. */
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1474
		if (_networking) {
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1475
			this->window_number = lengthof(_highscore_table) - 1;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1476
			this->rank = SaveHighScoreValueNetwork();
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1477
		} else {
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1478
			/* in single player _local player is always valid */
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1479
			const Player *p = GetPlayer(_local_player);
10707
81a4013a7680 (svn r13255) -Codechange: move _opt to _settings.
rubidium
parents: 10703
diff changeset
  1480
			this->window_number = _settings.difficulty.diff_level;
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1481
			this->rank = SaveHighScoreValue(p);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1482
		}
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1483
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1484
		MarkWholeScreenDirty();
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1485
	}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1486
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1487
	~EndGameWindow()
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1488
	{
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1489
		if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1490
		ShowHighscoreTable(this->window_number, this->rank);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1491
	}
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1492
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1493
	virtual void OnPaint()
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1494
	{
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1495
		const Player *p;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1496
		uint x, y;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1497
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1498
		this->SetupHighScoreEndWindow(&x, &y);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1499
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1500
		if (!IsValidPlayer(_local_player)) return;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1501
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1502
		p = GetPlayer(_local_player);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1503
		/* We need to get performance from last year because the image is shown
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1504
		 * at the start of the new year when these things have already been copied */
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1505
		if (this->background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1506
			SetDParam(0, p->index);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1507
			SetDParam(1, p->index);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1508
			SetDParam(2, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history));
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1509
			DrawStringMultiCenter(x + (640 / 2), y + 107, STR_021C_OF_ACHIEVES_STATUS, 640);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1510
		} else {
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1511
			SetDParam(0, p->index);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1512
			SetDParam(1, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history));
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1513
			DrawStringMultiCenter(x + (640 / 2), y + 157, STR_021B_ACHIEVES_STATUS, 640);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1514
		}
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1515
	}
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1516
};
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1517
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1518
struct HighScoreWindow : EndGameHighScoreBaseWindow
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1519
{
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1520
	HighScoreWindow(const WindowDesc *desc, int difficulty, int8 ranking) : EndGameHighScoreBaseWindow(desc)
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1521
	{
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1522
		/* pause game to show the chart */
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1523
		if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
1839
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1524
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1525
		/* Close all always on-top windows to get a clean screen */
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1526
		if (_game_mode != GM_MENU) HideVitalWindows();
10104
29e5b919d4a1 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 10103
diff changeset
  1527
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1528
		MarkWholeScreenDirty();
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1529
		this->window_number = difficulty; // show highscore chart for difficulty...
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1530
		this->background_img = SPR_HIGHSCORE_CHART_BEGIN; // which background to show
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1531
		this->rank = ranking;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1532
	}
10104
29e5b919d4a1 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 10103
diff changeset
  1533
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1534
	~HighScoreWindow()
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1535
	{
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1536
		if (_game_mode != GM_MENU) ShowVitalWindows();
10104
29e5b919d4a1 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 10103
diff changeset
  1537
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1538
		if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1539
	}
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1540
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1541
	virtual void OnPaint()
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1542
	{
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1543
		const HighScore *hs = _highscore_table[this->window_number];
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1544
		uint x, y;
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1545
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1546
		this->SetupHighScoreEndWindow(&x, &y);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1547
10703
2c998f3776d1 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 10681
diff changeset
  1548
		SetDParam(0, _settings.gui.ending_year);
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1549
		SetDParam(1, this->window_number + STR_6801_EASY);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1550
		DrawStringMultiCenter(x + (640 / 2), y + 62, !_networking ? STR_0211_TOP_COMPANIES_WHO_REACHED : STR_TOP_COMPANIES_NETWORK_GAME, 500);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1551
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1552
		/* Draw Highscore peepz */
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1553
		for (uint8 i = 0; i < lengthof(_highscore_table[0]); i++) {
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1554
			SetDParam(0, i + 1);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1555
			DrawString(x + 40, y + 140 + (i * 55), STR_0212, TC_BLACK);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1556
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1557
			if (hs[i].company[0] != '\0') {
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1558
				TextColour colour = (this->rank == i) ? TC_RED : TC_BLACK; // draw new highscore in red
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1559
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1560
				DoDrawString(hs[i].company, x + 71, y + 140 + (i * 55), colour);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1561
				SetDParam(0, hs[i].title);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1562
				SetDParam(1, hs[i].score);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1563
				DrawString(x + 71, y + 160 + (i * 55), STR_HIGHSCORE_STATS, colour);
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1564
			}
10104
29e5b919d4a1 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 10103
diff changeset
  1565
		}
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1566
	}
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1567
};
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1568
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1569
static const Widget _highscore_widgets[] = {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1570
{      WWT_PANEL, RESIZE_NONE, 16, 0, 640, 0, 480, 0x0, STR_NULL},
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1571
{   WIDGETS_END},
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1572
};
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1573
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1574
static const WindowDesc _highscore_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
  1575
	0, 0, 641, 481, 641, 481,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
  1576
	WC_HIGHSCORE, WC_NONE,
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1577
	0,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1578
	_highscore_widgets,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1579
};
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1580
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1581
static const WindowDesc _endgame_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
  1582
	0, 0, 641, 481, 641, 481,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6105
diff changeset
  1583
	WC_ENDSCREEN, WC_NONE,
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1584
	0,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1585
	_highscore_widgets,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1586
};
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1587
6678
6353b8865d42 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6585
diff changeset
  1588
/** Show the highscore table for a given difficulty. When called from
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1589
 * endgame ranking is set to the top5 element that was newly added
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1590
 * and is thus highlighted */
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
  1591
void ShowHighscoreTable(int difficulty, int8 ranking)
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1592
{
1875
3a1dba8ed6ea (svn r2381) - Fix: [ 1210610 ] Endgame window on easy difficulty results in infinite loop. Oops. Seperated the window classes of endgame and highscreen.
Darkvater
parents: 1839
diff changeset
  1593
	DeleteWindowByClass(WC_HIGHSCORE);
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1594
	new HighScoreWindow(&_highscore_desc, difficulty, ranking);
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1595
}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1596
6678
6353b8865d42 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6585
diff changeset
  1597
/** Show the endgame victory screen in 2050. Update the new highscore
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1598
 * if it was high enough */
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6516
diff changeset
  1599
void ShowEndGameChart()
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1600
{
1839
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1601
	/* Dedicated server doesn't need the highscore window */
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1602
	if (_network_dedicated) return;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1603
1839
6c0c19719fb2 (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1604
	HideVitalWindows();
1875
3a1dba8ed6ea (svn r2381) - Fix: [ 1210610 ] Endgame window on easy difficulty results in infinite loop. Oops. Seperated the window classes of endgame and highscreen.
Darkvater
parents: 1839
diff changeset
  1605
	DeleteWindowByClass(WC_ENDSCREEN);
10574
8ce36e759149 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 10573
diff changeset
  1606
	new EndGameWindow(&_endgame_desc);
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1607
}