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