src/company_gui.cpp
author translators
Sat, 06 Dec 2008 18:44:49 +0000
changeset 10409 a61956ad5da2
parent 10209 a1e7417bf1b7
permissions -rw-r--r--
(svn r14660) -Update: WebTranslator2 update to 2008-12-06 18:44:39
croatian - 55 changed by knovak (55)
hebrew - 237 fixed, 2 changed by ybungalobill (239)
indonesian - 124 fixed, 11 changed by sireno (19), adjayanto (50), fanioz (66)
persian - 19 fixed by ali sattari (19)
russian - 1 fixed by ybungalobill (1)
traditional_chinese - 1 fixed by josesun (1)
turkish - 28 fixed by Emin (28)
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
     3
/** @file company_gui.cpp Company related GUIs. */
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1875
diff changeset
     6
#include "openttd.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     8
#include "window_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     9
#include "textbuf_gui.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    10
#include "viewport_func.h"
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    11
#include "gfx_func.h"
10208
72c00af5c95d (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents: 10207
diff changeset
    12
#include "company_func.h"
72c00af5c95d (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents: 10207
diff changeset
    13
#include "company_base.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    14
#include "command_func.h"
5469
7edfc643abbc (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5431
diff changeset
    15
#include "network/network.h"
9428
1ba05b499957 (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 9413
diff changeset
    16
#include "network/network_gui.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2064
diff changeset
    17
#include "variables.h"
6857
60130753e595 (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 6769
diff changeset
    18
#include "roadveh.h"
2676
59b65b4fb480 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2642
diff changeset
    19
#include "train.h"
5854
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5668
diff changeset
    20
#include "aircraft.h"
4742
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
    21
#include "newgrf.h"
10208
72c00af5c95d (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents: 10207
diff changeset
    22
#include "company_manager_face.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8107
diff changeset
    23
#include "strings_func.h"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8121
diff changeset
    24
#include "functions.h"
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8121
diff changeset
    25
#include "window_func.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8131
diff changeset
    26
#include "date_func.h"
8214
971f861d5543 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8144
diff changeset
    27
#include "string_func.h"
8270
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8264
diff changeset
    28
#include "settings_type.h"
8284
ebdc5ba08874 (svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents: 8270
diff changeset
    29
#include "widgets/dropdown_func.h"
8908
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
    30
#include "widgets/dropdown_type.h"
9127
14f21c5954ee (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 9116
diff changeset
    31
#include "tilehighlight_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    33
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    34
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    35
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
    36
enum {
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
    37
	FIRST_GUI_CALL = INT_MAX,  ///< default value to specify thuis is the first call of the resizable gui
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
    38
};
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
    39
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
    40
static void DoShowCompanyFinances(CompanyID company, bool show_small, bool show_stickied, int top = FIRST_GUI_CALL, int left = FIRST_GUI_CALL);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
    41
static void DoSelectCompanyManagerFace(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
    42
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
    43
static void DrawCompanyEconomyStats(const Company *c, bool small)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
{
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6352
diff changeset
    45
	int x, y, i, j, year;
8515
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8343
diff changeset
    46
	const Money (*tbl)[EXPENSES_END];
6990
136a08baf0ed (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 6952
diff changeset
    47
	Money sum, cost;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
	StringID str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
    50
	if (!small) { // normal sized economics window
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
		/* draw categories */
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
    52
		DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, TC_FROMSTRING);
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
    53
		for (i = 0; i != EXPENSES_END; i++)
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
    54
			DrawString(2, 27 + i * 10, STR_7011_CONSTRUCTION + i, TC_FROMSTRING);
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
    55
		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
    56
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
		/* draw the price columns */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
		year = _cur_year - 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
		j = 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
		x = 215;
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
    61
		tbl = c->yearly_expenses + 2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
		do {
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
    63
			if (year >= c->inaugurated_year) {
4293
4b7006c1b5eb (svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents: 4286
diff changeset
    64
				SetDParam(0, year);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
    65
				DrawStringRightAlignedUnderline(x, 15, STR_7010, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
				sum = 0;
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
    67
				for (i = 0; i != EXPENSES_END; i++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
					/* draw one row in the price column */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
					cost = (*tbl)[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
					if (cost != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
						sum += cost;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
    72
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
						str = STR_701E;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
						if (cost < 0) { cost = -cost; str++; }
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
    75
						SetDParam(0, cost);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
    76
						DrawStringRightAligned(x, 27 + i * 10, str, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
				str = STR_701E;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
				if (sum < 0) { sum = -sum; str++; }
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
    82
				SetDParam(0, sum);
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
    83
				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
    84
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
    85
				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
    86
				x += 95;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
			year++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
			tbl--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
		} while (--j != 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
    92
		y = 27 + 10 * EXPENSES_END + 14;
186
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    93
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
    94
		/* draw max loan aligned to loan below (y += 10) */
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
    95
		SetDParam(0, _economy.max_loan);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
    96
		DrawString(202, y + 10, STR_MAX_LOAN, TC_FROMSTRING);
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    97
	} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
		y = 15;
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    99
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   101
	DrawString(2, y, STR_7026_BANK_BALANCE, TC_FROMSTRING);
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   102
	SetDParam(0, c->money);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   103
	DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
	y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   107
	DrawString(2, y, STR_7027_LOAN, TC_FROMSTRING);
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   108
	SetDParam(0, c->current_loan);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   109
	DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
	y += 12;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6352
diff changeset
   113
	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
   114
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   115
	SetDParam(0, c->money - c->current_loan);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
   116
	DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   119
enum CompanyFinancesWindowWidgets {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   120
	CFW_WIDGET_TOGGLE_SIZE   = 2,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   121
	CFW_WIDGET_INCREASE_LOAN = 6,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   122
	CFW_WIDGET_REPAY_LOAN    = 7,
8339
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   123
};
74f5ebc768d4 (svn r11905) -Codechange: add widget enums for player finances and player livery windows
peter1138
parents: 8309
diff changeset
   124
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   125
static const Widget _company_finances_widgets[] = {
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   126
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   127
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   379,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   128
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,   380,   394,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   129
{  WWT_STICKYBOX,   RESIZE_NONE,  COLOUR_GREY,   395,   406,     0,    13, 0x0,                    STR_STICKY_BUTTON},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   130
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   406,    14, 39 + 10 * EXPENSES_END, 0x0,    STR_NULL},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   131
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   406, 40 + 10 * EXPENSES_END, 73 + 10 * EXPENSES_END, 0x0, STR_NULL},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   132
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,   202, 74 + 10 * EXPENSES_END, 85 + 10 * EXPENSES_END, STR_7029_BORROW,        STR_7035_INCREASE_SIZE_OF_LOAN},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   133
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   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
   134
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   137
static const Widget _company_finances_small_widgets[] = {
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   138
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   139
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   253,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   140
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,   254,   267,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   141
{  WWT_STICKYBOX,   RESIZE_NONE,  COLOUR_GREY,   268,   279,     0,    13, 0x0,                    STR_STICKY_BUTTON},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   142
{      WWT_EMPTY,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,     0, 0x0,                    STR_NULL},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   143
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   279,    14,    47, STR_NULL,               STR_NULL},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   144
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,   139,    48,    59, STR_7029_BORROW,        STR_7035_INCREASE_SIZE_OF_LOAN},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   145
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   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
   146
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   149
struct CompanyFinancesWindow : Window {
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   150
	bool small;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   152
	CompanyFinancesWindow(const WindowDesc *desc, CompanyID company, bool show_small,
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   153
					bool show_stickied, int top, int left) :
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   154
			Window(desc, company),
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   155
			small(show_small)
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   156
	{
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   157
		this->caption_color = this->window_number;
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   158
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   159
		if (show_stickied) this->flags4 |= WF_STICKY;
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   160
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   161
		/* Check if repositioning from default is required */
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   162
		if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) {
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   163
			this->top = top;
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   164
			this->left = left;
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   165
		}
9333
2da01b3b71d8 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 9332
diff changeset
   166
2da01b3b71d8 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 9332
diff changeset
   167
		this->FindWindowPlacementAndResize(desc);
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   168
	}
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   169
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   170
	virtual void OnPaint()
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   171
	{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   172
		CompanyID company = (CompanyID)this->window_number;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   173
		const Company *c = GetCompany(company);
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   174
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   175
		/* Recheck the size of the window as it might need to be resized due to the local company changing */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   176
		int new_height = ((company != _local_company) ? 0 : 12) + ((this->small != 0) ? 48 : 74 + 10 * EXPENSES_END);
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   177
		if (this->height != new_height) {
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   178
			/* Make window dirty before and after resizing */
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   179
			this->SetDirty();
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   180
			this->height = new_height;
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   181
			this->SetDirty();
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   182
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   183
			this->SetWidgetHiddenState(CFW_WIDGET_INCREASE_LOAN, company != _local_company);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   184
			this->SetWidgetHiddenState(CFW_WIDGET_REPAY_LOAN,    company != _local_company);
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   185
		}
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   186
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   187
		/* Borrow button only shows when there is any more money to loan */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   188
		this->SetWidgetDisabledState(CFW_WIDGET_INCREASE_LOAN, c->current_loan == _economy.max_loan);
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   189
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   190
		/* Repay button only shows when there is any more money to repay */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   191
		this->SetWidgetDisabledState(CFW_WIDGET_REPAY_LOAN, company != _local_company || c->current_loan == 0);
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   192
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   193
		SetDParam(0, c->index);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   194
		SetDParam(1, c->index);
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   195
		SetDParam(2, LOAN_INTERVAL);
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9252
diff changeset
   196
		this->DrawWidgets();
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   197
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   198
		DrawCompanyEconomyStats(c, this->small);
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   199
	}
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   200
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   201
	virtual void OnClick(Point pt, int widget)
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   202
	{
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   203
		switch (widget) {
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   204
			case CFW_WIDGET_TOGGLE_SIZE: {/* toggle size */
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   205
				bool new_mode = !this->small;
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   206
				bool stickied = !!(this->flags4 & WF_STICKY);
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   207
				int oldtop = this->top;   ///< current top position of the window before closing it
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   208
				int oldleft = this->left; ///< current left position of the window before closing it
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   209
				CompanyID company = (CompanyID)this->window_number;
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   210
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   211
				delete this;
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   212
				/* Open up the (toggled size) Finance window at the same position as the previous */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   213
				DoShowCompanyFinances(company, new_mode, stickied, oldtop, oldleft);
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   214
			}
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   215
			break;
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   216
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   217
			case CFW_WIDGET_INCREASE_LOAN: /* increase loan */
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   218
				DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY));
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   219
				break;
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
   220
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   221
			case CFW_WIDGET_REPAY_LOAN: /* repay loan */
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   222
				DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN));
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   223
				break;
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   224
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
	}
9251
bee6451d87a7 (svn r13117) -Codechange: make a window class of the PlayerFinancesWindow.
rubidium
parents: 9241
diff changeset
   226
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   228
static const WindowDesc _company_finances_desc = {
8960
bec2d8df8265 (svn r12752) -Codechange: replace some magic constants in player_gui.cpp. Patch by Yexo.
rubidium
parents: 8908
diff changeset
   229
	WDP_AUTO, WDP_AUTO, 407, 86 + 10 * EXPENSES_END, 407, 86 + 10 * EXPENSES_END,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
   230
	WC_FINANCES, WC_NONE,
2064
e6a2b42d0b15 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   231
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   232
	_company_finances_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   235
static const WindowDesc _company_finances_small_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   236
	WDP_AUTO, WDP_AUTO, 280, 60, 280, 60,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
   237
	WC_FINANCES, WC_NONE,
2064
e6a2b42d0b15 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   238
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   239
	_company_finances_small_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   242
/**
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   243
 * Open the small/large finance window of the company
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   244
 *
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   245
 * @param company        the company who's finances are requested to be seen
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   246
 * @param show_small     show large or small version opf the window
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   247
 * @param show_stickied  previous "stickyness" of the window
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   248
 * @param top            previous top position of the window
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   249
 * @param left           previous left position of the window
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   250
 *
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   251
 * @pre is company a valid company
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
   252
 */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   253
static void DoShowCompanyFinances(CompanyID company, 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
   254
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   255
	if (!IsValidCompanyID(company)) return;
5005
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
   256
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   257
	if (BringWindowToFrontById(WC_FINANCES, company)) return;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   258
	new CompanyFinancesWindow(show_small ? &_company_finances_small_desc : &_company_finances_desc, company, show_small, show_stickied, top, left);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   261
void ShowCompanyFinances(CompanyID company)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   263
	DoShowCompanyFinances(company, false, false);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   266
/* List of colours for the livery window */
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   267
static const StringID _colour_dropdown[] = {
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   268
	STR_00D1_DARK_BLUE,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   269
	STR_00D2_PALE_GREEN,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   270
	STR_00D3_PINK,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   271
	STR_00D4_YELLOW,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   272
	STR_00D5_RED,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   273
	STR_00D6_LIGHT_BLUE,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   274
	STR_00D7_GREEN,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   275
	STR_00D8_DARK_GREEN,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   276
	STR_00D9_BLUE,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   277
	STR_00DA_CREAM,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   278
	STR_00DB_MAUVE,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   279
	STR_00DC_PURPLE,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   280
	STR_00DD_ORANGE,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   281
	STR_00DE_BROWN,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   282
	STR_00DF_GREY,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   283
	STR_00E0_WHITE,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   284
};
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   285
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   286
/* Association of liveries to livery classes */
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   287
static const LiveryClass _livery_class[LS_END] = {
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   288
	LC_OTHER,
8309
5d3e63cd70e0 (svn r11874) -Fix [FS#1655]: all wagons of maglev/monorail trains would get the livery colour of the engine instead of their wagon type.
rubidium
parents: 8284
diff changeset
   289
	LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL,
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   290
	LC_ROAD, LC_ROAD,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   291
	LC_SHIP, LC_SHIP,
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   292
	LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT,
6724
4f404dfe9752 (svn r9956) -Codechange: Add tram livery schemes
peter1138
parents: 6491
diff changeset
   293
	LC_ROAD, LC_ROAD,
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   294
};
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   295
8908
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   296
class DropDownListColourItem : public DropDownListItem {
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   297
public:
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   298
	DropDownListColourItem(int result, bool masked) : DropDownListItem(result, masked) {}
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   299
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   300
	virtual ~DropDownListColourItem() {}
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   301
9859
28606a486c52 (svn r14004) -Codechange: Clean of drop down lists.
peter1138
parents: 9762
diff changeset
   302
	StringID String() const
8908
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   303
	{
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   304
		return _colour_dropdown[this->result];
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   305
	}
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   306
9859
28606a486c52 (svn r14004) -Codechange: Clean of drop down lists.
peter1138
parents: 9762
diff changeset
   307
	uint Height(uint width) const
8908
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   308
	{
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   309
		return 14;
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   310
	}
9878
8142e032b4e0 (svn r14026) -Cleanup (r13995, r14004): trailing whitespaces
glx
parents: 9859
diff changeset
   311
9859
28606a486c52 (svn r14004) -Codechange: Clean of drop down lists.
peter1138
parents: 9762
diff changeset
   312
	bool Selectable() const
28606a486c52 (svn r14004) -Codechange: Clean of drop down lists.
peter1138
parents: 9762
diff changeset
   313
	{
28606a486c52 (svn r14004) -Codechange: Clean of drop down lists.
peter1138
parents: 9762
diff changeset
   314
		return true;
28606a486c52 (svn r14004) -Codechange: Clean of drop down lists.
peter1138
parents: 9762
diff changeset
   315
	}
8908
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   316
9859
28606a486c52 (svn r14004) -Codechange: Clean of drop down lists.
peter1138
parents: 9762
diff changeset
   317
	void Draw(int x, int y, uint width, uint height, bool sel, int bg_colour) const
8908
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   318
	{
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   319
		DrawSprite(SPR_VEH_BUS_SIDE_VIEW, PALETTE_RECOLOR_START + this->result, x + 16, y + 7);
9859
28606a486c52 (svn r14004) -Codechange: Clean of drop down lists.
peter1138
parents: 9762
diff changeset
   320
		DrawStringTruncated(x + 32, y + 3, this->String(), sel ? TC_WHITE : TC_BLACK, width - 30);
8908
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   321
	}
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   322
};
87dcd87222cf (svn r12676) -Codechange: Reinstate colour selection buses, absent since r6455.
peter1138
parents: 8868
diff changeset
   323
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   324
struct SelectCompanyLiveryWindow : public Window {
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   325
private:
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   326
	uint32 sel;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   327
	LiveryClass livery_class;
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   328
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   329
	enum SelectCompanyLiveryWindowWidgets {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   330
		SCLW_WIDGET_CLOSE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   331
		SCLW_WIDGET_CAPTION,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   332
		SCLW_WIDGET_CLASS_GENERAL,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   333
		SCLW_WIDGET_CLASS_RAIL,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   334
		SCLW_WIDGET_CLASS_ROAD,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   335
		SCLW_WIDGET_CLASS_SHIP,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   336
		SCLW_WIDGET_CLASS_AIRCRAFT,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   337
		SCLW_WIDGET_SPACER_CLASS,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   338
		SCLW_WIDGET_SPACER_DROPDOWN,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   339
		SCLW_WIDGET_PRI_COL_DROPDOWN,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   340
		SCLW_WIDGET_SEC_COL_DROPDOWN,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   341
		SCLW_WIDGET_MATRIX,
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   342
	};
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   343
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   344
	void ShowColourDropDownMenu(uint32 widget)
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   345
	{
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   346
		uint32 used_colours = 0;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   347
		const Livery *livery;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   348
		LiveryScheme scheme;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   349
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   350
		/* Disallow other company colours for the primary colour */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   351
		if (HasBit(this->sel, LS_DEFAULT) && widget == SCLW_WIDGET_PRI_COL_DROPDOWN) {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   352
			const Company *c;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   353
			FOR_ALL_COMPANIES(c) {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   354
				if (c->index != _local_company) SetBit(used_colours, c->colour);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   355
			}
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   356
		}
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   357
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   358
		/* Get the first selected livery to use as the default dropdown item */
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   359
		for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   360
			if (HasBit(this->sel, scheme)) break;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   361
		}
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   362
		if (scheme == LS_END) scheme = LS_DEFAULT;
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   363
		livery = &GetCompany((CompanyID)this->window_number)->livery[scheme];
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   364
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   365
		DropDownList *list = new DropDownList();
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   366
		for (uint i = 0; i < lengthof(_colour_dropdown); i++) {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   367
			list->push_back(new DropDownListColourItem(i, HasBit(used_colours, i)));
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   368
		}
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   369
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   370
		ShowDropDownList(this, list, widget == SCLW_WIDGET_PRI_COL_DROPDOWN ? livery->colour1 : livery->colour2, widget);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   371
	}
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   372
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   373
public:
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   374
	SelectCompanyLiveryWindow(const WindowDesc *desc, CompanyID company) : Window(desc, company)
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   375
	{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   376
		this->caption_color = company;
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   377
		this->livery_class = LC_OTHER;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   378
		this->sel = 1;
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   379
		this->LowerWidget(SCLW_WIDGET_CLASS_GENERAL);
9230
6710ef7d0226 (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 9229
diff changeset
   380
		this->OnInvalidateData(_loaded_newgrf_features.has_2CC);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   381
		this->FindWindowPlacementAndResize(desc);
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   382
	}
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   383
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   384
	virtual void OnPaint()
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   385
	{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   386
		const Company *c = GetCompany((CompanyID)this->window_number);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   387
		LiveryScheme scheme = LS_DEFAULT;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   388
		int y = 51;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   389
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   390
		/* Disable dropdown controls if no scheme is selected */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   391
		this->SetWidgetDisabledState(SCLW_WIDGET_PRI_COL_DROPDOWN, this->sel == 0);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   392
		this->SetWidgetDisabledState(SCLW_WIDGET_SEC_COL_DROPDOWN, this->sel == 0);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   393
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   394
		if (this->sel != 0) {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   395
			for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   396
				if (HasBit(this->sel, scheme)) break;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   397
			}
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   398
			if (scheme == LS_END) scheme = LS_DEFAULT;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   399
		}
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   400
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   401
		SetDParam(0, STR_00D1_DARK_BLUE + c->livery[scheme].colour1);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   402
		SetDParam(1, STR_00D1_DARK_BLUE + c->livery[scheme].colour2);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   403
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9252
diff changeset
   404
		this->DrawWidgets();
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   405
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   406
		for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   407
			if (_livery_class[scheme] == this->livery_class) {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   408
				bool sel = HasBit(this->sel, scheme) != 0;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   409
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   410
				if (scheme != LS_DEFAULT) {
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   411
					DrawSprite(c->livery[scheme].in_use ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, 2, y);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   412
				}
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   413
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   414
				DrawString(15, y, STR_LIVERY_DEFAULT + scheme, sel ? TC_WHITE : TC_BLACK);
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   415
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   416
				DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(c->livery[scheme].colour1), 152, y);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   417
				DrawString(165, y, STR_00D1_DARK_BLUE + c->livery[scheme].colour1, sel ? TC_WHITE : TC_GOLD);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   418
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   419
				if (!this->IsWidgetHidden(SCLW_WIDGET_SEC_COL_DROPDOWN)) {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   420
					DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(c->livery[scheme].colour2), 277, y);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   421
					DrawString(290, y, STR_00D1_DARK_BLUE + c->livery[scheme].colour2, sel ? TC_WHITE : TC_GOLD);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   422
				}
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   423
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   424
				y += 14;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   425
			}
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   426
		}
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   427
	}
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   428
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   429
	virtual void OnClick(Point pt, int widget)
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   430
	{
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   431
		/* Number of liveries in each class, used to determine the height of the livery window */
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   432
		static const byte livery_height[] = {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   433
			1,
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   434
			13,
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   435
			4,
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   436
			2,
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   437
			3,
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   438
		};
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   439
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   440
		switch (widget) {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   441
			/* Livery Class buttons */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   442
			case SCLW_WIDGET_CLASS_GENERAL:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   443
			case SCLW_WIDGET_CLASS_RAIL:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   444
			case SCLW_WIDGET_CLASS_ROAD:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   445
			case SCLW_WIDGET_CLASS_SHIP:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   446
			case SCLW_WIDGET_CLASS_AIRCRAFT: {
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   447
				LiveryScheme scheme;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   448
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   449
				this->RaiseWidget(this->livery_class + SCLW_WIDGET_CLASS_GENERAL);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   450
				this->livery_class = (LiveryClass)(widget - SCLW_WIDGET_CLASS_GENERAL);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   451
				this->sel = 0;
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   452
				this->LowerWidget(this->livery_class + SCLW_WIDGET_CLASS_GENERAL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   454
				/* Select the first item in the list */
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   455
				for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   456
					if (_livery_class[scheme] == this->livery_class) {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   457
						this->sel = 1 << scheme;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   458
						break;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   459
					}
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   460
				}
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   461
				this->height = 49 + livery_height[this->livery_class] * 14;
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   462
				this->widget[SCLW_WIDGET_MATRIX].bottom = this->height - 1;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   463
				this->widget[SCLW_WIDGET_MATRIX].data = livery_height[this->livery_class] << 8 | 1;
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   464
				MarkWholeScreenDirty();
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   465
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
			}
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   467
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   468
			case SCLW_WIDGET_PRI_COL_DROPDOWN: /* First colour dropdown */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   469
				ShowColourDropDownMenu(SCLW_WIDGET_PRI_COL_DROPDOWN);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   470
				break;
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   471
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   472
			case SCLW_WIDGET_SEC_COL_DROPDOWN: /* Second colour dropdown */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   473
				ShowColourDropDownMenu(SCLW_WIDGET_SEC_COL_DROPDOWN);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   474
				break;
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   475
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   476
			case SCLW_WIDGET_MATRIX: {
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   477
				LiveryScheme scheme;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   478
				LiveryScheme j = (LiveryScheme)((pt.y - 48) / 14);
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   479
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   480
				for (scheme = LS_BEGIN; scheme <= j; scheme++) {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   481
					if (_livery_class[scheme] != this->livery_class) j++;
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   482
					if (scheme >= LS_END) return;
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   483
				}
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   484
				if (j >= LS_END) return;
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   485
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   486
				/* If clicking on the left edge, toggle using the livery */
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   487
				if (pt.x < 10) {
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   488
					DoCommandP(0, j | (2 << 8), !GetCompany((CompanyID)this->window_number)->livery[j].in_use, NULL, CMD_SET_COMPANY_COLOR);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   489
				}
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   490
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   491
				if (_ctrl_pressed) {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   492
					ToggleBit(this->sel, j);
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   493
				} else {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   494
					this->sel = 1 << j;
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   495
				}
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   496
				this->SetDirty();
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   497
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
			}
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   499
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
	}
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   501
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   502
	virtual void OnDropdownSelect(int widget, int index)
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   503
	{
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   504
		for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   505
			if (HasBit(this->sel, scheme)) {
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   506
				DoCommandP(0, scheme | (widget == SCLW_WIDGET_PRI_COL_DROPDOWN ? 0 : 256), index, NULL, CMD_SET_COMPANY_COLOR);
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   507
			}
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   508
		}
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   509
	}
9230
6710ef7d0226 (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 9229
diff changeset
   510
6710ef7d0226 (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 9229
diff changeset
   511
	virtual void OnInvalidateData(int data = 0)
6710ef7d0226 (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 9229
diff changeset
   512
	{
6710ef7d0226 (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 9229
diff changeset
   513
		static bool has2cc = true;
6710ef7d0226 (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 9229
diff changeset
   514
6710ef7d0226 (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 9229
diff changeset
   515
		if (has2cc == !!data) return;
6710ef7d0226 (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 9229
diff changeset
   516
6710ef7d0226 (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 9229
diff changeset
   517
		has2cc = !!data;
6710ef7d0226 (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 9229
diff changeset
   518
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   519
		int r = this->widget[has2cc ? SCLW_WIDGET_SEC_COL_DROPDOWN : SCLW_WIDGET_PRI_COL_DROPDOWN].right;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   520
		this->SetWidgetHiddenState(SCLW_WIDGET_SEC_COL_DROPDOWN, !has2cc);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   521
		this->widget[SCLW_WIDGET_CAPTION].right = r;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   522
		this->widget[SCLW_WIDGET_SPACER_CLASS].right = r;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   523
		this->widget[SCLW_WIDGET_MATRIX].right = r;
9230
6710ef7d0226 (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 9229
diff changeset
   524
		this->width = r + 1;
6710ef7d0226 (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx
parents: 9229
diff changeset
   525
	}
9229
9e355bf1ab65 (svn r13095) -Codechange: make a class of the SelectPlayerLiveryWindow.
glx
parents: 9204
diff changeset
   526
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   528
static const Widget _select_company_livery_widgets[] = {
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   529
{ WWT_CLOSEBOX, RESIZE_NONE,  COLOUR_GREY,   0,  10,   0,  13, STR_00C5,                  STR_018B_CLOSE_WINDOW },
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   530
{  WWT_CAPTION, RESIZE_NONE,  COLOUR_GREY,  11, 399,   0,  13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   531
{   WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,  21,  14,  35, SPR_IMG_COMPANY_GENERAL,   STR_LIVERY_GENERAL_TIP },
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   532
{   WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,  22,  43,  14,  35, SPR_IMG_TRAINLIST,         STR_LIVERY_TRAIN_TIP },
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   533
{   WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,  44,  65,  14,  35, SPR_IMG_TRUCKLIST,         STR_LIVERY_ROADVEH_TIP },
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   534
{   WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,  66,  87,  14,  35, SPR_IMG_SHIPLIST,          STR_LIVERY_SHIP_TIP },
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   535
{   WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,  88, 109,  14,  35, SPR_IMG_AIRPLANESLIST,     STR_LIVERY_AIRCRAFT_TIP },
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   536
{    WWT_PANEL, RESIZE_NONE,  COLOUR_GREY, 110, 399,  14,  35, 0x0,                       STR_NULL },
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   537
{    WWT_PANEL, RESIZE_NONE,  COLOUR_GREY,   0, 149,  36,  47, 0x0,                       STR_NULL },
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   538
{ WWT_DROPDOWN, RESIZE_NONE,  COLOUR_GREY, 150, 274,  36,  47, STR_02BD,                  STR_LIVERY_PRIMARY_TIP },
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   539
{ WWT_DROPDOWN, RESIZE_NONE,  COLOUR_GREY, 275, 399,  36,  47, STR_02E1,                  STR_LIVERY_SECONDARY_TIP },
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
   540
{   WWT_MATRIX, RESIZE_NONE,  COLOUR_GREY,   0, 399,  48,  48 + 1 * 14, (1 << 8) | 1,     STR_LIVERY_PANEL_TIP },
4603
20c816f664de (svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents: 4344
diff changeset
   541
{ WIDGETS_END },
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   544
static const WindowDesc _select_company_livery_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
   545
	WDP_AUTO, WDP_AUTO, 400, 49 + 1 * 14, 400, 49 + 1 * 14,
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   546
	WC_COMPANY_COLOR, WC_NONE,
4742
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4719
diff changeset
   547
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   548
	_select_company_livery_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   551
/**
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   552
 * Draws the face of a company manager's face.
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   553
 * @param cmf   the company manager's face
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   554
 * @param color the (background) color of the gradient
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   555
 * @param x     x-position to draw the face
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   556
 * @param y     y-position to draw the face
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   557
 */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   558
void DrawCompanyManagerFace(CompanyManagerFace cmf, int color, int x, int y)
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   559
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   560
	GenderEthnicity ge = (GenderEthnicity)GetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, GE_WM);
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   561
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   562
	bool has_moustache   = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE,   ge) != 0;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   563
	bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetCompanyManagerFaceBits(cmf, CMFV_HAS_TIE_EARRING, ge) != 0;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   564
	bool has_glasses     = GetCompanyManagerFaceBits(cmf, CMFV_HAS_GLASSES, ge) != 0;
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   565
	SpriteID pal;
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   566
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   567
	/* Modify eye colour palette only if 2 or more valid values exist */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   568
	if (_cmf_info[CMFV_EYE_COLOUR].valid_values[ge] < 2) {
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   569
		pal = PAL_NONE;
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   570
	} else {
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   571
		switch (GetCompanyManagerFaceBits(cmf, CMFV_EYE_COLOUR, ge)) {
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   572
			default: NOT_REACHED();
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   573
			case 0: pal = PALETTE_TO_BROWN; break;
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   574
			case 1: pal = PALETTE_TO_BLUE;  break;
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   575
			case 2: pal = PALETTE_TO_GREEN; break;
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   576
		}
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   577
	}
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   578
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   579
	/* Draw the gradient (background) */
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   580
	DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOR(color), x, y);
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   581
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   582
	for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   583
		switch (cmfv) {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   584
			case CMFV_MOUSTACHE:   if (!has_moustache)   continue; break;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   585
			case CMFV_LIPS:        /* FALL THROUGH */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   586
			case CMFV_NOSE:        if (has_moustache)    continue; break;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   587
			case CMFV_TIE_EARRING: if (!has_tie_earring) continue; break;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   588
			case CMFV_GLASSES:     if (!has_glasses)     continue; break;
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   589
			default: break;
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   590
		}
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   591
		DrawSprite(GetCompanyManagerFaceSprite(cmf, cmfv, ge), (cmfv == CMFV_EYEBROWS) ? pal : PAL_NONE, x, y);
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   592
	}
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   593
}
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 5893
diff changeset
   594
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   595
/** Widget description for the normal/simple company manager face selection dialog */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   596
static const Widget _select_company_manager_face_widgets[] = {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   597
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},              // SCMFW_WIDGET_CLOSEBOX
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   598
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   174,     0,    13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // SCMFW_WIDGET_CAPTION
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   599
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,   175,   189,     0,    13, SPR_LARGE_SMALL_WINDOW,  STR_FACE_ADVANCED_TIP},              // SCMFW_WIDGET_TOGGLE_LARGE_SMALL
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   600
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   189,    14,   150, 0x0,                     STR_NULL},                           // SCMFW_WIDGET_SELECT_FACE
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   601
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,    94,   151,   162, STR_012E_CANCEL,         STR_7047_CANCEL_NEW_FACE_SELECTION}, // SCMFW_WIDGET_CANCEL
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   602
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    95,   189,   151,   162, STR_012F_OK,             STR_7048_ACCEPT_NEW_FACE_SELECTION}, // SCMFW_WIDGET_ACCEPT
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   603
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,    95,   187,    75,    86, STR_7044_MALE,           STR_7049_SELECT_MALE_FACES},         // SCMFW_WIDGET_MALE
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   604
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,    95,   187,    87,    98, STR_7045_FEMALE,         STR_704A_SELECT_FEMALE_FACES},       // SCMFW_WIDGET_FEMALE
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   605
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     2,    93,   137,   148, STR_7046_NEW_FACE,       STR_704B_GENERATE_RANDOM_NEW_FACE},  // SCMFW_WIDGET_RANDOM_NEW_FACE
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   606
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    95,   187,    16,    27, STR_FACE_ADVANCED,       STR_FACE_ADVANCED_TIP},              // SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   607
{   WIDGETS_END},
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   608
};
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   609
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   610
/** Widget description for the advanced company manager face selection dialog */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   611
static const Widget _select_company_manager_face_adv_widgets[] = {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   612
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},              // SCMFW_WIDGET_CLOSEBOX
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   613
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   204,     0,    13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // SCMFW_WIDGET_CAPTION
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   614
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,   205,   219,     0,    13, SPR_LARGE_SMALL_WINDOW,  STR_FACE_SIMPLE_TIP},                // SCMFW_WIDGET_TOGGLE_LARGE_SMALL
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   615
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   219,    14,   207, 0x0,                     STR_NULL},                           // SCMFW_WIDGET_SELECT_FACE
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   616
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,    94,   208,   219, STR_012E_CANCEL,         STR_7047_CANCEL_NEW_FACE_SELECTION}, // SCMFW_WIDGET_CANCEL
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   617
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    95,   219,   208,   219, STR_012F_OK,             STR_7048_ACCEPT_NEW_FACE_SELECTION}, // SCMFW_WIDGET_ACCEPT
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   618
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,    96,   156,    32,    43, STR_7044_MALE,           STR_7049_SELECT_MALE_FACES},         // SCMFW_WIDGET_MALE
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   619
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,   157,   217,    32,    43, STR_7045_FEMALE,         STR_704A_SELECT_FEMALE_FACES},       // SCMFW_WIDGET_FEMALE
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   620
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     2,    93,   137,   148, STR_RANDOM,              STR_704B_GENERATE_RANDOM_NEW_FACE},  // SCMFW_WIDGET_RANDOM_NEW_FACE
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   621
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    95,   217,    16,    27, STR_FACE_SIMPLE,         STR_FACE_SIMPLE_TIP},                // SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   622
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     2,    93,   158,   169, STR_FACE_LOAD,           STR_FACE_LOAD_TIP},                  // SCMFW_WIDGET_LOAD
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   623
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     2,    93,   170,   181, STR_FACE_FACECODE,       STR_FACE_FACECODE_TIP},              // SCMFW_WIDGET_FACECODE
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   624
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     2,    93,   182,   193, STR_FACE_SAVE,           STR_FACE_SAVE_TIP},                  // SCMFW_WIDGET_SAVE
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   625
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,    96,   156,    46,    57, STR_FACE_EUROPEAN,       STR_FACE_SELECT_EUROPEAN},           // SCMFW_WIDGET_ETHNICITY_EUR
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   626
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,   157,   217,    46,    57, STR_FACE_AFRICAN,        STR_FACE_SELECT_AFRICAN},            // SCMFW_WIDGET_ETHNICITY_AFR
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   627
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   175,   217,    60,    71, STR_EMPTY,               STR_FACE_MOUSTACHE_EARRING_TIP},     // SCMFW_WIDGET_HAS_MOUSTACHE_EARRING
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   628
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   175,   217,    72,    83, STR_EMPTY,               STR_FACE_GLASSES_TIP},               // SCMFW_WIDGET_HAS_GLASSES
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   629
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    175,  183,   110,   121, SPR_ARROW_LEFT,          STR_FACE_EYECOLOUR_TIP},             // SCMFW_WIDGET_EYECOLOUR_L
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   630
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    184,  208,   110,   121, STR_EMPTY,               STR_FACE_EYECOLOUR_TIP},             // SCMFW_WIDGET_EYECOLOUR
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   631
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    209,  217,   110,   121, SPR_ARROW_RIGHT,         STR_FACE_EYECOLOUR_TIP},             // SCMFW_WIDGET_EYECOLOUR_R
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   632
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    175,  183,   158,   169, SPR_ARROW_LEFT,          STR_FACE_CHIN_TIP},                  // SCMFW_WIDGET_CHIN_L
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   633
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    184,  208,   158,   169, STR_EMPTY,               STR_FACE_CHIN_TIP},                  // SCMFW_WIDGET_CHIN
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   634
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    209,  217,   158,   169, SPR_ARROW_RIGHT,         STR_FACE_CHIN_TIP},                  // SCMFW_WIDGET_CHIN_R
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   635
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    175,  183,    98,   109, SPR_ARROW_LEFT,          STR_FACE_EYEBROWS_TIP},              // SCMFW_WIDGET_EYEBROWS_L
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   636
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    184,  208,    98,   109, STR_EMPTY,               STR_FACE_EYEBROWS_TIP},              // SCMFW_WIDGET_EYEBROWS
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   637
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    209,  217,    98,   109, SPR_ARROW_RIGHT,         STR_FACE_EYEBROWS_TIP},              // SCMFW_WIDGET_EYEBROWS_R
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   638
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    175,  183,   146,   157, SPR_ARROW_LEFT,          STR_FACE_LIPS_MOUSTACHE_TIP},        // SCMFW_WIDGET_LIPS_MOUSTACHE_L
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   639
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    184,  208,   146,   157, STR_EMPTY,               STR_FACE_LIPS_MOUSTACHE_TIP},        // SCMFW_WIDGET_LIPS_MOUSTACHE
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   640
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    209,  217,   146,   157, SPR_ARROW_RIGHT,         STR_FACE_LIPS_MOUSTACHE_TIP},        // SCMFW_WIDGET_LIPS_MOUSTACHE_R
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   641
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    175,  183,   134,   145, SPR_ARROW_LEFT,          STR_FACE_NOSE_TIP},                  // SCMFW_WIDGET_NOSE_L
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   642
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    184,  208,   134,   145, STR_EMPTY,               STR_FACE_NOSE_TIP},                  // SCMFW_WIDGET_NOSE
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   643
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    209,  217,   134,   145, SPR_ARROW_RIGHT,         STR_FACE_NOSE_TIP},                  // SCMFW_WIDGET_NOSE_R
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   644
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    175,  183,    86,    97, SPR_ARROW_LEFT,          STR_FACE_HAIR_TIP},                  // SCMFW_WIDGET_HAIR_L
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   645
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    184,  208,    86,    97, STR_EMPTY,               STR_FACE_HAIR_TIP},                  // SCMFW_WIDGET_HAIR
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   646
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    209,  217,    86,    97, SPR_ARROW_RIGHT,         STR_FACE_HAIR_TIP},                  // SCMFW_WIDGET_HAIR_R
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   647
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    175,  183,   170,   181, SPR_ARROW_LEFT,          STR_FACE_JACKET_TIP},                // SCMFW_WIDGET_JACKET_L
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   648
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    184,  208,   170,   181, STR_EMPTY,               STR_FACE_JACKET_TIP},                // SCMFW_WIDGET_JACKET
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   649
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    209,  217,   170,   181, SPR_ARROW_RIGHT,         STR_FACE_JACKET_TIP},                // SCMFW_WIDGET_JACKET_R
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   650
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    175,  183,   182,   193, SPR_ARROW_LEFT,          STR_FACE_COLLAR_TIP},                // SCMFW_WIDGET_COLLAR_L
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   651
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    184,  208,   182,   193, STR_EMPTY,               STR_FACE_COLLAR_TIP},                // SCMFW_WIDGET_COLLAR
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   652
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    209,  217,   182,   193, SPR_ARROW_RIGHT,         STR_FACE_COLLAR_TIP},                // SCMFW_WIDGET_COLLAR_R
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   653
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    175,  183,   194,   205, SPR_ARROW_LEFT,          STR_FACE_TIE_EARRING_TIP},           // SCMFW_WIDGET_TIE_EARRING_L
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   654
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    184,  208,   194,   205, STR_EMPTY,               STR_FACE_TIE_EARRING_TIP},           // SCMFW_WIDGET_TIE_EARRING
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   655
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    209,  217,   194,   205, SPR_ARROW_RIGHT,         STR_FACE_TIE_EARRING_TIP},           // SCMFW_WIDGET_TIE_EARRING_R
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   656
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    175,  183,   122,   133, SPR_ARROW_LEFT,          STR_FACE_GLASSES_TIP_2},             // SCMFW_WIDGET_GLASSES_L
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   657
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    184,  208,   122,   133, STR_EMPTY,               STR_FACE_GLASSES_TIP_2},             // SCMFW_WIDGET_GLASSES
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   658
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,    209,  217,   122,   133, SPR_ARROW_RIGHT,         STR_FACE_GLASSES_TIP_2},             // SCMFW_WIDGET_GLASSES_R
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   659
{   WIDGETS_END},
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   660
};
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   661
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   662
class SelectCompanyManagerFaceWindow : public Window
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   663
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   664
	CompanyManagerFace face; ///< company manager face bits
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   665
	bool advanced; ///< advanced company manager face selection window
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   666
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   667
	GenderEthnicity ge;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   668
	bool is_female;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   669
	bool is_moust_male;
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   670
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   671
	/**
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   672
	 * Names of the widgets. Keep them in the same order as in the widget array.
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   673
	 * Do not change the order of the widgets from SCMFW_WIDGET_HAS_MOUSTACHE_EARRING to SCMFW_WIDGET_GLASSES_R,
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   674
	 * this order is needed for the WE_CLICK event of DrawFaceStringLabel().
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   675
	 */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   676
	enum SelectCompanyManagerFaceWidgets {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   677
		SCMFW_WIDGET_CLOSEBOX = 0,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   678
		SCMFW_WIDGET_CAPTION,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   679
		SCMFW_WIDGET_TOGGLE_LARGE_SMALL,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   680
		SCMFW_WIDGET_SELECT_FACE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   681
		SCMFW_WIDGET_CANCEL,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   682
		SCMFW_WIDGET_ACCEPT,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   683
		SCMFW_WIDGET_MALE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   684
		SCMFW_WIDGET_FEMALE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   685
		SCMFW_WIDGET_RANDOM_NEW_FACE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   686
		SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   687
		/* from here is the advanced company manager face selection window */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   688
		SCMFW_WIDGET_LOAD,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   689
		SCMFW_WIDGET_FACECODE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   690
		SCMFW_WIDGET_SAVE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   691
		SCMFW_WIDGET_ETHNICITY_EUR,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   692
		SCMFW_WIDGET_ETHNICITY_AFR,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   693
		SCMFW_WIDGET_HAS_MOUSTACHE_EARRING,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   694
		SCMFW_WIDGET_HAS_GLASSES,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   695
		SCMFW_WIDGET_EYECOLOUR_L,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   696
		SCMFW_WIDGET_EYECOLOUR,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   697
		SCMFW_WIDGET_EYECOLOUR_R,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   698
		SCMFW_WIDGET_CHIN_L,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   699
		SCMFW_WIDGET_CHIN,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   700
		SCMFW_WIDGET_CHIN_R,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   701
		SCMFW_WIDGET_EYEBROWS_L,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   702
		SCMFW_WIDGET_EYEBROWS,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   703
		SCMFW_WIDGET_EYEBROWS_R,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   704
		SCMFW_WIDGET_LIPS_MOUSTACHE_L,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   705
		SCMFW_WIDGET_LIPS_MOUSTACHE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   706
		SCMFW_WIDGET_LIPS_MOUSTACHE_R,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   707
		SCMFW_WIDGET_NOSE_L,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   708
		SCMFW_WIDGET_NOSE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   709
		SCMFW_WIDGET_NOSE_R,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   710
		SCMFW_WIDGET_HAIR_L,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   711
		SCMFW_WIDGET_HAIR,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   712
		SCMFW_WIDGET_HAIR_R,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   713
		SCMFW_WIDGET_JACKET_L,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   714
		SCMFW_WIDGET_JACKET,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   715
		SCMFW_WIDGET_JACKET_R,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   716
		SCMFW_WIDGET_COLLAR_L,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   717
		SCMFW_WIDGET_COLLAR,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   718
		SCMFW_WIDGET_COLLAR_R,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   719
		SCMFW_WIDGET_TIE_EARRING_L,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   720
		SCMFW_WIDGET_TIE_EARRING,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   721
		SCMFW_WIDGET_TIE_EARRING_R,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   722
		SCMFW_WIDGET_GLASSES_L,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   723
		SCMFW_WIDGET_GLASSES,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   724
		SCMFW_WIDGET_GLASSES_R,
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   725
	};
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   726
	/**
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   727
	 * Draw dynamic a label to the left of the button and a value in the button
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   728
	 *
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   729
	 * @param widget_index   index of this widget in the window
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   730
	 * @param str            the label which will be draw
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   731
	 * @param val            the value which will be draw
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   732
	 * @param is_bool_widget is it a bool button
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   733
	 */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   734
	void DrawFaceStringLabel(byte widget_index, StringID str, uint8 val, bool is_bool_widget)
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   735
	{
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   736
		/* Write the label in gold (0x2) to the left of the button. */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   737
		DrawStringRightAligned(this->widget[widget_index].left - (is_bool_widget ? 5 : 14), this->widget[widget_index].top + 1, str, TC_GOLD);
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   738
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   739
		if (!this->IsWidgetDisabled(widget_index)) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   740
			if (is_bool_widget) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   741
				/* if it a bool button write yes or no */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   742
				str = (val != 0) ? STR_FACE_YES : STR_FACE_NO;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   743
			} else {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   744
				/* else write the value + 1 */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   745
				SetDParam(0, val + 1);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   746
				str = STR_JUST_INT;
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   747
			}
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   748
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   749
			/* Draw the value/bool in white (0xC). If the button clicked adds 1px to x and y text coordinates (IsWindowWidgetLowered()). */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   750
			DrawStringCentered(this->widget[widget_index].left + (this->widget[widget_index].right - this->widget[widget_index].left) / 2 +
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   751
				this->IsWidgetLowered(widget_index), this->widget[widget_index].top + 1 + this->IsWidgetLowered(widget_index), str, TC_WHITE);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   752
		}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   753
	}
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   754
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   755
	void UpdateData()
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   756
	{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   757
		this->ge = (GenderEthnicity)GB(this->face, _cmf_info[CMFV_GEN_ETHN].offset, _cmf_info[CMFV_GEN_ETHN].length); // get the gender and ethnicity
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   758
		this->is_female = HasBit(this->ge, GENDER_FEMALE); // get the gender: 0 == male and 1 == female
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   759
		this->is_moust_male = !is_female && GetCompanyManagerFaceBits(this->face, CMFV_HAS_MOUSTACHE, this->ge) != 0; // is a male face with moustache
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   760
	}
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   761
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   762
public:
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   763
	SelectCompanyManagerFaceWindow(const WindowDesc *desc, Window *parent, bool advanced, int top, int left) : Window(desc, parent->window_number)
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   764
	{
9241
93e9c7c074cc (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 9237
diff changeset
   765
		this->parent = parent;
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   766
		this->caption_color = this->window_number;
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   767
		this->face = GetCompany((CompanyID)this->window_number)->face;
9203
082fbf0500c4 (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: 9198
diff changeset
   768
		this->advanced = advanced;
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   769
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   770
		this->UpdateData();
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   771
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   772
		/* Check if repositioning from default is required */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   773
		if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   774
			this->top = top;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   775
			this->left = left;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   776
		}
9333
2da01b3b71d8 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 9332
diff changeset
   777
2da01b3b71d8 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 9332
diff changeset
   778
		this->FindWindowPlacementAndResize(desc);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   779
	}
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   780
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   781
	virtual void OnPaint()
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   782
	{
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   783
		/* lower the non-selected gender button */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   784
		this->SetWidgetLoweredState(SCMFW_WIDGET_MALE,  !this->is_female);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   785
		this->SetWidgetLoweredState(SCMFW_WIDGET_FEMALE, this->is_female);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   786
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   787
		/* advanced company manager face selection window */
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   788
		if (this->advanced) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   789
			/* lower the non-selected ethnicity button */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   790
			this->SetWidgetLoweredState(SCMFW_WIDGET_ETHNICITY_EUR, !HasBit(this->ge, ETHNICITY_BLACK));
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   791
			this->SetWidgetLoweredState(SCMFW_WIDGET_ETHNICITY_AFR,  HasBit(this->ge, ETHNICITY_BLACK));
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   792
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   793
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   794
			/* Disable dynamically the widgets which CompanyManagerFaceVariable has less than 2 options
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   795
			* (or in other words you haven't any choice).
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   796
			* If the widgets depend on a HAS-variable and this is false the widgets will be disabled, too. */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   797
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   798
			/* Eye colour buttons */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   799
			this->SetWidgetsDisabledState(_cmf_info[CMFV_EYE_COLOUR].valid_values[this->ge] < 2,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   800
				SCMFW_WIDGET_EYECOLOUR, SCMFW_WIDGET_EYECOLOUR_L, SCMFW_WIDGET_EYECOLOUR_R, WIDGET_LIST_END);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   801
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   802
			/* Chin buttons */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   803
			this->SetWidgetsDisabledState(_cmf_info[CMFV_CHIN].valid_values[this->ge] < 2,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   804
				SCMFW_WIDGET_CHIN, SCMFW_WIDGET_CHIN_L, SCMFW_WIDGET_CHIN_R, WIDGET_LIST_END);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   805
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   806
			/* Eyebrows buttons */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   807
			this->SetWidgetsDisabledState(_cmf_info[CMFV_EYEBROWS].valid_values[this->ge] < 2,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   808
				SCMFW_WIDGET_EYEBROWS, SCMFW_WIDGET_EYEBROWS_L, SCMFW_WIDGET_EYEBROWS_R, WIDGET_LIST_END);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   809
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   810
			/* Lips or (if it a male face with a moustache) moustache buttons */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   811
			this->SetWidgetsDisabledState(_cmf_info[this->is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS].valid_values[this->ge] < 2,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   812
				SCMFW_WIDGET_LIPS_MOUSTACHE, SCMFW_WIDGET_LIPS_MOUSTACHE_L, SCMFW_WIDGET_LIPS_MOUSTACHE_R, WIDGET_LIST_END);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   813
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   814
			/* Nose buttons | male faces with moustache haven't any nose options */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   815
			this->SetWidgetsDisabledState(_cmf_info[CMFV_NOSE].valid_values[this->ge] < 2 || this->is_moust_male,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   816
				SCMFW_WIDGET_NOSE, SCMFW_WIDGET_NOSE_L, SCMFW_WIDGET_NOSE_R, WIDGET_LIST_END);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   817
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   818
			/* Hair buttons */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   819
			this->SetWidgetsDisabledState(_cmf_info[CMFV_HAIR].valid_values[this->ge] < 2,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   820
				SCMFW_WIDGET_HAIR, SCMFW_WIDGET_HAIR_L, SCMFW_WIDGET_HAIR_R, WIDGET_LIST_END);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   821
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   822
			/* Jacket buttons */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   823
			this->SetWidgetsDisabledState(_cmf_info[CMFV_JACKET].valid_values[this->ge] < 2,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   824
				SCMFW_WIDGET_JACKET, SCMFW_WIDGET_JACKET_L, SCMFW_WIDGET_JACKET_R, WIDGET_LIST_END);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   825
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   826
			/* Collar buttons */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   827
			this->SetWidgetsDisabledState(_cmf_info[CMFV_COLLAR].valid_values[this->ge] < 2,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   828
				SCMFW_WIDGET_COLLAR, SCMFW_WIDGET_COLLAR_L, SCMFW_WIDGET_COLLAR_R, WIDGET_LIST_END);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   829
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   830
			/* Tie/earring buttons | female faces without earring haven't any earring options */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   831
			this->SetWidgetsDisabledState(_cmf_info[CMFV_TIE_EARRING].valid_values[this->ge] < 2 ||
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   832
					(this->is_female && GetCompanyManagerFaceBits(this->face, CMFV_HAS_TIE_EARRING, this->ge) == 0),
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   833
				SCMFW_WIDGET_TIE_EARRING, SCMFW_WIDGET_TIE_EARRING_L, SCMFW_WIDGET_TIE_EARRING_R, WIDGET_LIST_END);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   834
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   835
			/* Glasses buttons | faces without glasses haven't any glasses options */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   836
			this->SetWidgetsDisabledState(_cmf_info[CMFV_GLASSES].valid_values[this->ge] < 2 || GetCompanyManagerFaceBits(this->face, CMFV_HAS_GLASSES, this->ge) == 0,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   837
				SCMFW_WIDGET_GLASSES, SCMFW_WIDGET_GLASSES_L, SCMFW_WIDGET_GLASSES_R, WIDGET_LIST_END);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   838
		}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   839
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9252
diff changeset
   840
		this->DrawWidgets();
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   841
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   842
		/* Draw dynamic button value and labels for the advanced company manager face selection window */
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   843
		if (this->advanced) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   844
			if (this->is_female) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   845
				/* Only for female faces */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   846
				this->DrawFaceStringLabel(SCMFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_EARRING,   GetCompanyManagerFaceBits(this->face, CMFV_HAS_TIE_EARRING, this->ge), true );
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   847
				this->DrawFaceStringLabel(SCMFW_WIDGET_TIE_EARRING,           STR_FACE_EARRING,   GetCompanyManagerFaceBits(this->face, CMFV_TIE_EARRING,     this->ge), false);
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   848
			} else {
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   849
				/* Only for male faces */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   850
				this->DrawFaceStringLabel(SCMFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_MOUSTACHE, GetCompanyManagerFaceBits(this->face, CMFV_HAS_MOUSTACHE,   this->ge), true );
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   851
				this->DrawFaceStringLabel(SCMFW_WIDGET_TIE_EARRING,           STR_FACE_TIE,       GetCompanyManagerFaceBits(this->face, CMFV_TIE_EARRING,     this->ge), false);
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   852
			}
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   853
			if (this->is_moust_male) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   854
				/* Only for male faces with moustache */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   855
				this->DrawFaceStringLabel(SCMFW_WIDGET_LIPS_MOUSTACHE,        STR_FACE_MOUSTACHE, GetCompanyManagerFaceBits(this->face, CMFV_MOUSTACHE,       this->ge), false);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   856
			} else {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   857
				/* Only for female faces or male faces without moustache */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   858
				this->DrawFaceStringLabel(SCMFW_WIDGET_LIPS_MOUSTACHE,        STR_FACE_LIPS,      GetCompanyManagerFaceBits(this->face, CMFV_LIPS,            this->ge), false);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   859
			}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   860
			/* For all faces */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   861
			this->DrawFaceStringLabel(SCMFW_WIDGET_HAS_GLASSES,           STR_FACE_GLASSES,     GetCompanyManagerFaceBits(this->face, CMFV_HAS_GLASSES,     this->ge), true );
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   862
			this->DrawFaceStringLabel(SCMFW_WIDGET_HAIR,                  STR_FACE_HAIR,        GetCompanyManagerFaceBits(this->face, CMFV_HAIR,            this->ge), false);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   863
			this->DrawFaceStringLabel(SCMFW_WIDGET_EYEBROWS,              STR_FACE_EYEBROWS,    GetCompanyManagerFaceBits(this->face, CMFV_EYEBROWS,        this->ge), false);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   864
			this->DrawFaceStringLabel(SCMFW_WIDGET_EYECOLOUR,             STR_FACE_EYECOLOUR,   GetCompanyManagerFaceBits(this->face, CMFV_EYE_COLOUR,      this->ge), false);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   865
			this->DrawFaceStringLabel(SCMFW_WIDGET_GLASSES,               STR_FACE_GLASSES,     GetCompanyManagerFaceBits(this->face, CMFV_GLASSES,         this->ge), false);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   866
			this->DrawFaceStringLabel(SCMFW_WIDGET_NOSE,                  STR_FACE_NOSE,        GetCompanyManagerFaceBits(this->face, CMFV_NOSE,            this->ge), false);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   867
			this->DrawFaceStringLabel(SCMFW_WIDGET_CHIN,                  STR_FACE_CHIN,        GetCompanyManagerFaceBits(this->face, CMFV_CHIN,            this->ge), false);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   868
			this->DrawFaceStringLabel(SCMFW_WIDGET_JACKET,                STR_FACE_JACKET,      GetCompanyManagerFaceBits(this->face, CMFV_JACKET,          this->ge), false);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   869
			this->DrawFaceStringLabel(SCMFW_WIDGET_COLLAR,                STR_FACE_COLLAR,      GetCompanyManagerFaceBits(this->face, CMFV_COLLAR,          this->ge), false);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   870
		}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   871
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   872
		/* Draw the company manager face picture */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   873
		DrawCompanyManagerFace(this->face, GetCompany((CompanyID)this->window_number)->colour, 2, 16);
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
   874
	}
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   875
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   876
	virtual void OnClick(Point pt, int widget)
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   877
	{
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   878
		switch (widget) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   879
			/* Toggle size, advanced/simple face selection */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   880
			case SCMFW_WIDGET_TOGGLE_LARGE_SMALL:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   881
			case SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON: {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   882
				DoCommandP(0, 0, this->face, NULL, CMD_SET_COMPANY_MANAGER_FACE);
9241
93e9c7c074cc (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 9237
diff changeset
   883
93e9c7c074cc (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 9237
diff changeset
   884
				/* Backup some data before deletion */
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   885
				int oldtop = this->top;     ///< current top position of the window before closing it
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   886
				int oldleft = this->left;   ///< current top position of the window before closing it
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   887
				bool adv = !this->advanced;
9241
93e9c7c074cc (svn r13107) -Codechange: make NetworkCompanyPasswordWindow and SelectPlayerFaceWindow children of PlayerCompanyWindow.
glx
parents: 9237
diff changeset
   888
				Window *parent = this->parent;
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   889
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   890
				delete this;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   891
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   892
				/* Open up the (toggled size) Face selection window at the same position as the previous */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   893
				DoSelectCompanyManagerFace(parent, adv, oldtop, oldleft);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   894
			} break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   895
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   896
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   897
			/* OK button */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   898
			case SCMFW_WIDGET_ACCEPT:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   899
				DoCommandP(0, 0, this->face, NULL, CMD_SET_COMPANY_MANAGER_FACE);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   900
				/* Fall-Through */
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   901
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   902
			/* Cancel button */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   903
			case SCMFW_WIDGET_CANCEL:
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   904
				delete this;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   905
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   906
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   907
			/* Load button */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   908
			case SCMFW_WIDGET_LOAD:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   909
				this->face = _company_manager_face;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   910
				ScaleAllCompanyManagerFaceBits(this->face);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   911
				ShowErrorMessage(INVALID_STRING_ID, STR_FACE_LOAD_DONE, 0, 0);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   912
				this->UpdateData();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   913
				this->SetDirty();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   914
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   915
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   916
			/* 'Company manager face number' button, view and/or set company manager face number */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   917
			case SCMFW_WIDGET_FACECODE:
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   918
				SetDParam(0, this->face);
10145
849ba8b8626b (svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents: 10010
diff changeset
   919
				ShowQueryString(STR_JUST_INT, STR_FACE_FACECODE_CAPTION, 10 + 1, 0, this, CS_NUMERAL, QSF_NONE);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   920
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   921
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   922
			/* Save button */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   923
			case SCMFW_WIDGET_SAVE:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   924
				_company_manager_face = this->face;
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   925
				ShowErrorMessage(INVALID_STRING_ID, STR_FACE_SAVE_DONE, 0, 0);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   926
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   927
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   928
			/* Toggle gender (male/female) button */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   929
			case SCMFW_WIDGET_MALE:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   930
			case SCMFW_WIDGET_FEMALE:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   931
				SetCompanyManagerFaceBits(this->face, CMFV_GENDER, this->ge, widget - SCMFW_WIDGET_MALE);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   932
				ScaleAllCompanyManagerFaceBits(this->face);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   933
				this->UpdateData();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   934
				this->SetDirty();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   935
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   936
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   937
			/* Randomize face button */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   938
			case SCMFW_WIDGET_RANDOM_NEW_FACE:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   939
				RandomCompanyManagerFaceBits(this->face, this->ge, this->advanced);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   940
				this->UpdateData();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   941
				this->SetDirty();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   942
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   943
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   944
			/* Toggle ethnicity (european/african) button */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   945
			case SCMFW_WIDGET_ETHNICITY_EUR:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   946
			case SCMFW_WIDGET_ETHNICITY_AFR:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   947
				SetCompanyManagerFaceBits(this->face, CMFV_ETHNICITY, this->ge, widget - SCMFW_WIDGET_ETHNICITY_EUR);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   948
				ScaleAllCompanyManagerFaceBits(this->face);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   949
				this->UpdateData();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   950
				this->SetDirty();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   951
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   952
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   953
			default:
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   954
				/* For all buttons from SCMFW_WIDGET_HAS_MOUSTACHE_EARRING to SCMFW_WIDGET_GLASSES_R is the same function.
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   955
				* Therefor is this combined function.
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   956
				* First it checks which CompanyManagerFaceVariable will be change and then
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   957
				* a: invert the value for boolean variables
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   958
				* or b: it checks inside of IncreaseCompanyManagerFaceBits() if a left (_L) butten is pressed and then decrease else increase the variable */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   959
				if (this->advanced && widget >= SCMFW_WIDGET_HAS_MOUSTACHE_EARRING && widget <= SCMFW_WIDGET_GLASSES_R) {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   960
					CompanyManagerFaceVariable cmfv; // which CompanyManagerFaceVariable shall be edited
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   961
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   962
					if (widget < SCMFW_WIDGET_EYECOLOUR_L) { // Bool buttons
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   963
						switch (widget - SCMFW_WIDGET_HAS_MOUSTACHE_EARRING) {
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   964
							default: NOT_REACHED();
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   965
							case 0: cmfv = this->is_female ? CMFV_HAS_TIE_EARRING : CMFV_HAS_MOUSTACHE; break; // Has earring/moustache button
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   966
							case 1: cmfv = CMFV_HAS_GLASSES; break; // Has glasses button
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   967
						}
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   968
						SetCompanyManagerFaceBits(this->face, cmfv, this->ge, !GetCompanyManagerFaceBits(this->face, cmfv, this->ge));
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   969
						ScaleAllCompanyManagerFaceBits(this->face);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   970
					} else { // Value buttons
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   971
						switch ((widget - SCMFW_WIDGET_EYECOLOUR_L) / 3) {
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   972
							default: NOT_REACHED();
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   973
							case 0: cmfv = CMFV_EYE_COLOUR; break;  // Eye colour buttons
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   974
							case 1: cmfv = CMFV_CHIN; break;        // Chin buttons
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   975
							case 2: cmfv = CMFV_EYEBROWS; break;    // Eyebrows buttons
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   976
							case 3: cmfv = this->is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS; break; // Moustache or lips buttons
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   977
							case 4: cmfv = CMFV_NOSE; break;        // Nose buttons
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   978
							case 5: cmfv = CMFV_HAIR; break;        // Hair buttons
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   979
							case 6: cmfv = CMFV_JACKET; break;      // Jacket buttons
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   980
							case 7: cmfv = CMFV_COLLAR; break;      // Collar buttons
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   981
							case 8: cmfv = CMFV_TIE_EARRING; break; // Tie/earring buttons
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   982
							case 9: cmfv = CMFV_GLASSES; break;     // Glasses buttons
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   983
						}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   984
						/* 0 == left (_L), 1 == middle or 2 == right (_R) - button click */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   985
						IncreaseCompanyManagerFaceBits(this->face, cmfv, this->ge, (((widget - SCMFW_WIDGET_EYECOLOUR_L) % 3) != 0) ? 1 : -1);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   986
					}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   987
					this->UpdateData();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   988
					this->SetDirty();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   989
				}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   990
				break;
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   991
		}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   992
	}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   993
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   994
	virtual void OnQueryTextFinished(char *str)
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   995
	{
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   996
		if (str == NULL) return;
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
   997
		/* Set a new company manager face number */
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   998
		if (!StrEmpty(str)) {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
   999
			this->face = strtoul(str, NULL, 10);
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1000
			ScaleAllCompanyManagerFaceBits(this->face);
9198
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1001
			ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_SET, 0, 0);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1002
			this->UpdateData();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1003
			this->SetDirty();
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1004
		} else {
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1005
			ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_ERR, 0, 0);
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1006
		}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1007
	}
7cb23ea1b7b8 (svn r13064) -Codechange: make a class of the SelectPlayerFaceWindow.
glx
parents: 9164
diff changeset
  1008
};
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1009
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1010
/** normal/simple company manager face selection window description */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1011
static const WindowDesc _select_company_manager_face_desc = {
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1012
	WDP_AUTO, WDP_AUTO, 190, 163, 190, 163,
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1013
	WC_COMPANY_MANAGER_FACE, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1014
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1015
	_select_company_manager_face_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1016
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1017
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1018
/** advanced company manager face selection window description */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1019
static const WindowDesc _select_company_manager_face_adv_desc = {
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1020
	WDP_AUTO, WDP_AUTO, 220, 220, 220, 220,
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1021
	WC_COMPANY_MANAGER_FACE, WC_NONE,
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1022
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1023
	_select_company_manager_face_adv_widgets,
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1024
};
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1025
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1026
/**
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1027
 * Open the simple/advanced company manager face selection window
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1028
 *
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1029
 * @param parent the parent company window
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1030
 * @param adv    simple or advanced face selection window
8867
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
  1031
 * @param top    previous top position of the window
f6019b3c193b (svn r12634) -Feature: Financial and Player Selection Face windows are now remembering their position when toggling sizes
belugas
parents: 8515
diff changeset
  1032
 * @param left   previous left position of the window
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1033
 */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1034
static void DoSelectCompanyManagerFace(Window *parent, bool adv, int top, int left)
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1035
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1036
	if (!IsValidCompanyID((CompanyID)parent->window_number)) return;
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1037
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1038
	if (BringWindowToFrontById(WC_COMPANY_MANAGER_FACE, parent->window_number)) return;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1039
	new SelectCompanyManagerFaceWindow(adv ? &_select_company_manager_face_adv_desc : &_select_company_manager_face_desc, parent, adv, top, left); // simple or advanced window
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1040
}
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1041
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1042
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1043
/* Names of the widgets. Keep them in the same order as in the widget array */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1044
enum CompanyWindowWidgets {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1045
	CW_WIDGET_CLOSEBOX = 0,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1046
	CW_WIDGET_CAPTION,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1047
	CW_WIDGET_FACE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1048
	CW_WIDGET_NEW_FACE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1049
	CW_WIDGET_COLOR_SCHEME,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1050
	CW_WIDGET_PRESIDENT_NAME,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1051
	CW_WIDGET_COMPANY_NAME,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1052
	CW_WIDGET_BUILD_VIEW_HQ,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1053
	CW_WIDGET_RELOCATE_HQ,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1054
	CW_WIDGET_BUY_SHARE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1055
	CW_WIDGET_SELL_SHARE,
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1056
	CW_WIDGET_COMPANY_PASSWORD,
5273
d9f707aa36a6 (svn r7415) -Codechange: Don't use typedef enum for simple widget enumerators when we will never use
Darkvater
parents: 5070
diff changeset
  1057
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1058
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1059
static const Widget _company_widgets[] = {
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1060
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1061
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   359,     0,    13, STR_7001,                          STR_018C_WINDOW_TITLE_DRAG_THIS},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1062
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   359,    14,   157, 0x0,                               STR_NULL},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1063
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,    89,   158,   169, STR_7004_NEW_FACE,                 STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1064
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,    90,   179,   158,   169, STR_7005_COLOR_SCHEME,             STR_7031_CHANGE_THE_COMPANY_VEHICLE},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1065
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   180,   269,   158,   169, STR_7009_PRESIDENT_NAME,           STR_7032_CHANGE_THE_PRESIDENT_S},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1066
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   270,   359,   158,   169, STR_7008_COMPANY_NAME,             STR_7033_CHANGE_THE_COMPANY_NAME},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1067
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,   266,   355,    18,    29, STR_7072_VIEW_HQ,                  STR_7070_BUILD_COMPANY_HEADQUARTERS},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1068
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,   266,   355,    32,    43, STR_RELOCATE_HQ,                   STR_RELOCATE_COMPANY_HEADQUARTERS},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1069
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,   179,   158,   169, STR_7077_BUY_25_SHARE_IN_COMPANY,  STR_7079_BUY_25_SHARE_IN_THIS_COMPANY},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1070
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   180,   359,   158,   169, STR_7078_SELL_25_SHARE_IN_COMPANY, STR_707A_SELL_25_SHARE_IN_THIS_COMPANY},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1071
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   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
  1072
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1073
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1074
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1075
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1076
/**
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1077
 * Draws text "Vehicles:" and number of all vehicle types, or "(none)"
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1078
 * @param company ID of company to print statistics of
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1079
 */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1080
static void DrawCompanyVehiclesAmount(CompanyID company)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1081
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1082
	const int x = 110;
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1083
	int y = 63;
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1084
	const Vehicle *v;
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1085
	uint train = 0;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1086
	uint road  = 0;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1087
	uint air   = 0;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1088
	uint ship  = 0;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
  1089
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
  1090
	DrawString(x, y, STR_7039_VEHICLES, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1091
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1092
	FOR_ALL_VEHICLES(v) {
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1093
		if (v->owner == company) {
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1094
			switch (v->type) {
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
  1095
				case VEH_TRAIN:    if (IsFrontEngine(v)) train++; break;
6857
60130753e595 (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 6769
diff changeset
  1096
				case VEH_ROAD:     if (IsRoadVehFront(v)) road++; break;
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
  1097
				case VEH_AIRCRAFT: if (IsNormalAircraft(v)) air++; break;
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
  1098
				case VEH_SHIP:     ship++; break;
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1099
				default: break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1100
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1101
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1102
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1103
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6352
diff changeset
  1104
	if (train + road + air + ship == 0) {
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
  1105
		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
  1106
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1107
		if (train != 0) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1108
			SetDParam(0, train);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
  1109
			DrawString(x + 70, y, STR_TRAINS, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1110
			y += 10;
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1113
		if (road != 0) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1114
			SetDParam(0, road);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
  1115
			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
  1116
			y += 10;
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1119
		if (air != 0) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1120
			SetDParam(0, air);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
  1121
			DrawString(x + 70, y, STR_AIRCRAFT, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1122
			y += 10;
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1125
		if (ship != 0) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1126
			SetDParam(0, ship);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7734
diff changeset
  1127
			DrawString(x + 70, y, STR_SHIPS, TC_FROMSTRING);
0
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1131
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1132
int GetAmountOwnedBy(const Company *c, Owner owner)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1133
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1134
	return (c->share_owners[0] == owner) +
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1135
				 (c->share_owners[1] == owner) +
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1136
				 (c->share_owners[2] == owner) +
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1137
				 (c->share_owners[3] == owner);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1138
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1139
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1140
/**
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1141
 * Draws list of all companies with shares
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1142
 * @param c pointer to the Company structure
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1143
 */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1144
static void DrawCompanyOwnerText(const Company *c)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1145
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1146
	const Company *c2;
7884
46547eab1ac8 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
  1147
	uint num = 0;
46547eab1ac8 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
  1148
	const byte height = GetCharacterHeight(FS_NORMAL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1149
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1150
	FOR_ALL_COMPANIES(c2) {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1151
		uint amt = GetAmountOwnedBy(c, c2->index);
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2498
diff changeset
  1152
		if (amt != 0) {
7884
46547eab1ac8 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
  1153
			SetDParam(0, amt * 25);
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1154
			SetDParam(1, c2->index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1155
7884
46547eab1ac8 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
  1156
			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
  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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1160
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1161
/**
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1162
 * Window with general information about a company
7734
627817106768 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium
parents: 7521
diff changeset
  1163
 */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1164
struct CompanyWindow : Window
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1165
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1166
	CompanyWindowWidgets query_widget;
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1167
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1168
	CompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1169
	{
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1170
		this->caption_color = this->window_number;
9333
2da01b3b71d8 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 9332
diff changeset
  1171
		this->FindWindowPlacementAndResize(desc);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1172
	}
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1173
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1174
	virtual void OnPaint()
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1175
	{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1176
		const Company *c = GetCompany((CompanyID)this->window_number);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1177
		bool local = this->window_number == _local_company;
7934
c1b897797d7a (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz
parents: 7932
diff changeset
  1178
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1179
		this->SetWidgetHiddenState(CW_WIDGET_NEW_FACE,       !local);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1180
		this->SetWidgetHiddenState(CW_WIDGET_COLOR_SCHEME,   !local);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1181
		this->SetWidgetHiddenState(CW_WIDGET_PRESIDENT_NAME, !local);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1182
		this->SetWidgetHiddenState(CW_WIDGET_COMPANY_NAME,   !local);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1183
		this->widget[CW_WIDGET_BUILD_VIEW_HQ].data = (local && c->location_of_HQ == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1184
		if (local && c->location_of_HQ != 0) this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1185
		this->SetWidgetDisabledState(CW_WIDGET_BUILD_VIEW_HQ, !local && c->location_of_HQ == 0);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1186
		this->SetWidgetHiddenState(CW_WIDGET_RELOCATE_HQ,      !local || c->location_of_HQ == 0);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1187
		this->SetWidgetHiddenState(CW_WIDGET_BUY_SHARE,        local);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1188
		this->SetWidgetHiddenState(CW_WIDGET_SELL_SHARE,       local);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1189
		this->SetWidgetHiddenState(CW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1190
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1191
		if (!local) {
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9412
diff changeset
  1192
			if (_settings_game.economy.allow_shares) { // Shares are allowed
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1193
				/* If all shares are owned by someone (none by nobody), disable buy button */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1194
				this->SetWidgetDisabledState(CW_WIDGET_BUY_SHARE, GetAmountOwnedBy(c, INVALID_OWNER) == 0 ||
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1195
						/* Only 25% left to buy. If the company is human, disable buying it up.. TODO issues! */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1196
						(GetAmountOwnedBy(c, INVALID_OWNER) == 1 && !c->is_ai) ||
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1197
						/* Spectators cannot do anything of course */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1198
						_local_company == COMPANY_SPECTATOR);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1199
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1200
				/* If the company doesn't own any shares, disable sell button */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1201
				this->SetWidgetDisabledState(CW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(c, _local_company) == 0) ||
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1202
						/* Spectators cannot do anything of course */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1203
						_local_company == COMPANY_SPECTATOR);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1204
			} else { // Shares are not allowed, disable buy/sell buttons
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1205
				this->DisableWidget(CW_WIDGET_BUY_SHARE);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1206
				this->DisableWidget(CW_WIDGET_SELL_SHARE);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1207
			}
773
a376cebd3dc0 (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
  1208
		}
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
  1209
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1210
		SetDParam(0, c->index);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1211
		SetDParam(1, c->index);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1212
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9252
diff changeset
  1213
		this->DrawWidgets();
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1214
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1215
		/* Company manager's face */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1216
		DrawCompanyManagerFace(c->face, c->colour, 2, 16);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1217
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1218
		/* "xxx (Manager)" */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1219
		SetDParam(0, c->index);
9913
d9ce89020cc0 (svn r14063) -Codechange: replace some "magic" constants with enumified constants.
rubidium
parents: 9878
diff changeset
  1220
		DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, MAX_LENGTH_PRESIDENT_NAME_PIXELS);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1221
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1222
		/* "Inaugurated:" */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1223
		SetDParam(0, c->inaugurated_year);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1224
		DrawString(110, 23, STR_7038_INAUGURATED, TC_FROMSTRING);
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1225
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1226
		/* "Colour scheme:" */
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1227
		DrawString(110, 43, STR_7006_COLOR_SCHEME, TC_FROMSTRING);
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1228
		/* Draw company-colour bus */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1229
		DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOR(c->index), 215, 44);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1230
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1231
		/* "Vehicles:" */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1232
		DrawCompanyVehiclesAmount((CompanyID)this->window_number);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1233
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1234
		/* "Company value:" */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1235
		SetDParam(0, CalculateCompanyValue(c));
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1236
		DrawString(110, 106, STR_7076_COMPANY_VALUE, TC_FROMSTRING);
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1238
		/* Shares list */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1239
		DrawCompanyOwnerText(c);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1240
	}
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1241
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1242
	virtual void OnClick(Point pt, int widget)
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1243
	{
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1244
		switch (widget) {
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1245
			case CW_WIDGET_NEW_FACE: DoSelectCompanyManagerFace(this, false); break;
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1246
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1247
			case CW_WIDGET_COLOR_SCHEME:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1248
				if (BringWindowToFrontById(WC_COMPANY_COLOR, this->window_number)) break;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1249
				new SelectCompanyLiveryWindow(&_select_company_livery_desc, (CompanyID)this->window_number);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1250
				break;
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1251
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1252
			case CW_WIDGET_PRESIDENT_NAME:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1253
				this->query_widget = CW_WIDGET_PRESIDENT_NAME;
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1254
				SetDParam(0, this->window_number);
10209
a1e7417bf1b7 (svn r14423) -Codechange: also do r14221 for the strings.
rubidium
parents: 10208
diff changeset
  1255
				ShowQueryString(STR_PRESIDENT_NAME, STR_700B_PRESIDENT_S_NAME, MAX_LENGTH_PRESIDENT_NAME_BYTES, MAX_LENGTH_PRESIDENT_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1256
				break;
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1257
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1258
			case CW_WIDGET_COMPANY_NAME:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1259
				this->query_widget = CW_WIDGET_COMPANY_NAME;
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1260
				SetDParam(0, this->window_number);
10148
ad8e8a65f6a2 (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents: 10145
diff changeset
  1261
				ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, MAX_LENGTH_COMPANY_NAME_BYTES, MAX_LENGTH_COMPANY_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1262
				break;
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1263
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1264
			case CW_WIDGET_BUILD_VIEW_HQ: {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1265
				TileIndex tile = GetCompany((CompanyID)this->window_number)->location_of_HQ;
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1266
				if (tile == 0) {
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1267
					if ((byte)this->window_number != _local_company) return;
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1268
					SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this);
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1269
					SetTileSelectSize(2, 2);
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1270
					this->LowerWidget(CW_WIDGET_BUILD_VIEW_HQ);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1271
					this->InvalidateWidget(CW_WIDGET_BUILD_VIEW_HQ);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1272
				} else {
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1273
					if (_ctrl_pressed) {
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1274
						ShowExtraViewPortWindow(tile);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1275
					} else {
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1276
						ScrollMainWindowToTile(tile);
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1277
					}
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1278
				}
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1279
				break;
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1280
			}
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1281
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1282
			case CW_WIDGET_RELOCATE_HQ:
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1283
				SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this);
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1284
				SetTileSelectSize(2, 2);
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1285
				this->LowerWidget(CW_WIDGET_RELOCATE_HQ);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1286
				this->InvalidateWidget(CW_WIDGET_RELOCATE_HQ);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1287
				break;
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1288
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1289
			case CW_WIDGET_BUY_SHARE:
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1290
				DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS));
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1291
				break;
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1292
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1293
			case CW_WIDGET_SELL_SHARE:
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1294
				DoCommandP(0, this->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN));
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1295
				break;
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1296
7998
9cf9f9153262 (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents: 7997
diff changeset
  1297
#ifdef ENABLE_NETWORK
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1298
			case CW_WIDGET_COMPANY_PASSWORD:
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1299
				if (this->window_number == _local_company) ShowNetworkCompanyPasswordWindow(this);
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1300
				break;
7998
9cf9f9153262 (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents: 7997
diff changeset
  1301
#endif /* ENABLE_NETWORK */
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1302
		}
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1303
	}
4808
07bc43331422 (svn r6730) Fix: Make Build HQ and Relocate HQ buttons of Player window behave as normal placement buttons, and not as push buttons.
belugas
parents: 4805
diff changeset
  1304
9412
163c465bf250 (svn r13323) -Codechange: scrollbars are not refresh counters
peter1138
parents: 9358
diff changeset
  1305
	virtual void OnHundredthTick()
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1306
	{
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1307
		/* redraw the window every now and then */
9412
163c465bf250 (svn r13323) -Codechange: scrollbars are not refresh counters
peter1138
parents: 9358
diff changeset
  1308
		this->SetDirty();
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1309
	}
4746
2951243a88de (svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents: 4744
diff changeset
  1310
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1311
	virtual void OnPlaceObject(Point pt, TileIndex tile)
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1312
	{
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1313
		if (DoCommandP(tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1314
			ResetObjectToPlace();
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1315
			this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1316
			this->RaiseButtons();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1317
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1318
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1319
	virtual void OnPlaceObjectAbort()
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1320
	{
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1321
		this->RaiseButtons();
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1322
	}
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1323
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1324
	virtual void OnQueryTextFinished(char *str)
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1325
	{
10148
ad8e8a65f6a2 (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz
parents: 10145
diff changeset
  1326
		if (str == NULL) return;
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1327
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1328
		_cmd_text = str;
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1329
		switch (this->query_widget) {
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1330
			default: NOT_REACHED();
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1331
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1332
			case CW_WIDGET_PRESIDENT_NAME:
10151
0dd6c35bf0cc (svn r14337) -Codechange: use CmdRename* and CMD_RENAME_* for vehicle, president and company renaming commands, too
smatz
parents: 10148
diff changeset
  1333
				DoCommandP(0, 0, 0, NULL, CMD_RENAME_PRESIDENT | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT));
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1334
				break;
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1335
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1336
			case CW_WIDGET_COMPANY_NAME:
10151
0dd6c35bf0cc (svn r14337) -Codechange: use CmdRename* and CMD_RENAME_* for vehicle, president and company renaming commands, too
smatz
parents: 10148
diff changeset
  1337
				DoCommandP(0, 0, 0, NULL, CMD_RENAME_COMPANY | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME));
9237
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1338
				break;
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1339
		}
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1340
	}
c3cbcd8323e6 (svn r13103) -Codechange: make a class of the PlayerCompanyWindow.
rubidium
parents: 9230
diff changeset
  1341
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1342
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1343
static const WindowDesc _company_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
  1344
	WDP_AUTO, WDP_AUTO, 360, 170, 360, 170,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
  1345
	WC_COMPANY, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1346
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1347
	_company_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1348
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1349
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1350
void ShowCompany(CompanyID company)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1351
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1352
	if (!IsValidCompanyID(company)) return;
5005
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4998
diff changeset
  1353
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1354
	AllocateWindowDescFront<CompanyWindow>(&_company_desc, company);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1355
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1356
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1357
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1358
9302
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1359
struct BuyCompanyWindow : Window {
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1360
	BuyCompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1361
	{
9333
2da01b3b71d8 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 9332
diff changeset
  1362
		this->FindWindowPlacementAndResize(desc);
9302
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1363
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1364
9302
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1365
	virtual void OnPaint()
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1366
	{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1367
		Company *c = GetCompany((CompanyID)this->window_number);
9302
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1368
		SetDParam(0, STR_COMPANY_NAME);
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1369
		SetDParam(1, c->index);
9302
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1370
		this->DrawWidgets();
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1371
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1372
		DrawCompanyManagerFace(c->face, c->colour, 2, 16);
9302
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1373
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1374
		SetDParam(0, c->index);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1375
		SetDParam(1, c->bankrupt_value);
9302
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1376
		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
  1377
	}
9302
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1378
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1379
	virtual void OnClick(Point pt, int widget)
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1380
	{
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1381
		switch (widget) {
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1382
			case 3:
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1383
				delete this;
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1384
				break;
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1385
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1386
			case 4:
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1387
				DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY));
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1388
				break;
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1389
		}
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1390
	}
ed4a509cf8fd (svn r13170) -Codechange: make classes of the EnginePreview and BuyCompany windows.
rubidium
parents: 9273
diff changeset
  1391
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1392
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1393
static const Widget _buy_company_widgets[] = {
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1394
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_LIGHT_BLUE,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1395
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_LIGHT_BLUE,    11,   333,     0,    13, STR_00B3_MESSAGE_FROM, STR_018C_WINDOW_TITLE_DRAG_THIS},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1396
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_LIGHT_BLUE,     0,   333,    14,   136, 0x0,                   STR_NULL},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1397
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_LIGHT_BLUE,   148,   207,   117,   128, STR_00C9_NO,           STR_NULL},
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1398
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_LIGHT_BLUE,   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
  1399
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1400
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1401
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1402
static const WindowDesc _buy_company_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
  1403
	153, 171, 334, 137, 334, 137,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
  1404
	WC_BUY_COMPANY, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1405
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1406
	_buy_company_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1407
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1408
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1409
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1410
void ShowBuyCompanyDialog(CompanyID company)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1411
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1412
	AllocateWindowDescFront<BuyCompanyWindow>(&_buy_company_desc, company);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1413
}
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1414
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1415
/********** HIGHSCORE and ENDGAME windows */
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1416
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1417
extern StringID EndGameGetPerformanceTitleFromValue(uint value);
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1418
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1419
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1420
struct EndGameHighScoreBaseWindow : Window
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1421
{
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1422
	uint32 background_img;
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1423
	int8 rank;
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1424
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1425
	EndGameHighScoreBaseWindow(const WindowDesc *desc) : Window(desc)
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1426
	{
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1427
	}
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1428
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1429
	/* Always draw a maximized window and within there the centered background */
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1430
	void SetupHighScoreEndWindow(uint *x, uint *y)
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1431
	{
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1432
		/* resize window to "full-screen" */
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1433
		this->width = _screen.width;
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1434
		this->height = _screen.height;
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1435
		this->widget[0].right = this->width - 1;
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1436
		this->widget[0].bottom = this->height - 1;
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1437
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9252
diff changeset
  1438
		this->DrawWidgets();
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1439
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1440
		/* Center Highscore/Endscreen background */
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1441
		*x = max(0, (_screen.width  / 2) - (640 / 2));
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1442
		*y = max(0, (_screen.height / 2) - (480 / 2));
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1443
		for (uint i = 0; i < 10; i++) { // the image is split into 10 50px high parts
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1444
			DrawSprite(this->background_img + i, PAL_NONE, *x, *y + (i * 50));
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1445
		}
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1446
	}
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1447
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1448
	virtual void OnClick(Point pt, int widget)
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1449
	{
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1450
		delete this;
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1451
	}
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1452
};
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1453
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
  1454
/** End game window shown at the end of the game */
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1455
struct EndGameWindow : EndGameHighScoreBaseWindow {
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1456
	EndGameWindow(const WindowDesc *desc) : EndGameHighScoreBaseWindow(desc)
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1457
	{
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1458
		/* Pause in single-player to have a look at the highscore at your own leisure */
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1459
		if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1460
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1461
		this->background_img = SPR_TYCOON_IMG1_BEGIN;
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1462
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1463
		if (_local_company != COMPANY_SPECTATOR) {
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1464
			const Company *c = GetCompany(_local_company);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1465
			if (c->old_economy[0].performance_history == SCORE_MAX) {
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1466
				this->background_img = SPR_TYCOON_IMG2_BEGIN;
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1467
			}
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1468
		}
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1469
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1470
		/* In a network game show the endscores of the custom difficulty 'network' which is the last one
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1471
		 * as well as generate a TOP5 of that game, and not an all-time top5. */
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1472
		if (_networking) {
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1473
			this->window_number = lengthof(_highscore_table) - 1;
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1474
			this->rank = SaveHighScoreValueNetwork();
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1475
		} else {
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1476
			/* in single player _local company is always valid */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1477
			const Company *c = GetCompany(_local_company);
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9412
diff changeset
  1478
			this->window_number = _settings_game.difficulty.diff_level;
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1479
			this->rank = SaveHighScoreValue(c);
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1480
		}
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1481
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1482
		MarkWholeScreenDirty();
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1483
	}
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1484
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1485
	~EndGameWindow()
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1486
	{
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1487
		if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1488
		ShowHighscoreTable(this->window_number, this->rank);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1489
	}
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1490
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1491
	virtual void OnPaint()
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1492
	{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1493
		const Company *c;
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1494
		uint x, y;
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1495
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1496
		this->SetupHighScoreEndWindow(&x, &y);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1497
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1498
		if (!IsValidCompanyID(_local_company)) return;
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1499
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1500
		c = GetCompany(_local_company);
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1501
		/* We need to get performance from last year because the image is shown
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1502
		 * at the start of the new year when these things have already been copied */
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1503
		if (this->background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1504
			SetDParam(0, c->index);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1505
			SetDParam(1, c->index);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1506
			SetDParam(2, EndGameGetPerformanceTitleFromValue(c->old_economy[0].performance_history));
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1507
			DrawStringMultiCenter(x + (640 / 2), y + 107, STR_021C_OF_ACHIEVES_STATUS, 640);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1508
		} else {
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1509
			SetDParam(0, c->index);
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10151
diff changeset
  1510
			SetDParam(1, EndGameGetPerformanceTitleFromValue(c->old_economy[0].performance_history));
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1511
			DrawStringMultiCenter(x + (640 / 2), y + 157, STR_021B_ACHIEVES_STATUS, 640);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1512
		}
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1513
	}
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1514
};
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1515
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1516
struct HighScoreWindow : EndGameHighScoreBaseWindow
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1517
{
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1518
	HighScoreWindow(const WindowDesc *desc, int difficulty, int8 ranking) : EndGameHighScoreBaseWindow(desc)
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1519
	{
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1520
		/* pause game to show the chart */
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1521
		if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
1839
f64935a60abb (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1522
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1523
		/* Close all always on-top windows to get a clean screen */
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1524
		if (_game_mode != GM_MENU) HideVitalWindows();
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1525
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1526
		MarkWholeScreenDirty();
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1527
		this->window_number = difficulty; // show highscore chart for difficulty...
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1528
		this->background_img = SPR_HIGHSCORE_CHART_BEGIN; // which background to show
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1529
		this->rank = ranking;
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1530
	}
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1531
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1532
	~HighScoreWindow()
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1533
	{
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1534
		if (_game_mode != GM_MENU) ShowVitalWindows();
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1535
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1536
		if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1537
	}
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1538
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1539
	virtual void OnPaint()
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1540
	{
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1541
		const HighScore *hs = _highscore_table[this->window_number];
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1542
		uint x, y;
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1543
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1544
		this->SetupHighScoreEndWindow(&x, &y);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1545
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9412
diff changeset
  1546
		SetDParam(0, _settings_client.gui.ending_year);
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1547
		SetDParam(1, this->window_number + STR_6801_EASY);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1548
		DrawStringMultiCenter(x + (640 / 2), y + 62, !_networking ? STR_0211_TOP_COMPANIES_WHO_REACHED : STR_TOP_COMPANIES_NETWORK_GAME, 500);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1549
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1550
		/* Draw Highscore peepz */
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1551
		for (uint8 i = 0; i < lengthof(_highscore_table[0]); i++) {
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1552
			SetDParam(0, i + 1);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1553
			DrawString(x + 40, y + 140 + (i * 55), STR_0212, TC_BLACK);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1554
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1555
			if (hs[i].company[0] != '\0') {
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1556
				TextColour colour = (this->rank == i) ? TC_RED : TC_BLACK; // draw new highscore in red
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1557
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1558
				DoDrawString(hs[i].company, x + 71, y + 140 + (i * 55), colour);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1559
				SetDParam(0, hs[i].title);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1560
				SetDParam(1, hs[i].score);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1561
				DrawString(x + 71, y + 160 + (i * 55), STR_HIGHSCORE_STATS, colour);
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1562
			}
8868
0519384f7ac0 (svn r12635) -Codechange: a bit of a code-style cleanup
belugas
parents: 8867
diff changeset
  1563
		}
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1564
	}
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1565
};
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1566
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1567
static const Widget _highscore_widgets[] = {
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9659
diff changeset
  1568
{      WWT_PANEL, RESIZE_NONE,  COLOUR_END, 0, 640, 0, 480, 0x0, STR_NULL},
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1569
{   WIDGETS_END},
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1570
};
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1571
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1572
static const WindowDesc _highscore_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
  1573
	0, 0, 641, 481, 641, 481,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
  1574
	WC_HIGHSCORE, WC_NONE,
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1575
	0,
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1576
	_highscore_widgets,
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1577
};
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1578
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1579
static const WindowDesc _endgame_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7266
diff changeset
  1580
	0, 0, 641, 481, 641, 481,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5854
diff changeset
  1581
	WC_ENDSCREEN, WC_NONE,
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1582
	0,
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1583
	_highscore_widgets,
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1584
};
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1585
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
  1586
/** Show the highscore table for a given difficulty. When called from
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1587
 * endgame ranking is set to the top5 element that was newly added
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1588
 * and is thus highlighted */
998
c90459c24842 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
  1589
void ShowHighscoreTable(int difficulty, int8 ranking)
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1590
{
1875
f7155c837fa2 (svn r2381) - Fix: [ 1210610 ] Endgame window on easy difficulty results in infinite loop. Oops. Seperated the window classes of endgame and highscreen.
Darkvater
parents: 1839
diff changeset
  1591
	DeleteWindowByClass(WC_HIGHSCORE);
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1592
	new HighScoreWindow(&_highscore_desc, difficulty, ranking);
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1593
}
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1594
6352
938ab8f48e5d (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents: 6259
diff changeset
  1595
/** Show the endgame victory screen in 2050. Update the new highscore
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1596
 * if it was high enough */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6190
diff changeset
  1597
void ShowEndGameChart()
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1598
{
1839
f64935a60abb (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1599
	/* Dedicated server doesn't need the highscore window */
f64935a60abb (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1600
	if (_network_dedicated) return;
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1601
1839
f64935a60abb (svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents: 1824
diff changeset
  1602
	HideVitalWindows();
1875
f7155c837fa2 (svn r2381) - Fix: [ 1210610 ] Endgame window on easy difficulty results in infinite loop. Oops. Seperated the window classes of endgame and highscreen.
Darkvater
parents: 1839
diff changeset
  1603
	DeleteWindowByClass(WC_ENDSCREEN);
9252
71843bf1bf33 (svn r13118) -Codechange: make classes of the EndGameWindow and the HighScoreWindow.
rubidium
parents: 9251
diff changeset
  1604
	new EndGameWindow(&_endgame_desc);
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
  1605
}