author | glx |
Sun, 15 Jun 2008 22:18:10 +0000 | |
branch | noai |
changeset 10971 | aaf89f8c59b9 |
parent 10829 | 8a0ec0f0f928 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10249
diff
changeset
|
3 |
/** @file player_gui.cpp Player related GUIs. */ |
9505 | 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" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
8 |
#include "window_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
9 |
#include "textbuf_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
10 |
#include "viewport_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
11 |
#include "gfx_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
12 |
#include "player_func.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
13 |
#include "player_base.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
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" |
10829 | 16 |
#include "network/network_gui.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2064
diff
changeset
|
17 |
#include "variables.h" |
9627 | 18 |
#include "roadveh.h" |
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2642
diff
changeset
|
19 |
#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
|
20 |
#include "aircraft.h" |
4742
d5a2d3da5002
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4719
diff
changeset
|
21 |
#include "newgrf.h" |
6516
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
22 |
#include "player_face.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
23 |
#include "strings_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
24 |
#include "functions.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
25 |
#include "window_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
26 |
#include "date_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
27 |
#include "string_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
28 |
#include "settings_type.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
29 |
#include "widgets/dropdown_func.h" |
10181
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
30 |
#include "widgets/dropdown_type.h" |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10249
diff
changeset
|
31 |
#include "tilehighlight_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
32 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
33 |
#include "table/sprites.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
34 |
#include "table/strings.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
35 |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
36 |
enum { |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
37 |
FIRST_GUI_CALL = INT_MAX, ///< default value to specify thuis is the first call of the resizable gui |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
38 |
}; |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
39 |
|
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
40 |
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied, int top = FIRST_GUI_CALL, int left = FIRST_GUI_CALL); |
10645 | 41 |
static void DoSelectPlayerFace(Window *parent, bool show_big, int top = FIRST_GUI_CALL, int left = FIRST_GUI_CALL); |
0 | 42 |
|
10645 | 43 |
static void DrawPlayerEconomyStats(const Player *p, bool small) |
0 | 44 |
{ |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9505
diff
changeset
|
45 |
int x, y, i, j, year; |
9732 | 46 |
const Money (*tbl)[EXPENSES_END]; |
9629 | 47 |
Money sum, cost; |
0 | 48 |
StringID str; |
49 |
||
10645 | 50 |
if (!small) { // normal sized economics window |
0 | 51 |
/* draw categories */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
52 |
DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, TC_FROMSTRING); |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
53 |
for (i = 0; i != EXPENSES_END; i++) |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
54 |
DrawString(2, 27 + i * 10, STR_7011_CONSTRUCTION + i, TC_FROMSTRING); |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
55 |
DrawStringRightAligned(111, 27 + 10 * EXPENSES_END + 2, STR_7020_TOTAL, TC_FROMSTRING); |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
56 |
|
0 | 57 |
/* draw the price columns */ |
58 |
year = _cur_year - 2; |
|
59 |
j = 3; |
|
60 |
x = 215; |
|
61 |
tbl = p->yearly_expenses + 2; |
|
62 |
do { |
|
4329
9759d5c52010
(svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents:
4314
diff
changeset
|
63 |
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
|
64 |
SetDParam(0, year); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
65 |
DrawStringRightAlignedUnderline(x, 15, STR_7010, TC_FROMSTRING); |
0 | 66 |
sum = 0; |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
67 |
for (i = 0; i != EXPENSES_END; i++) { |
0 | 68 |
/* draw one row in the price column */ |
69 |
cost = (*tbl)[i]; |
|
70 |
if (cost != 0) { |
|
71 |
sum += cost; |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
72 |
|
0 | 73 |
str = STR_701E; |
74 |
if (cost < 0) { cost = -cost; str++; } |
|
9629 | 75 |
SetDParam(0, cost); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
76 |
DrawStringRightAligned(x, 27 + i * 10, str, TC_FROMSTRING); |
0 | 77 |
} |
78 |
} |
|
79 |
||
80 |
str = STR_701E; |
|
81 |
if (sum < 0) { sum = -sum; str++; } |
|
9629 | 82 |
SetDParam(0, sum); |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
83 |
DrawStringRightAligned(x, 27 + EXPENSES_END * 10 + 2, str, TC_FROMSTRING); |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
84 |
|
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
85 |
GfxFillRect(x - 75, 27 + 10 * EXPENSES_END, x, 27 + 10 * EXPENSES_END, 215); |
0 | 86 |
x += 95; |
87 |
} |
|
88 |
year++; |
|
89 |
tbl--; |
|
90 |
} while (--j != 0); |
|
91 |
||
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
92 |
y = 27 + 10 * EXPENSES_END + 14; |
186
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
93 |
|
9505 | 94 |
/* draw max loan aligned to loan below (y += 10) */ |
9629 | 95 |
SetDParam(0, _economy.max_loan); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
96 |
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
|
97 |
} else { |
0 | 98 |
y = 15; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
99 |
} |
0 | 100 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
101 |
DrawString(2, y, STR_7026_BANK_BALANCE, TC_FROMSTRING); |
9629 | 102 |
SetDParam(0, p->player_money); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
103 |
DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING); |
0 | 104 |
|
105 |
y += 10; |
|
106 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
107 |
DrawString(2, y, STR_7027_LOAN, TC_FROMSTRING); |
9629 | 108 |
SetDParam(0, p->current_loan); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
109 |
DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING); |
0 | 110 |
|
111 |
y += 12; |
|
112 |
||
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9505
diff
changeset
|
113 |
GfxFillRect(182 - 75, y - 2, 182, y - 2, 215); |
0 | 114 |
|
9629 | 115 |
SetDParam(0, p->player_money - p->current_loan); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
116 |
DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING); |
0 | 117 |
} |
118 |
||
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
119 |
enum PlayerFinancesWindowWidgets { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
120 |
PFW_WIDGET_TOGGLE_SIZE = 2, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
121 |
PFW_WIDGET_INCREASE_LOAN = 6, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
122 |
PFW_WIDGET_REPAY_LOAN = 7, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
123 |
}; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
124 |
|
0 | 125 |
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
|
126 |
{ 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
|
127 |
{ 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
|
128 |
{ 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
|
129 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON}, |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
130 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 406, 14, 39 + 10 * EXPENSES_END, 0x0, STR_NULL}, |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
131 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 406, 40 + 10 * EXPENSES_END, 73 + 10 * EXPENSES_END, 0x0, STR_NULL}, |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
132 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 202, 74 + 10 * EXPENSES_END, 85 + 10 * EXPENSES_END, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN}, |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
133 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 203, 406, 74 + 10 * EXPENSES_END, 85 + 10 * EXPENSES_END, STR_702A_REPAY, STR_7036_REPAY_PART_OF_LOAN}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
150
diff
changeset
|
134 |
{ WIDGETS_END}, |
0 | 135 |
}; |
136 |
||
137 |
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
|
138 |
{ 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
|
139 |
{ 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
|
140 |
{ 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
|
141 |
{ 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
|
142 |
{ 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
|
143 |
{ 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
|
144 |
{ 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
|
145 |
{ 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
|
146 |
{ WIDGETS_END}, |
0 | 147 |
}; |
148 |
||
10645 | 149 |
struct PlayerFinancesWindow : Window { |
150 |
bool small; |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
151 |
|
10645 | 152 |
PlayerFinancesWindow(const WindowDesc *desc, PlayerID player, bool show_small, |
153 |
bool show_stickied, int top, int left) : |
|
154 |
Window(desc, player), |
|
155 |
small(show_small) |
|
156 |
{ |
|
157 |
this->caption_color = this->window_number; |
|
0 | 158 |
|
10645 | 159 |
if (show_stickied) this->flags4 |= WF_STICKY; |
0 | 160 |
|
10645 | 161 |
/* Check if repositioning from default is required */ |
162 |
if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) { |
|
163 |
this->top = top; |
|
164 |
this->left = left; |
|
165 |
} |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
166 |
|
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
167 |
this->FindWindowPlacementAndResize(desc); |
10645 | 168 |
} |
169 |
||
170 |
virtual void OnPaint() |
|
171 |
{ |
|
172 |
PlayerID player = (PlayerID)this->window_number; |
|
173 |
const Player *p = GetPlayer(player); |
|
174 |
||
175 |
/* Recheck the size of the window as it might need to be resized due to the local player changing */ |
|
176 |
int new_height = ((player != _local_player) ? 0 : 12) + ((this->small != 0) ? 48 : 74 + 10 * EXPENSES_END); |
|
177 |
if (this->height != new_height) { |
|
178 |
/* Make window dirty before and after resizing */ |
|
179 |
this->SetDirty(); |
|
180 |
this->height = new_height; |
|
181 |
this->SetDirty(); |
|
182 |
||
183 |
this->SetWidgetHiddenState(PFW_WIDGET_INCREASE_LOAN, player != _local_player); |
|
184 |
this->SetWidgetHiddenState(PFW_WIDGET_REPAY_LOAN, player != _local_player); |
|
185 |
} |
|
186 |
||
187 |
/* Borrow button only shows when there is any more money to loan */ |
|
188 |
this->SetWidgetDisabledState(PFW_WIDGET_INCREASE_LOAN, p->current_loan == _economy.max_loan); |
|
189 |
||
190 |
/* Repay button only shows when there is any more money to repay */ |
|
191 |
this->SetWidgetDisabledState(PFW_WIDGET_REPAY_LOAN, player != _local_player || p->current_loan == 0); |
|
192 |
||
193 |
SetDParam(0, p->index); |
|
194 |
SetDParam(1, p->index); |
|
195 |
SetDParam(2, LOAN_INTERVAL); |
|
196 |
this->DrawWidgets(); |
|
197 |
||
198 |
DrawPlayerEconomyStats(p, this->small); |
|
199 |
} |
|
200 |
||
201 |
virtual void OnClick(Point pt, int widget) |
|
202 |
{ |
|
203 |
switch (widget) { |
|
204 |
case PFW_WIDGET_TOGGLE_SIZE: {/* toggle size */ |
|
205 |
bool new_mode = !this->small; |
|
206 |
bool stickied = !!(this->flags4 & WF_STICKY); |
|
207 |
int oldtop = this->top; ///< current top position of the window before closing it |
|
208 |
int oldleft = this->left; ///< current left position of the window before closing it |
|
209 |
PlayerID player = (PlayerID)this->window_number; |
|
210 |
||
211 |
delete this; |
|
212 |
/* Open up the (toggled size) Finance window at the same position as the previous */ |
|
213 |
DoShowPlayerFinances(player, new_mode, stickied, oldtop, oldleft); |
|
214 |
} |
|
215 |
break; |
|
216 |
||
217 |
case PFW_WIDGET_INCREASE_LOAN: /* increase loan */ |
|
218 |
DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY)); |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
219 |
break; |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
220 |
|
10645 | 221 |
case PFW_WIDGET_REPAY_LOAN: /* repay loan */ |
222 |
DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN)); |
|
223 |
break; |
|
224 |
} |
|
0 | 225 |
} |
10645 | 226 |
}; |
0 | 227 |
|
228 |
static const WindowDesc _player_finances_desc = { |
|
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
229 |
WDP_AUTO, WDP_AUTO, 407, 86 + 10 * EXPENSES_END, 407, 86 + 10 * EXPENSES_END, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6105
diff
changeset
|
230 |
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
|
231 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 232 |
_player_finances_widgets, |
233 |
}; |
|
234 |
||
235 |
static const WindowDesc _player_finances_small_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
236 |
WDP_AUTO, WDP_AUTO, 280, 60, 280, 60, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6105
diff
changeset
|
237 |
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
|
238 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 239 |
_player_finances_small_widgets, |
240 |
}; |
|
241 |
||
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
242 |
/** |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
243 |
* Open the small/large finance window of the player |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
244 |
* |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
245 |
* @param player the player who's finances are requested to be seen |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
246 |
* @param show_small show large or small version opf the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
247 |
* @param show_stickied previous "stickyness" of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
248 |
* @param top previous top position of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
249 |
* @param left previous left position of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
250 |
* |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
251 |
* @pre is player a valid player |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
252 |
*/ |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
253 |
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied, int top, int left) |
0 | 254 |
{ |
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4998
diff
changeset
|
255 |
if (!IsValidPlayer(player)) return; |
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4998
diff
changeset
|
256 |
|
10645 | 257 |
if (BringWindowToFrontById(WC_FINANCES, player)) return; |
258 |
new PlayerFinancesWindow(show_small ? &_player_finances_small_desc : &_player_finances_desc, player, show_small, show_stickied, top, left); |
|
0 | 259 |
} |
260 |
||
2475 | 261 |
void ShowPlayerFinances(PlayerID player) |
0 | 262 |
{ |
888
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
263 |
DoShowPlayerFinances(player, false, false); |
0 | 264 |
} |
265 |
||
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 |
/* 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
|
267 |
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
|
268 |
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
|
269 |
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
|
270 |
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
|
271 |
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
|
272 |
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
|
273 |
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
|
274 |
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
|
275 |
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
|
276 |
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
|
277 |
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
|
278 |
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
|
279 |
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
|
280 |
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
|
281 |
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
|
282 |
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
|
283 |
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
|
284 |
}; |
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload 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 |
|
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4344
diff
changeset
|
286 |
/* Association of liveries to livery classes */ |
10645 | 287 |
static const LiveryClass _livery_class[LS_END] = { |
4603
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4344
diff
changeset
|
288 |
LC_OTHER, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
289 |
LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, |
4603
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4344
diff
changeset
|
290 |
LC_ROAD, LC_ROAD, |
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4344
diff
changeset
|
291 |
LC_SHIP, LC_SHIP, |
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4344
diff
changeset
|
292 |
LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT, |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9601
diff
changeset
|
293 |
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
|
294 |
}; |
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4344
diff
changeset
|
295 |
|
10181
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
296 |
class DropDownListColourItem : public DropDownListItem { |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
297 |
public: |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
298 |
DropDownListColourItem(int result, bool masked) : DropDownListItem(result, masked) {} |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
299 |
|
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
300 |
virtual ~DropDownListColourItem() {} |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
301 |
|
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
302 |
virtual StringID String() const |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
303 |
{ |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
304 |
return _colour_dropdown[this->result]; |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
305 |
} |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
306 |
|
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
307 |
virtual uint Height(uint width) const |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
308 |
{ |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
309 |
return 14; |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
310 |
} |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
311 |
|
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
312 |
virtual void Draw(int x, int y, uint width, uint height, bool sel) const |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
313 |
{ |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
314 |
DrawSprite(SPR_VEH_BUS_SIDE_VIEW, PALETTE_RECOLOR_START + this->result, x + 16, y + 7); |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
315 |
DrawStringTruncated(x + 32, y + 3, this->String(), sel ? TC_WHITE : TC_BLACK, x + width - 30); |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
316 |
} |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
317 |
}; |
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
318 |
|
10645 | 319 |
struct SelectPlayerLiveryWindow : public Window { |
320 |
private: |
|
321 |
uint32 sel; |
|
322 |
LiveryClass livery_class; |
|
4603
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4344
diff
changeset
|
323 |
|
10645 | 324 |
enum PlayerLiveryWindowWidgets { |
325 |
PLW_WIDGET_CLOSE, |
|
326 |
PLW_WIDGET_CAPTION, |
|
327 |
PLW_WIDGET_CLASS_GENERAL, |
|
328 |
PLW_WIDGET_CLASS_RAIL, |
|
329 |
PLW_WIDGET_CLASS_ROAD, |
|
330 |
PLW_WIDGET_CLASS_SHIP, |
|
331 |
PLW_WIDGET_CLASS_AIRCRAFT, |
|
332 |
PLW_WIDGET_SPACER_CLASS, |
|
333 |
PLW_WIDGET_SPACER_DROPDOWN, |
|
334 |
PLW_WIDGET_PRI_COL_DROPDOWN, |
|
335 |
PLW_WIDGET_SEC_COL_DROPDOWN, |
|
336 |
PLW_WIDGET_MATRIX, |
|
337 |
}; |
|
338 |
||
339 |
void ShowColourDropDownMenu(uint32 widget) |
|
340 |
{ |
|
341 |
uint32 used_colours = 0; |
|
342 |
const Livery *livery; |
|
343 |
LiveryScheme scheme; |
|
344 |
||
345 |
/* Disallow other player colours for the primary colour */ |
|
346 |
if (HasBit(this->sel, LS_DEFAULT) && widget == PLW_WIDGET_PRI_COL_DROPDOWN) { |
|
347 |
const Player *p; |
|
348 |
FOR_ALL_PLAYERS(p) { |
|
349 |
if (p->is_active && p->index != _local_player) SetBit(used_colours, p->player_color); |
|
350 |
} |
|
351 |
} |
|
352 |
||
353 |
/* Get the first selected livery to use as the default dropdown item */ |
|
354 |
for (scheme = LS_BEGIN; scheme < LS_END; scheme++) { |
|
355 |
if (HasBit(this->sel, scheme)) break; |
|
356 |
} |
|
357 |
if (scheme == LS_END) scheme = LS_DEFAULT; |
|
358 |
livery = &GetPlayer((PlayerID)this->window_number)->livery[scheme]; |
|
359 |
||
360 |
DropDownList *list = new DropDownList(); |
|
361 |
for (uint i = 0; i < lengthof(_colour_dropdown); i++) { |
|
362 |
list->push_back(new DropDownListColourItem(i, HasBit(used_colours, i))); |
|
363 |
} |
|
364 |
||
365 |
ShowDropDownList(this, list, widget == PLW_WIDGET_PRI_COL_DROPDOWN ? livery->colour1 : livery->colour2, widget); |
|
366 |
} |
|
367 |
||
368 |
public: |
|
369 |
SelectPlayerLiveryWindow(const WindowDesc *desc, PlayerID player) : Window(desc, player) |
|
370 |
{ |
|
371 |
this->caption_color = player; |
|
372 |
this->livery_class = LC_OTHER; |
|
373 |
this->sel = 1; |
|
374 |
this->LowerWidget(PLW_WIDGET_CLASS_GENERAL); |
|
375 |
this->OnInvalidateData(_loaded_newgrf_features.has_2CC); |
|
376 |
this->FindWindowPlacementAndResize(desc); |
|
377 |
} |
|
378 |
||
379 |
virtual void OnPaint() |
|
380 |
{ |
|
381 |
const Player *p = GetPlayer((PlayerID)this->window_number); |
|
382 |
LiveryScheme scheme = LS_DEFAULT; |
|
383 |
int y = 51; |
|
384 |
||
385 |
/* Disable dropdown controls if no scheme is selected */ |
|
386 |
this->SetWidgetDisabledState(PLW_WIDGET_PRI_COL_DROPDOWN, this->sel == 0); |
|
387 |
this->SetWidgetDisabledState(PLW_WIDGET_SEC_COL_DROPDOWN, this->sel == 0); |
|
388 |
||
389 |
if (this->sel != 0) { |
|
390 |
for (scheme = LS_BEGIN; scheme < LS_END; scheme++) { |
|
391 |
if (HasBit(this->sel, scheme)) break; |
|
392 |
} |
|
393 |
if (scheme == LS_END) scheme = LS_DEFAULT; |
|
394 |
} |
|
395 |
||
396 |
SetDParam(0, STR_00D1_DARK_BLUE + p->livery[scheme].colour1); |
|
397 |
SetDParam(1, STR_00D1_DARK_BLUE + p->livery[scheme].colour2); |
|
398 |
||
399 |
this->DrawWidgets(); |
|
400 |
||
401 |
for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) { |
|
402 |
if (_livery_class[scheme] == this->livery_class) { |
|
403 |
bool sel = HasBit(this->sel, scheme) != 0; |
|
404 |
||
405 |
if (scheme != LS_DEFAULT) { |
|
406 |
DrawSprite(p->livery[scheme].in_use ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, 2, y); |
|
407 |
} |
|
408 |
||
409 |
DrawString(15, y, STR_LIVERY_DEFAULT + scheme, sel ? TC_WHITE : TC_BLACK); |
|
410 |
||
411 |
DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour1), 152, y); |
|
412 |
DrawString(165, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour1, sel ? TC_WHITE : TC_GOLD); |
|
413 |
||
414 |
if (!this->IsWidgetHidden(PLW_WIDGET_SEC_COL_DROPDOWN)) { |
|
415 |
DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour2), 277, y); |
|
416 |
DrawString(290, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour2, sel ? TC_WHITE : TC_GOLD); |
|
417 |
} |
|
418 |
||
419 |
y += 14; |
|
420 |
} |
|
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 |
} |
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload 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 |
} |
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload 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 |
|
10645 | 424 |
virtual void OnClick(Point pt, int widget) |
425 |
{ |
|
426 |
/* Number of liveries in each class, used to determine the height of the livery window */ |
|
427 |
static const byte livery_height[] = { |
|
428 |
1, |
|
429 |
13, |
|
430 |
4, |
|
431 |
2, |
|
432 |
3, |
|
433 |
}; |
|
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
|
434 |
|
10645 | 435 |
switch (widget) { |
436 |
/* Livery Class buttons */ |
|
437 |
case PLW_WIDGET_CLASS_GENERAL: |
|
438 |
case PLW_WIDGET_CLASS_RAIL: |
|
439 |
case PLW_WIDGET_CLASS_ROAD: |
|
440 |
case PLW_WIDGET_CLASS_SHIP: |
|
441 |
case PLW_WIDGET_CLASS_AIRCRAFT: { |
|
442 |
LiveryScheme scheme; |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
443 |
|
10645 | 444 |
this->RaiseWidget(this->livery_class + PLW_WIDGET_CLASS_GENERAL); |
445 |
this->livery_class = (LiveryClass)(widget - PLW_WIDGET_CLASS_GENERAL); |
|
446 |
this->sel = 0; |
|
447 |
this->LowerWidget(this->livery_class + PLW_WIDGET_CLASS_GENERAL); |
|
0 | 448 |
|
10645 | 449 |
/* Select the first item in the list */ |
450 |
for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) { |
|
451 |
if (_livery_class[scheme] == this->livery_class) { |
|
452 |
this->sel = 1 << scheme; |
|
453 |
break; |
|
454 |
} |
|
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
|
455 |
} |
10645 | 456 |
this->height = 49 + livery_height[this->livery_class] * 14; |
457 |
this->widget[PLW_WIDGET_MATRIX].bottom = this->height - 1; |
|
458 |
this->widget[PLW_WIDGET_MATRIX].data = livery_height[this->livery_class] << 8 | 1; |
|
459 |
MarkWholeScreenDirty(); |
|
460 |
break; |
|
0 | 461 |
} |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
462 |
|
10645 | 463 |
case PLW_WIDGET_PRI_COL_DROPDOWN: /* First colour dropdown */ |
464 |
ShowColourDropDownMenu(PLW_WIDGET_PRI_COL_DROPDOWN); |
|
465 |
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
|
466 |
|
10645 | 467 |
case PLW_WIDGET_SEC_COL_DROPDOWN: /* Second colour dropdown */ |
468 |
ShowColourDropDownMenu(PLW_WIDGET_SEC_COL_DROPDOWN); |
|
469 |
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
|
470 |
|
10645 | 471 |
case PLW_WIDGET_MATRIX: { |
472 |
LiveryScheme scheme; |
|
473 |
LiveryScheme j = (LiveryScheme)((pt.y - 48) / 14); |
|
4603
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4344
diff
changeset
|
474 |
|
10645 | 475 |
for (scheme = LS_BEGIN; scheme <= j; scheme++) { |
476 |
if (_livery_class[scheme] != this->livery_class) j++; |
|
477 |
if (scheme >= LS_END) return; |
|
4603
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4344
diff
changeset
|
478 |
} |
10645 | 479 |
if (j >= LS_END) return; |
4603
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4344
diff
changeset
|
480 |
|
10645 | 481 |
/* If clicking on the left edge, toggle using the livery */ |
482 |
if (pt.x < 10) { |
|
483 |
DoCommandP(0, j | (2 << 8), !GetPlayer((PlayerID)this->window_number)->livery[j].in_use, NULL, CMD_SET_PLAYER_COLOR); |
|
0 | 484 |
} |
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
|
485 |
|
10645 | 486 |
if (_ctrl_pressed) { |
487 |
ToggleBit(this->sel, j); |
|
488 |
} else { |
|
489 |
this->sel = 1 << j; |
|
4603
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4344
diff
changeset
|
490 |
} |
10645 | 491 |
this->SetDirty(); |
492 |
break; |
|
0 | 493 |
} |
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
|
494 |
} |
0 | 495 |
} |
496 |
||
10645 | 497 |
virtual void OnDropdownSelect(int widget, int index) |
498 |
{ |
|
499 |
for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) { |
|
500 |
if (HasBit(this->sel, scheme)) { |
|
501 |
DoCommandP(0, scheme | (widget == PLW_WIDGET_PRI_COL_DROPDOWN ? 0 : 256), index, NULL, CMD_SET_PLAYER_COLOR); |
|
502 |
} |
|
503 |
} |
|
504 |
} |
|
505 |
||
506 |
virtual void OnInvalidateData(int data = 0) |
|
507 |
{ |
|
508 |
static bool has2cc = true; |
|
509 |
||
510 |
if (has2cc == !!data) return; |
|
511 |
||
512 |
has2cc = !!data; |
|
513 |
||
514 |
int r = this->widget[has2cc ? PLW_WIDGET_SEC_COL_DROPDOWN : PLW_WIDGET_PRI_COL_DROPDOWN].right; |
|
515 |
this->SetWidgetHiddenState(PLW_WIDGET_SEC_COL_DROPDOWN, !has2cc); |
|
516 |
this->widget[PLW_WIDGET_CAPTION].right = r; |
|
517 |
this->widget[PLW_WIDGET_SPACER_CLASS].right = r; |
|
518 |
this->widget[PLW_WIDGET_MATRIX].right = r; |
|
519 |
this->width = r + 1; |
|
520 |
} |
|
521 |
}; |
|
522 |
||
523 |
static const Widget _select_player_livery_widgets[] = { |
|
4603
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4344
diff
changeset
|
524 |
{ 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
|
525 |
{ 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
|
526 |
{ 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
|
527 |
{ 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
|
528 |
{ 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
|
529 |
{ 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
|
530 |
{ 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
|
531 |
{ 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
|
532 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 149, 36, 47, 0x0, STR_NULL }, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
533 |
{ WWT_DROPDOWN, RESIZE_NONE, 14, 150, 274, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP }, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
534 |
{ 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
|
535 |
{ 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
|
536 |
{ WIDGETS_END }, |
0 | 537 |
}; |
538 |
||
10645 | 539 |
static const WindowDesc _select_player_livery_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
540 |
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
|
541 |
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
|
542 |
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
|
543 |
_select_player_livery_widgets, |
0 | 544 |
}; |
545 |
||
6516
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 |
* Draws the face of a player. |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
548 |
* @param pf the player's face |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
549 |
* @param color the (background) color of the gradient |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
550 |
* @param x x-position to draw the face |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
551 |
* @param y y-position to draw the face |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
552 |
*/ |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
553 |
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
|
554 |
{ |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
555 |
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
|
556 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
557 |
bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetPlayerFaceBits(pf, PFV_HAS_MOUSTACHE, ge) != 0; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
558 |
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
|
559 |
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
|
560 |
SpriteID pal; |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
561 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
562 |
/* Modify eye colour palette only if 2 or more valid values exist */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
563 |
if (_pf_info[PFV_EYE_COLOUR].valid_values[ge] < 2) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
564 |
pal = PAL_NONE; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
565 |
} else { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
566 |
switch (GetPlayerFaceBits(pf, PFV_EYE_COLOUR, ge)) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
567 |
default: NOT_REACHED(); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
568 |
case 0: pal = PALETTE_TO_BROWN; break; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
569 |
case 1: pal = PALETTE_TO_BLUE; break; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
570 |
case 2: pal = PALETTE_TO_GREEN; break; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
571 |
} |
6516
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
572 |
} |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
573 |
|
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
574 |
/* Draw the gradient (background) */ |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
575 |
DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOR(color), x, y); |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
576 |
|
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
577 |
for (PlayerFaceVariable pfv = PFV_CHEEKS; pfv < PFV_END; pfv++) { |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
578 |
switch (pfv) { |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
579 |
case PFV_MOUSTACHE: if (!has_moustache) continue; break; |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
580 |
case PFV_LIPS: /* FALL THROUGH */ |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
581 |
case PFV_NOSE: if (has_moustache) continue; break; |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
582 |
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
|
583 |
case PFV_GLASSES: if (!has_glasses) continue; break; |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
584 |
default: break; |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
585 |
} |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
586 |
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
|
587 |
} |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
588 |
} |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6144
diff
changeset
|
589 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
590 |
/** Widget description for the normal/simple player face selection dialog */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
591 |
static const Widget _select_player_face_widgets[] = { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
592 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // PFW_WIDGET_CLOSEBOX |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
593 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 174, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // PFW_WIDGET_CAPTION |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
594 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 175, 189, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_ADVANCED_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
595 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 189, 14, 150, 0x0, STR_NULL}, // PFW_WIDGET_SELECT_FACE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
596 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 94, 151, 162, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // PFW_WIDGET_CANCEL |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
597 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 95, 189, 151, 162, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // PFW_WIDGET_ACCEPT |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
598 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 95, 187, 75, 86, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // PFW_WIDGET_MALE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
599 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 95, 187, 87, 98, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // PFW_WIDGET_FEMALE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
600 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 2, 93, 137, 148, STR_7046_NEW_FACE, STR_704B_GENERATE_RANDOM_NEW_FACE}, // PFW_WIDGET_RANDOM_NEW_FACE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
601 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 95, 187, 16, 27, STR_FACE_ADVANCED, STR_FACE_ADVANCED_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
602 |
{ WIDGETS_END}, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
603 |
}; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
604 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
605 |
/** Widget description for the advanced player face selection dialog */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
606 |
static const Widget _select_player_face_adv_widgets[] = { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
607 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // PFW_WIDGET_CLOSEBOX |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
608 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 204, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // PFW_WIDGET_CAPTION |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
609 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 205, 219, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_SIMPLE_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
610 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 219, 14, 207, 0x0, STR_NULL}, // PFW_WIDGET_SELECT_FACE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
611 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 94, 208, 219, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // PFW_WIDGET_CANCEL |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
612 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 95, 219, 208, 219, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // PFW_WIDGET_ACCEPT |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
613 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 96, 156, 32, 43, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // PFW_WIDGET_MALE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
614 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 157, 217, 32, 43, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // PFW_WIDGET_FEMALE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
615 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 2, 93, 137, 148, STR_RANDOM, STR_704B_GENERATE_RANDOM_NEW_FACE}, // PFW_WIDGET_RANDOM_NEW_FACE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
616 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 95, 217, 16, 27, STR_FACE_SIMPLE, STR_FACE_SIMPLE_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
617 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 2, 93, 158, 169, STR_FACE_LOAD, STR_FACE_LOAD_TIP}, // PFW_WIDGET_LOAD |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
618 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 2, 93, 170, 181, STR_FACE_FACECODE, STR_FACE_FACECODE_TIP}, // PFW_WIDGET_FACECODE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
619 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 2, 93, 182, 193, STR_FACE_SAVE, STR_FACE_SAVE_TIP}, // PFW_WIDGET_SAVE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
620 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 96, 156, 46, 57, STR_FACE_EUROPEAN, STR_FACE_SELECT_EUROPEAN}, // PFW_WIDGET_ETHNICITY_EUR |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
621 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 157, 217, 46, 57, STR_FACE_AFRICAN, STR_FACE_SELECT_AFRICAN}, // PFW_WIDGET_ETHNICITY_AFR |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
622 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 175, 217, 60, 71, STR_EMPTY, STR_FACE_MOUSTACHE_EARRING_TIP}, // PFW_WIDGET_HAS_MOUSTACHE_EARRING |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
623 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 175, 217, 72, 83, STR_EMPTY, STR_FACE_GLASSES_TIP}, // PFW_WIDGET_HAS_GLASSES |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
624 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 110, 121, SPR_ARROW_LEFT, STR_FACE_EYECOLOUR_TIP}, // PFW_WIDGET_EYECOLOUR_L |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
625 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 110, 121, STR_EMPTY, STR_FACE_EYECOLOUR_TIP}, // PFW_WIDGET_EYECOLOUR |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
626 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 110, 121, SPR_ARROW_RIGHT, STR_FACE_EYECOLOUR_TIP}, // PFW_WIDGET_EYECOLOUR_R |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
627 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 158, 169, SPR_ARROW_LEFT, STR_FACE_CHIN_TIP}, // PFW_WIDGET_CHIN_L |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
628 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 158, 169, STR_EMPTY, STR_FACE_CHIN_TIP}, // PFW_WIDGET_CHIN |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
629 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 158, 169, SPR_ARROW_RIGHT, STR_FACE_CHIN_TIP}, // PFW_WIDGET_CHIN_R |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
630 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 98, 109, SPR_ARROW_LEFT, STR_FACE_EYEBROWS_TIP}, // PFW_WIDGET_EYEBROWS_L |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
631 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 98, 109, STR_EMPTY, STR_FACE_EYEBROWS_TIP}, // PFW_WIDGET_EYEBROWS |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
632 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 98, 109, SPR_ARROW_RIGHT, STR_FACE_EYEBROWS_TIP}, // PFW_WIDGET_EYEBROWS_R |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
633 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 146, 157, SPR_ARROW_LEFT, STR_FACE_LIPS_MOUSTACHE_TIP}, // PFW_WIDGET_LIPS_MOUSTACHE_L |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
634 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 146, 157, STR_EMPTY, STR_FACE_LIPS_MOUSTACHE_TIP}, // PFW_WIDGET_LIPS_MOUSTACHE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
635 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 146, 157, SPR_ARROW_RIGHT, STR_FACE_LIPS_MOUSTACHE_TIP}, // PFW_WIDGET_LIPS_MOUSTACHE_R |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
636 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 134, 145, SPR_ARROW_LEFT, STR_FACE_NOSE_TIP}, // PFW_WIDGET_NOSE_L |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
637 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 134, 145, STR_EMPTY, STR_FACE_NOSE_TIP}, // PFW_WIDGET_NOSE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
638 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 134, 145, SPR_ARROW_RIGHT, STR_FACE_NOSE_TIP}, // PFW_WIDGET_NOSE_R |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
639 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 86, 97, SPR_ARROW_LEFT, STR_FACE_HAIR_TIP}, // PFW_WIDGET_HAIR_L |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
640 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 86, 97, STR_EMPTY, STR_FACE_HAIR_TIP}, // PFW_WIDGET_HAIR |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
641 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 86, 97, SPR_ARROW_RIGHT, STR_FACE_HAIR_TIP}, // PFW_WIDGET_HAIR_R |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
642 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 170, 181, SPR_ARROW_LEFT, STR_FACE_JACKET_TIP}, // PFW_WIDGET_JACKET_L |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
643 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 170, 181, STR_EMPTY, STR_FACE_JACKET_TIP}, // PFW_WIDGET_JACKET |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
644 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 170, 181, SPR_ARROW_RIGHT, STR_FACE_JACKET_TIP}, // PFW_WIDGET_JACKET_R |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
645 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 182, 193, SPR_ARROW_LEFT, STR_FACE_COLLAR_TIP}, // PFW_WIDGET_COLLAR_L |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
646 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 182, 193, STR_EMPTY, STR_FACE_COLLAR_TIP}, // PFW_WIDGET_COLLAR |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
647 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 182, 193, SPR_ARROW_RIGHT, STR_FACE_COLLAR_TIP}, // PFW_WIDGET_COLLAR_R |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
648 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 194, 205, SPR_ARROW_LEFT, STR_FACE_TIE_EARRING_TIP}, // PFW_WIDGET_TIE_EARRING_L |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
649 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 194, 205, STR_EMPTY, STR_FACE_TIE_EARRING_TIP}, // PFW_WIDGET_TIE_EARRING |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
650 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 194, 205, SPR_ARROW_RIGHT, STR_FACE_TIE_EARRING_TIP}, // PFW_WIDGET_TIE_EARRING_R |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
651 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 122, 133, SPR_ARROW_LEFT, STR_FACE_GLASSES_TIP_2}, // PFW_WIDGET_GLASSES_L |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
652 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 122, 133, STR_EMPTY, STR_FACE_GLASSES_TIP_2}, // PFW_WIDGET_GLASSES |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
653 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 122, 133, SPR_ARROW_RIGHT, STR_FACE_GLASSES_TIP_2}, // PFW_WIDGET_GLASSES_R |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
654 |
{ WIDGETS_END}, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
655 |
}; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
656 |
|
10645 | 657 |
class SelectPlayerFaceWindow : public Window |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
658 |
{ |
10645 | 659 |
PlayerFace face; // player face bits |
660 |
bool advanced; // advance player face selection window |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
661 |
|
10645 | 662 |
GenderEthnicity ge; |
663 |
bool is_female; |
|
664 |
bool is_moust_male; |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
665 |
|
10645 | 666 |
/** |
667 |
* Names of the widgets. Keep them in the same order as in the widget array. |
|
668 |
* Do not change the order of the widgets from PFW_WIDGET_HAS_MOUSTACHE_EARRING to PFW_WIDGET_GLASSES_R, |
|
669 |
* this order is needed for the WE_CLICK event of DrawFaceStringLabel(). |
|
670 |
*/ |
|
671 |
enum PlayerFaceWindowWidgets { |
|
672 |
PFW_WIDGET_CLOSEBOX = 0, |
|
673 |
PFW_WIDGET_CAPTION, |
|
674 |
PFW_WIDGET_TOGGLE_LARGE_SMALL, |
|
675 |
PFW_WIDGET_SELECT_FACE, |
|
676 |
PFW_WIDGET_CANCEL, |
|
677 |
PFW_WIDGET_ACCEPT, |
|
678 |
PFW_WIDGET_MALE, |
|
679 |
PFW_WIDGET_FEMALE, |
|
680 |
PFW_WIDGET_RANDOM_NEW_FACE, |
|
681 |
PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON, |
|
682 |
/* from here is the advanced player face selection window */ |
|
683 |
PFW_WIDGET_LOAD, |
|
684 |
PFW_WIDGET_FACECODE, |
|
685 |
PFW_WIDGET_SAVE, |
|
686 |
PFW_WIDGET_ETHNICITY_EUR, |
|
687 |
PFW_WIDGET_ETHNICITY_AFR, |
|
688 |
PFW_WIDGET_HAS_MOUSTACHE_EARRING, |
|
689 |
PFW_WIDGET_HAS_GLASSES, |
|
690 |
PFW_WIDGET_EYECOLOUR_L, |
|
691 |
PFW_WIDGET_EYECOLOUR, |
|
692 |
PFW_WIDGET_EYECOLOUR_R, |
|
693 |
PFW_WIDGET_CHIN_L, |
|
694 |
PFW_WIDGET_CHIN, |
|
695 |
PFW_WIDGET_CHIN_R, |
|
696 |
PFW_WIDGET_EYEBROWS_L, |
|
697 |
PFW_WIDGET_EYEBROWS, |
|
698 |
PFW_WIDGET_EYEBROWS_R, |
|
699 |
PFW_WIDGET_LIPS_MOUSTACHE_L, |
|
700 |
PFW_WIDGET_LIPS_MOUSTACHE, |
|
701 |
PFW_WIDGET_LIPS_MOUSTACHE_R, |
|
702 |
PFW_WIDGET_NOSE_L, |
|
703 |
PFW_WIDGET_NOSE, |
|
704 |
PFW_WIDGET_NOSE_R, |
|
705 |
PFW_WIDGET_HAIR_L, |
|
706 |
PFW_WIDGET_HAIR, |
|
707 |
PFW_WIDGET_HAIR_R, |
|
708 |
PFW_WIDGET_JACKET_L, |
|
709 |
PFW_WIDGET_JACKET, |
|
710 |
PFW_WIDGET_JACKET_R, |
|
711 |
PFW_WIDGET_COLLAR_L, |
|
712 |
PFW_WIDGET_COLLAR, |
|
713 |
PFW_WIDGET_COLLAR_R, |
|
714 |
PFW_WIDGET_TIE_EARRING_L, |
|
715 |
PFW_WIDGET_TIE_EARRING, |
|
716 |
PFW_WIDGET_TIE_EARRING_R, |
|
717 |
PFW_WIDGET_GLASSES_L, |
|
718 |
PFW_WIDGET_GLASSES, |
|
719 |
PFW_WIDGET_GLASSES_R, |
|
720 |
}; |
|
721 |
/** |
|
722 |
* Draw dynamic a label to the left of the button and a value in the button |
|
723 |
* |
|
724 |
* @param widget_index index of this widget in the window |
|
725 |
* @param str the label which will be draw |
|
726 |
* @param val the value which will be draw |
|
727 |
* @param is_bool_widget is it a bool button |
|
728 |
*/ |
|
729 |
void DrawFaceStringLabel(byte widget_index, StringID str, uint8 val, bool is_bool_widget) |
|
730 |
{ |
|
731 |
/* Write the label in gold (0x2) to the left of the button. */ |
|
732 |
DrawStringRightAligned(this->widget[widget_index].left - (is_bool_widget ? 5 : 14), this->widget[widget_index].top + 1, str, TC_GOLD); |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
733 |
|
10645 | 734 |
if (!this->IsWidgetDisabled(widget_index)) { |
735 |
if (is_bool_widget) { |
|
736 |
/* if it a bool button write yes or no */ |
|
737 |
str = (val != 0) ? STR_FACE_YES : STR_FACE_NO; |
|
738 |
} else { |
|
739 |
/* else write the value + 1 */ |
|
740 |
SetDParam(0, val + 1); |
|
741 |
str = STR_JUST_INT; |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
742 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
743 |
|
10645 | 744 |
/* Draw the value/bool in white (0xC). If the button clicked adds 1px to x and y text coordinates (IsWindowWidgetLowered()). */ |
745 |
DrawStringCentered(this->widget[widget_index].left + (this->widget[widget_index].right - this->widget[widget_index].left) / 2 + |
|
746 |
this->IsWidgetLowered(widget_index), this->widget[widget_index].top + 1 + this->IsWidgetLowered(widget_index), str, TC_WHITE); |
|
747 |
} |
|
748 |
} |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
749 |
|
10645 | 750 |
void UpdateData() |
751 |
{ |
|
752 |
this->ge = (GenderEthnicity)GB(this->face, _pf_info[PFV_GEN_ETHN].offset, _pf_info[PFV_GEN_ETHN].length); // get the gender and ethnicity |
|
753 |
this->is_female = HasBit(this->ge, GENDER_FEMALE); // get the gender: 0 == male and 1 == female |
|
754 |
this->is_moust_male = !is_female && GetPlayerFaceBits(this->face, PFV_HAS_MOUSTACHE, this->ge) != 0; // is a male face with moustache |
|
755 |
} |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
756 |
|
10645 | 757 |
public: |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
758 |
SelectPlayerFaceWindow(const WindowDesc *desc, Window *parent, bool advanced, int top, int left) : Window(desc, parent->window_number) |
10645 | 759 |
{ |
760 |
this->parent = parent; |
|
761 |
this->caption_color = this->window_number; |
|
762 |
this->face = GetPlayer((PlayerID)this->window_number)->face; |
|
763 |
this->advanced = advanced; |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
764 |
|
10645 | 765 |
this->UpdateData(); |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
766 |
|
10645 | 767 |
/* Check if repositioning from default is required */ |
768 |
if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) { |
|
769 |
this->top = top; |
|
770 |
this->left = left; |
|
771 |
} |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
772 |
|
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
773 |
this->FindWindowPlacementAndResize(desc); |
10645 | 774 |
} |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
775 |
|
10645 | 776 |
virtual void OnPaint() |
777 |
{ |
|
778 |
/* lower the non-selected gender button */ |
|
779 |
this->SetWidgetLoweredState(PFW_WIDGET_MALE, !this->is_female); |
|
780 |
this->SetWidgetLoweredState(PFW_WIDGET_FEMALE, this->is_female); |
|
781 |
||
782 |
/* advanced player face selection window */ |
|
783 |
if (this->advanced) { |
|
784 |
/* lower the non-selected ethnicity button */ |
|
785 |
this->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_EUR, !HasBit(this->ge, ETHNICITY_BLACK)); |
|
786 |
this->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_AFR, HasBit(this->ge, ETHNICITY_BLACK)); |
|
787 |
||
788 |
||
789 |
/* Disable dynamically the widgets which PlayerFaceVariable has less than 2 options |
|
790 |
* (or in other words you haven't any choice). |
|
791 |
* If the widgets depend on a HAS-variable and this is false the widgets will be disabled, too. */ |
|
792 |
||
793 |
/* Eye colour buttons */ |
|
794 |
this->SetWidgetsDisabledState(_pf_info[PFV_EYE_COLOUR].valid_values[this->ge] < 2, |
|
795 |
PFW_WIDGET_EYECOLOUR, PFW_WIDGET_EYECOLOUR_L, PFW_WIDGET_EYECOLOUR_R, WIDGET_LIST_END); |
|
796 |
||
797 |
/* Chin buttons */ |
|
798 |
this->SetWidgetsDisabledState(_pf_info[PFV_CHIN].valid_values[this->ge] < 2, |
|
799 |
PFW_WIDGET_CHIN, PFW_WIDGET_CHIN_L, PFW_WIDGET_CHIN_R, WIDGET_LIST_END); |
|
800 |
||
801 |
/* Eyebrows buttons */ |
|
802 |
this->SetWidgetsDisabledState(_pf_info[PFV_EYEBROWS].valid_values[this->ge] < 2, |
|
803 |
PFW_WIDGET_EYEBROWS, PFW_WIDGET_EYEBROWS_L, PFW_WIDGET_EYEBROWS_R, WIDGET_LIST_END); |
|
804 |
||
805 |
/* Lips or (if it a male face with a moustache) moustache buttons */ |
|
806 |
this->SetWidgetsDisabledState(_pf_info[this->is_moust_male ? PFV_MOUSTACHE : PFV_LIPS].valid_values[this->ge] < 2, |
|
807 |
PFW_WIDGET_LIPS_MOUSTACHE, PFW_WIDGET_LIPS_MOUSTACHE_L, PFW_WIDGET_LIPS_MOUSTACHE_R, WIDGET_LIST_END); |
|
808 |
||
809 |
/* Nose buttons | male faces with moustache haven't any nose options */ |
|
810 |
this->SetWidgetsDisabledState(_pf_info[PFV_NOSE].valid_values[this->ge] < 2 || this->is_moust_male, |
|
811 |
PFW_WIDGET_NOSE, PFW_WIDGET_NOSE_L, PFW_WIDGET_NOSE_R, WIDGET_LIST_END); |
|
812 |
||
813 |
/* Hair buttons */ |
|
814 |
this->SetWidgetsDisabledState(_pf_info[PFV_HAIR].valid_values[this->ge] < 2, |
|
815 |
PFW_WIDGET_HAIR, PFW_WIDGET_HAIR_L, PFW_WIDGET_HAIR_R, WIDGET_LIST_END); |
|
816 |
||
817 |
/* Jacket buttons */ |
|
818 |
this->SetWidgetsDisabledState(_pf_info[PFV_JACKET].valid_values[this->ge] < 2, |
|
819 |
PFW_WIDGET_JACKET, PFW_WIDGET_JACKET_L, PFW_WIDGET_JACKET_R, WIDGET_LIST_END); |
|
820 |
||
821 |
/* Collar buttons */ |
|
822 |
this->SetWidgetsDisabledState(_pf_info[PFV_COLLAR].valid_values[this->ge] < 2, |
|
823 |
PFW_WIDGET_COLLAR, PFW_WIDGET_COLLAR_L, PFW_WIDGET_COLLAR_R, WIDGET_LIST_END); |
|
824 |
||
825 |
/* Tie/earring buttons | female faces without earring haven't any earring options */ |
|
826 |
this->SetWidgetsDisabledState(_pf_info[PFV_TIE_EARRING].valid_values[this->ge] < 2 || |
|
827 |
(this->is_female && GetPlayerFaceBits(this->face, PFV_HAS_TIE_EARRING, this->ge) == 0), |
|
828 |
PFW_WIDGET_TIE_EARRING, PFW_WIDGET_TIE_EARRING_L, PFW_WIDGET_TIE_EARRING_R, WIDGET_LIST_END); |
|
829 |
||
830 |
/* Glasses buttons | faces without glasses haven't any glasses options */ |
|
831 |
this->SetWidgetsDisabledState(_pf_info[PFV_GLASSES].valid_values[this->ge] < 2 || GetPlayerFaceBits(this->face, PFV_HAS_GLASSES, this->ge) == 0, |
|
832 |
PFW_WIDGET_GLASSES, PFW_WIDGET_GLASSES_L, PFW_WIDGET_GLASSES_R, WIDGET_LIST_END); |
|
833 |
} |
|
834 |
||
835 |
this->DrawWidgets(); |
|
836 |
||
837 |
/* Draw dynamic button value and labels for the advanced player face selection window */ |
|
838 |
if (this->advanced) { |
|
839 |
if (this->is_female) { |
|
840 |
/* Only for female faces */ |
|
841 |
this->DrawFaceStringLabel(PFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_EARRING, GetPlayerFaceBits(this->face, PFV_HAS_TIE_EARRING, this->ge), true ); |
|
842 |
this->DrawFaceStringLabel(PFW_WIDGET_TIE_EARRING, STR_FACE_EARRING, GetPlayerFaceBits(this->face, PFV_TIE_EARRING, this->ge), false); |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
843 |
} else { |
10645 | 844 |
/* Only for male faces */ |
845 |
this->DrawFaceStringLabel(PFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_MOUSTACHE, GetPlayerFaceBits(this->face, PFV_HAS_MOUSTACHE, this->ge), true ); |
|
846 |
this->DrawFaceStringLabel(PFW_WIDGET_TIE_EARRING, STR_FACE_TIE, GetPlayerFaceBits(this->face, PFV_TIE_EARRING, this->ge), false); |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
847 |
} |
10645 | 848 |
if (this->is_moust_male) { |
849 |
/* Only for male faces with moustache */ |
|
850 |
this->DrawFaceStringLabel(PFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_MOUSTACHE, GetPlayerFaceBits(this->face, PFV_MOUSTACHE, this->ge), false); |
|
851 |
} else { |
|
852 |
/* Only for female faces or male faces without moustache */ |
|
853 |
this->DrawFaceStringLabel(PFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_LIPS, GetPlayerFaceBits(this->face, PFV_LIPS, this->ge), false); |
|
854 |
} |
|
855 |
/* For all faces */ |
|
856 |
this->DrawFaceStringLabel(PFW_WIDGET_HAS_GLASSES, STR_FACE_GLASSES, GetPlayerFaceBits(this->face, PFV_HAS_GLASSES, this->ge), true ); |
|
857 |
this->DrawFaceStringLabel(PFW_WIDGET_HAIR, STR_FACE_HAIR, GetPlayerFaceBits(this->face, PFV_HAIR, this->ge), false); |
|
858 |
this->DrawFaceStringLabel(PFW_WIDGET_EYEBROWS, STR_FACE_EYEBROWS, GetPlayerFaceBits(this->face, PFV_EYEBROWS, this->ge), false); |
|
859 |
this->DrawFaceStringLabel(PFW_WIDGET_EYECOLOUR, STR_FACE_EYECOLOUR, GetPlayerFaceBits(this->face, PFV_EYE_COLOUR, this->ge), false); |
|
860 |
this->DrawFaceStringLabel(PFW_WIDGET_GLASSES, STR_FACE_GLASSES, GetPlayerFaceBits(this->face, PFV_GLASSES, this->ge), false); |
|
861 |
this->DrawFaceStringLabel(PFW_WIDGET_NOSE, STR_FACE_NOSE, GetPlayerFaceBits(this->face, PFV_NOSE, this->ge), false); |
|
862 |
this->DrawFaceStringLabel(PFW_WIDGET_CHIN, STR_FACE_CHIN, GetPlayerFaceBits(this->face, PFV_CHIN, this->ge), false); |
|
863 |
this->DrawFaceStringLabel(PFW_WIDGET_JACKET, STR_FACE_JACKET, GetPlayerFaceBits(this->face, PFV_JACKET, this->ge), false); |
|
864 |
this->DrawFaceStringLabel(PFW_WIDGET_COLLAR, STR_FACE_COLLAR, GetPlayerFaceBits(this->face, PFV_COLLAR, this->ge), false); |
|
865 |
} |
|
866 |
||
867 |
/* Draw the player face picture */ |
|
868 |
DrawPlayerFace(this->face, GetPlayer((PlayerID)this->window_number)->player_color, 2, 16); |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
869 |
} |
10645 | 870 |
|
871 |
virtual void OnClick(Point pt, int widget) |
|
872 |
{ |
|
873 |
switch (widget) { |
|
874 |
/* Toggle size, advanced/simple face selection */ |
|
875 |
case PFW_WIDGET_TOGGLE_LARGE_SMALL: |
|
876 |
case PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON: { |
|
877 |
DoCommandP(0, 0, this->face, NULL, CMD_SET_PLAYER_FACE); |
|
878 |
||
879 |
/* Backup some data before deletion */ |
|
880 |
int oldtop = this->top; ///< current top position of the window before closing it |
|
881 |
int oldleft = this->left; ///< current top position of the window before closing it |
|
882 |
bool adv = !this->advanced; |
|
883 |
Window *parent = this->parent; |
|
884 |
||
885 |
delete this; |
|
886 |
||
887 |
/* Open up the (toggled size) Face selection window at the same position as the previous */ |
|
888 |
DoSelectPlayerFace(parent, adv, oldtop, oldleft); |
|
889 |
} break; |
|
890 |
||
891 |
||
892 |
/* OK button */ |
|
893 |
case PFW_WIDGET_ACCEPT: |
|
894 |
DoCommandP(0, 0, this->face, NULL, CMD_SET_PLAYER_FACE); |
|
895 |
/* Fall-Through */ |
|
896 |
||
897 |
/* Cancel button */ |
|
898 |
case PFW_WIDGET_CANCEL: |
|
899 |
delete this; |
|
900 |
break; |
|
901 |
||
902 |
/* Load button */ |
|
903 |
case PFW_WIDGET_LOAD: |
|
904 |
this->face = _player_face; |
|
905 |
ScaleAllPlayerFaceBits(this->face); |
|
906 |
ShowErrorMessage(INVALID_STRING_ID, STR_FACE_LOAD_DONE, 0, 0); |
|
907 |
this->UpdateData(); |
|
908 |
this->SetDirty(); |
|
909 |
break; |
|
910 |
||
911 |
/* 'Player face number' button, view and/or set player face number */ |
|
912 |
case PFW_WIDGET_FACECODE: |
|
913 |
SetDParam(0, this->face); |
|
914 |
ShowQueryString(STR_JUST_INT, STR_FACE_FACECODE_CAPTION, 10 + 1, 0, this, CS_NUMERAL); |
|
915 |
break; |
|
916 |
||
917 |
/* Save button */ |
|
918 |
case PFW_WIDGET_SAVE: |
|
919 |
_player_face = this->face; |
|
920 |
ShowErrorMessage(INVALID_STRING_ID, STR_FACE_SAVE_DONE, 0, 0); |
|
921 |
break; |
|
922 |
||
923 |
/* Toggle gender (male/female) button */ |
|
924 |
case PFW_WIDGET_MALE: |
|
925 |
case PFW_WIDGET_FEMALE: |
|
926 |
SetPlayerFaceBits(this->face, PFV_GENDER, this->ge, widget - PFW_WIDGET_MALE); |
|
927 |
ScaleAllPlayerFaceBits(this->face); |
|
928 |
this->UpdateData(); |
|
929 |
this->SetDirty(); |
|
930 |
break; |
|
931 |
||
932 |
/* Randomize face button */ |
|
933 |
case PFW_WIDGET_RANDOM_NEW_FACE: |
|
934 |
RandomPlayerFaceBits(this->face, this->ge, this->advanced); |
|
935 |
this->UpdateData(); |
|
936 |
this->SetDirty(); |
|
937 |
break; |
|
938 |
||
939 |
/* Toggle ethnicity (european/african) button */ |
|
940 |
case PFW_WIDGET_ETHNICITY_EUR: |
|
941 |
case PFW_WIDGET_ETHNICITY_AFR: |
|
942 |
SetPlayerFaceBits(this->face, PFV_ETHNICITY, this->ge, widget - PFW_WIDGET_ETHNICITY_EUR); |
|
943 |
ScaleAllPlayerFaceBits(this->face); |
|
944 |
this->UpdateData(); |
|
945 |
this->SetDirty(); |
|
946 |
break; |
|
947 |
||
948 |
default: |
|
949 |
/* For all buttons from PFW_WIDGET_HAS_MOUSTACHE_EARRING to PFW_WIDGET_GLASSES_R is the same function. |
|
950 |
* Therefor is this combined function. |
|
951 |
* First it checks which PlayerFaceVariable will be change and then |
|
952 |
* a: invert the value for boolean variables |
|
953 |
* or b: it checks inside of IncreasePlayerFaceBits() if a left (_L) butten is pressed and then decrease else increase the variable */ |
|
954 |
if (this->advanced && widget >= PFW_WIDGET_HAS_MOUSTACHE_EARRING && widget <= PFW_WIDGET_GLASSES_R) { |
|
955 |
PlayerFaceVariable pfv; // which PlayerFaceVariable shall be edited |
|
956 |
||
957 |
if (widget < PFW_WIDGET_EYECOLOUR_L) { // Bool buttons |
|
958 |
switch (widget - PFW_WIDGET_HAS_MOUSTACHE_EARRING) { |
|
959 |
default: NOT_REACHED(); |
|
960 |
case 0: pfv = this->is_female ? PFV_HAS_TIE_EARRING : PFV_HAS_MOUSTACHE; break; // Has earring/moustache button |
|
961 |
case 1: pfv = PFV_HAS_GLASSES; break; // Has glasses button |
|
962 |
} |
|
963 |
SetPlayerFaceBits(this->face, pfv, this->ge, !GetPlayerFaceBits(this->face, pfv, this->ge)); |
|
964 |
ScaleAllPlayerFaceBits(this->face); |
|
965 |
} else { // Value buttons |
|
966 |
switch ((widget - PFW_WIDGET_EYECOLOUR_L) / 3) { |
|
967 |
default: NOT_REACHED(); |
|
968 |
case 0: pfv = PFV_EYE_COLOUR; break; // Eye colour buttons |
|
969 |
case 1: pfv = PFV_CHIN; break; // Chin buttons |
|
970 |
case 2: pfv = PFV_EYEBROWS; break; // Eyebrows buttons |
|
971 |
case 3: pfv = this->is_moust_male ? PFV_MOUSTACHE : PFV_LIPS; break; // Moustache or lips buttons |
|
972 |
case 4: pfv = PFV_NOSE; break; // Nose buttons |
|
973 |
case 5: pfv = PFV_HAIR; break; // Hair buttons |
|
974 |
case 6: pfv = PFV_JACKET; break; // Jacket buttons |
|
975 |
case 7: pfv = PFV_COLLAR; break; // Collar buttons |
|
976 |
case 8: pfv = PFV_TIE_EARRING; break; // Tie/earring buttons |
|
977 |
case 9: pfv = PFV_GLASSES; break; // Glasses buttons |
|
978 |
} |
|
979 |
/* 0 == left (_L), 1 == middle or 2 == right (_R) - button click */ |
|
980 |
IncreasePlayerFaceBits(this->face, pfv, this->ge, (((widget - PFW_WIDGET_EYECOLOUR_L) % 3) != 0) ? 1 : -1); |
|
981 |
} |
|
982 |
this->UpdateData(); |
|
983 |
this->SetDirty(); |
|
984 |
} |
|
985 |
break; |
|
986 |
} |
|
987 |
} |
|
988 |
||
989 |
virtual void OnQueryTextFinished(char *str) |
|
990 |
{ |
|
991 |
if (str == NULL) return; |
|
992 |
/* Set a new player face number */ |
|
993 |
if (!StrEmpty(str)) { |
|
994 |
this->face = strtoul(str, NULL, 10); |
|
995 |
ScaleAllPlayerFaceBits(this->face); |
|
996 |
ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_SET, 0, 0); |
|
997 |
this->UpdateData(); |
|
998 |
this->SetDirty(); |
|
999 |
} else { |
|
1000 |
ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_ERR, 0, 0); |
|
1001 |
} |
|
1002 |
} |
|
1003 |
}; |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1004 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1005 |
/** normal/simple player face selection window description */ |
0 | 1006 |
static const WindowDesc _select_player_face_desc = { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1007 |
WDP_AUTO, WDP_AUTO, 190, 163, 190, 163, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6105
diff
changeset
|
1008 |
WC_PLAYER_FACE, WC_NONE, |
0 | 1009 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
1010 |
_select_player_face_widgets, |
|
1011 |
}; |
|
1012 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1013 |
/** advanced player face selection window description */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1014 |
static const WindowDesc _select_player_face_adv_desc = { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1015 |
WDP_AUTO, WDP_AUTO, 220, 220, 220, 220, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1016 |
WC_PLAYER_FACE, WC_NONE, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1017 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1018 |
_select_player_face_adv_widgets, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1019 |
}; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1020 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1021 |
/** |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1022 |
* Open the simple/advanced player face selection window |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1023 |
* |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1024 |
* @param player the player which face shall be edited |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1025 |
* @param adv simple or advanced player face selection window |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
1026 |
* @param top previous top position of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
1027 |
* @param left previous left position of the window |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1028 |
* |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1029 |
* @pre is player a valid player |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1030 |
*/ |
10645 | 1031 |
static void DoSelectPlayerFace(Window *parent, bool adv, int top, int left) |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1032 |
{ |
10645 | 1033 |
if (!IsValidPlayer((PlayerID)parent->window_number)) return; |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1034 |
|
10645 | 1035 |
if (BringWindowToFrontById(WC_PLAYER_FACE, parent->window_number)) return; |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
1036 |
new SelectPlayerFaceWindow(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, parent, adv, top, left); // simple or advanced window |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1037 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1038 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1039 |
|
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1040 |
/* 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
|
1041 |
enum PlayerCompanyWindowWidgets { |
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1042 |
PCW_WIDGET_CLOSEBOX = 0, |
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1043 |
PCW_WIDGET_CAPTION, |
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1044 |
PCW_WIDGET_FACE, |
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1045 |
PCW_WIDGET_NEW_FACE, |
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1046 |
PCW_WIDGET_COLOR_SCHEME, |
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1047 |
PCW_WIDGET_PRESIDENT_NAME, |
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1048 |
PCW_WIDGET_COMPANY_NAME, |
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1049 |
PCW_WIDGET_BUILD_VIEW_HQ, |
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1050 |
PCW_WIDGET_RELOCATE_HQ, |
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1051 |
PCW_WIDGET_BUY_SHARE, |
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1052 |
PCW_WIDGET_SELL_SHARE, |
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1053 |
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
|
1054 |
}; |
0 | 1055 |
|
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1056 |
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
|
1057 |
{ 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
|
1058 |
{ 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
|
1059 |
{ 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
|
1060 |
{ 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
|
1061 |
{ 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
|
1062 |
{ 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
|
1063 |
{ 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
|
1064 |
{ 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
|
1065 |
{ 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
|
1066 |
{ 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
|
1067 |
{ 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
|
1068 |
{ 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
|
1069 |
{ WIDGETS_END}, |
0 | 1070 |
}; |
1071 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1072 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1073 |
/** |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1074 |
* Draws text "Vehicles:" and number of all vehicle types, or "(none)" |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1075 |
* @param player ID of player to print statistics of |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1076 |
*/ |
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
|
1077 |
static void DrawPlayerVehiclesAmount(PlayerID player) |
0 | 1078 |
{ |
1079 |
const int x = 110; |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1080 |
int y = 63; |
4171 | 1081 |
const Vehicle *v; |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1082 |
uint train = 0; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1083 |
uint road = 0; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1084 |
uint air = 0; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1085 |
uint ship = 0; |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
1086 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1087 |
DrawString(x, y, STR_7039_VEHICLES, TC_FROMSTRING); |
0 | 1088 |
|
1089 |
FOR_ALL_VEHICLES(v) { |
|
1090 |
if (v->owner == player) { |
|
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1091 |
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
|
1092 |
case VEH_TRAIN: if (IsFrontEngine(v)) train++; break; |
9627 | 1093 |
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
|
1094 |
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
|
1095 |
case VEH_SHIP: ship++; break; |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1096 |
default: break; |
0 | 1097 |
} |
1098 |
} |
|
1099 |
} |
|
1100 |
||
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9505
diff
changeset
|
1101 |
if (train + road + air + ship == 0) { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1102 |
DrawString(x + 70, y, STR_7042_NONE, TC_FROMSTRING); |
0 | 1103 |
} else { |
1104 |
if (train != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1105 |
SetDParam(0, train); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1106 |
DrawString(x + 70, y, STR_TRAINS, TC_FROMSTRING); |
0 | 1107 |
y += 10; |
1108 |
} |
|
1109 |
||
1110 |
if (road != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1111 |
SetDParam(0, road); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1112 |
DrawString(x + 70, y, STR_ROAD_VEHICLES, TC_FROMSTRING); |
0 | 1113 |
y += 10; |
1114 |
} |
|
1115 |
||
1116 |
if (air != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1117 |
SetDParam(0, air); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1118 |
DrawString(x + 70, y, STR_AIRCRAFT, TC_FROMSTRING); |
0 | 1119 |
y += 10; |
1120 |
} |
|
1121 |
||
1122 |
if (ship != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1123 |
SetDParam(0, ship); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1124 |
DrawString(x + 70, y, STR_SHIPS, TC_FROMSTRING); |
0 | 1125 |
} |
1126 |
} |
|
1127 |
} |
|
1128 |
||
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
|
1129 |
int GetAmountOwnedBy(const Player *p, PlayerID owner) |
0 | 1130 |
{ |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
1131 |
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
|
1132 |
(p->share_owners[1] == owner) + |
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
1133 |
(p->share_owners[2] == owner) + |
0 | 1134 |
(p->share_owners[3] == owner); |
1135 |
} |
|
1136 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1137 |
/** |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1138 |
* Draws list of all companies with shares |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1139 |
* @param p pointer to the Player structure |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1140 |
*/ |
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
|
1141 |
static void DrawCompanyOwnerText(const Player *p) |
0 | 1142 |
{ |
4171 | 1143 |
const Player *p2; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1144 |
uint num = 0; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1145 |
const byte height = GetCharacterHeight(FS_NORMAL); |
0 | 1146 |
|
1147 |
FOR_ALL_PLAYERS(p2) { |
|
2549 | 1148 |
uint amt = GetAmountOwnedBy(p, p2->index); |
1149 |
if (amt != 0) { |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1150 |
SetDParam(0, amt * 25); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1151 |
SetDParam(1, p2->index); |
0 | 1152 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1153 |
DrawString(120, (num++) * height + 116, STR_707D_OWNED_BY, TC_FROMSTRING); |
0 | 1154 |
} |
1155 |
} |
|
1156 |
} |
|
1157 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1158 |
/** |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1159 |
* Player company window event definition |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1160 |
* |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1161 |
* @param w window pointer |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1162 |
* @param e event been triggered |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1163 |
*/ |
10645 | 1164 |
struct PlayerCompanyWindow : Window |
0 | 1165 |
{ |
10645 | 1166 |
PlayerCompanyWindowWidgets query_widget; |
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1167 |
|
10645 | 1168 |
PlayerCompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
1169 |
{ |
|
1170 |
this->caption_color = this->window_number; |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
1171 |
this->FindWindowPlacementAndResize(desc); |
10645 | 1172 |
} |
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1173 |
|
10645 | 1174 |
virtual void OnPaint() |
1175 |
{ |
|
1176 |
const Player *p = GetPlayer((PlayerID)this->window_number); |
|
1177 |
bool local = this->window_number == _local_player; |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1178 |
|
10645 | 1179 |
this->SetWidgetHiddenState(PCW_WIDGET_NEW_FACE, !local); |
1180 |
this->SetWidgetHiddenState(PCW_WIDGET_COLOR_SCHEME, !local); |
|
1181 |
this->SetWidgetHiddenState(PCW_WIDGET_PRESIDENT_NAME, !local); |
|
1182 |
this->SetWidgetHiddenState(PCW_WIDGET_COMPANY_NAME, !local); |
|
1183 |
this->widget[PCW_WIDGET_BUILD_VIEW_HQ].data = (local && p->location_of_house == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ; |
|
1184 |
if (local && p->location_of_house != 0) this->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built. |
|
1185 |
this->SetWidgetDisabledState(PCW_WIDGET_BUILD_VIEW_HQ, !local && p->location_of_house == 0); |
|
1186 |
this->SetWidgetHiddenState(PCW_WIDGET_RELOCATE_HQ, !local || p->location_of_house == 0); |
|
1187 |
this->SetWidgetHiddenState(PCW_WIDGET_BUY_SHARE, local); |
|
1188 |
this->SetWidgetHiddenState(PCW_WIDGET_SELL_SHARE, local); |
|
1189 |
this->SetWidgetHiddenState(PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking); |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1190 |
|
10645 | 1191 |
if (!local) { |
10776 | 1192 |
if (_settings_game.economy.allow_shares) { // Shares are allowed |
10645 | 1193 |
/* If all shares are owned by someone (none by nobody), disable buy button */ |
1194 |
this->SetWidgetDisabledState(PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 || |
|
1195 |
/* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */ |
|
1196 |
(GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) || |
|
1197 |
/* Spectators cannot do anything of course */ |
|
1198 |
_local_player == PLAYER_SPECTATOR); |
|
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1199 |
|
10645 | 1200 |
/* If the player doesn't own any shares, disable sell button */ |
1201 |
this->SetWidgetDisabledState(PCW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(p, _local_player) == 0) || |
|
1202 |
/* Spectators cannot do anything of course */ |
|
1203 |
_local_player == PLAYER_SPECTATOR); |
|
1204 |
} else { // Shares are not allowed, disable buy/sell buttons |
|
1205 |
this->DisableWidget(PCW_WIDGET_BUY_SHARE); |
|
1206 |
this->DisableWidget(PCW_WIDGET_SELL_SHARE); |
|
1207 |
} |
|
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
|
1208 |
} |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
1209 |
|
10645 | 1210 |
SetDParam(0, p->index); |
1211 |
SetDParam(1, p->index); |
|
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1212 |
|
10645 | 1213 |
this->DrawWidgets(); |
1214 |
||
1215 |
/* Player face */ |
|
1216 |
DrawPlayerFace(p->face, p->player_color, 2, 16); |
|
1217 |
||
1218 |
/* "xxx (Manager)" */ |
|
1219 |
SetDParam(0, p->index); |
|
1220 |
DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94); |
|
1221 |
||
1222 |
/* "Inaugurated:" */ |
|
1223 |
SetDParam(0, p->inaugurated_year); |
|
1224 |
DrawString(110, 23, STR_7038_INAUGURATED, TC_FROMSTRING); |
|
1225 |
||
1226 |
/* "Colour scheme:" */ |
|
1227 |
DrawString(110, 43, STR_7006_COLOR_SCHEME, TC_FROMSTRING); |
|
1228 |
/* Draw company-colour bus */ |
|
1229 |
DrawSprite(SPR_VEH_BUS_SW_VIEW, PLAYER_SPRITE_COLOR(p->index), 215, 44); |
|
1230 |
||
1231 |
/* "Vehicles:" */ |
|
1232 |
DrawPlayerVehiclesAmount((PlayerID)this->window_number); |
|
1233 |
||
1234 |
/* "Company value:" */ |
|
1235 |
SetDParam(0, CalculateCompanyValue(p)); |
|
1236 |
DrawString(110, 106, STR_7076_COMPANY_VALUE, TC_FROMSTRING); |
|
1237 |
||
1238 |
/* Shares list */ |
|
1239 |
DrawCompanyOwnerText(p); |
|
1240 |
} |
|
1241 |
||
1242 |
virtual void OnClick(Point pt, int widget) |
|
1243 |
{ |
|
1244 |
switch (widget) { |
|
1245 |
case PCW_WIDGET_NEW_FACE: DoSelectPlayerFace(this, false); break; |
|
1246 |
||
1247 |
case PCW_WIDGET_COLOR_SCHEME: |
|
1248 |
if (BringWindowToFrontById(WC_PLAYER_COLOR, this->window_number)) break; |
|
1249 |
new SelectPlayerLiveryWindow(&_select_player_livery_desc, (PlayerID)this->window_number); |
|
1250 |
break; |
|
1251 |
||
1252 |
case PCW_WIDGET_PRESIDENT_NAME: |
|
1253 |
this->query_widget = PCW_WIDGET_PRESIDENT_NAME; |
|
1254 |
SetDParam(0, this->window_number); |
|
1255 |
ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, 31, 94, this, CS_ALPHANUMERAL); |
|
1256 |
break; |
|
1257 |
||
1258 |
case PCW_WIDGET_COMPANY_NAME: |
|
1259 |
this->query_widget = PCW_WIDGET_COMPANY_NAME; |
|
1260 |
SetDParam(0, this->window_number); |
|
1261 |
ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, 31, 150, this, CS_ALPHANUMERAL); |
|
1262 |
break; |
|
1263 |
||
1264 |
case PCW_WIDGET_BUILD_VIEW_HQ: { |
|
1265 |
TileIndex tile = GetPlayer((PlayerID)this->window_number)->location_of_house; |
|
1266 |
if (tile == 0) { |
|
1267 |
if ((byte)this->window_number != _local_player) return; |
|
1268 |
SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this); |
|
1269 |
SetTileSelectSize(2, 2); |
|
1270 |
this->LowerWidget(PCW_WIDGET_BUILD_VIEW_HQ); |
|
1271 |
this->InvalidateWidget(PCW_WIDGET_BUILD_VIEW_HQ); |
|
1272 |
} else { |
|
1273 |
if (_ctrl_pressed) { |
|
1274 |
ShowExtraViewPortWindow(tile); |
|
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1275 |
} else { |
10645 | 1276 |
ScrollMainWindowToTile(tile); |
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1277 |
} |
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1278 |
} |
10645 | 1279 |
break; |
1280 |
} |
|
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1281 |
|
10645 | 1282 |
case PCW_WIDGET_RELOCATE_HQ: |
1283 |
SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this); |
|
1284 |
SetTileSelectSize(2, 2); |
|
1285 |
this->LowerWidget(PCW_WIDGET_RELOCATE_HQ); |
|
1286 |
this->InvalidateWidget(PCW_WIDGET_RELOCATE_HQ); |
|
1287 |
break; |
|
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1288 |
|
10645 | 1289 |
case PCW_WIDGET_BUY_SHARE: |
1290 |
DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS)); |
|
1291 |
break; |
|
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1292 |
|
10645 | 1293 |
case PCW_WIDGET_SELL_SHARE: |
1294 |
DoCommandP(0, this->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN)); |
|
1295 |
break; |
|
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1296 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1297 |
#ifdef ENABLE_NETWORK |
10645 | 1298 |
case PCW_WIDGET_COMPANY_PASSWORD: |
1299 |
if (this->window_number == _local_player) ShowNetworkCompanyPasswordWindow(this); |
|
1300 |
break; |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1301 |
#endif /* ENABLE_NETWORK */ |
10645 | 1302 |
} |
1303 |
} |
|
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
|
1304 |
|
10776 | 1305 |
virtual void OnHundredthTick() |
10645 | 1306 |
{ |
1307 |
/* redraw the window every now and then */ |
|
10776 | 1308 |
this->SetDirty(); |
10645 | 1309 |
} |
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1310 |
|
10645 | 1311 |
virtual void OnPlaceObject(Point pt, TileIndex tile) |
1312 |
{ |
|
1313 |
if (DoCommandP(tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS))) |
|
1314 |
ResetObjectToPlace(); |
|
1315 |
this->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button |
|
1316 |
this->RaiseButtons(); |
|
0 | 1317 |
} |
1318 |
||
10645 | 1319 |
virtual void OnPlaceObjectAbort() |
1320 |
{ |
|
1321 |
this->RaiseButtons(); |
|
1322 |
} |
|
1323 |
||
1324 |
virtual void OnQueryTextFinished(char *str) |
|
1325 |
{ |
|
1326 |
if (StrEmpty(str)) return; |
|
1327 |
||
1328 |
_cmd_text = str; |
|
1329 |
switch (this->query_widget) { |
|
1330 |
default: NOT_REACHED(); |
|
1331 |
||
1332 |
case PCW_WIDGET_PRESIDENT_NAME: |
|
1333 |
DoCommandP(0, 0, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT)); |
|
1334 |
break; |
|
1335 |
||
1336 |
case PCW_WIDGET_COMPANY_NAME: |
|
1337 |
DoCommandP(0, 0, 0, NULL, CMD_CHANGE_COMPANY_NAME | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME)); |
|
1338 |
break; |
|
1339 |
} |
|
1340 |
} |
|
1341 |
}; |
|
0 | 1342 |
|
4746
693a7e43596d
(svn r6658) -CodeChange: cleaned up the PlayerCompanyWindow code
glx
parents:
4744
diff
changeset
|
1343 |
static const WindowDesc _player_company_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1344 |
WDP_AUTO, WDP_AUTO, 360, 170, 360, 170, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6105
diff
changeset
|
1345 |
WC_COMPANY, WC_NONE, |
0 | 1346 |
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
|
1347 |
_player_company_widgets, |
0 | 1348 |
}; |
1349 |
||
2475 | 1350 |
void ShowPlayerCompany(PlayerID player) |
0 | 1351 |
{ |
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4998
diff
changeset
|
1352 |
if (!IsValidPlayer(player)) return; |
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4998
diff
changeset
|
1353 |
|
10645 | 1354 |
AllocateWindowDescFront<PlayerCompanyWindow>(&_player_company_desc, player); |
0 | 1355 |
} |
1356 |
||
1357 |
||
1358 |
||
10645 | 1359 |
struct BuyCompanyWindow : Window { |
1360 |
BuyCompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
|
1361 |
{ |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
1362 |
this->FindWindowPlacementAndResize(desc); |
10645 | 1363 |
} |
0 | 1364 |
|
10645 | 1365 |
virtual void OnPaint() |
1366 |
{ |
|
1367 |
Player *p = GetPlayer((PlayerID)this->window_number); |
|
1368 |
SetDParam(0, STR_COMPANY_NAME); |
|
1369 |
SetDParam(1, p->index); |
|
1370 |
this->DrawWidgets(); |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
1371 |
|
10645 | 1372 |
DrawPlayerFace(p->face, p->player_color, 2, 16); |
1373 |
||
1374 |
SetDParam(0, p->index); |
|
1375 |
SetDParam(1, p->bankrupt_value); |
|
1376 |
DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238); |
|
0 | 1377 |
} |
10645 | 1378 |
|
1379 |
virtual void OnClick(Point pt, int widget) |
|
1380 |
{ |
|
1381 |
switch (widget) { |
|
1382 |
case 3: |
|
1383 |
delete this; |
|
1384 |
break; |
|
1385 |
||
1386 |
case 4: |
|
1387 |
DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY)); |
|
1388 |
break; |
|
1389 |
} |
|
1390 |
} |
|
1391 |
}; |
|
0 | 1392 |
|
1393 |
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
|
1394 |
{ 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
|
1395 |
{ 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
|
1396 |
{ 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
|
1397 |
{ 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
|
1398 |
{ 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
|
1399 |
{ WIDGETS_END}, |
0 | 1400 |
}; |
1401 |
||
1402 |
static const WindowDesc _buy_company_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1403 |
153, 171, 334, 137, 334, 137, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6105
diff
changeset
|
1404 |
WC_BUY_COMPANY, WC_NONE, |
0 | 1405 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1406 |
_buy_company_widgets, |
|
1407 |
}; |
|
1408 |
||
1409 |
||
1410 |
void ShowBuyCompanyDialog(uint player) |
|
1411 |
{ |
|
10645 | 1412 |
AllocateWindowDescFront<BuyCompanyWindow>(&_buy_company_desc, player); |
0 | 1413 |
} |
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
|
1414 |
|
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
|
1415 |
/********** 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
|
1416 |
|
10645 | 1417 |
extern StringID EndGameGetPerformanceTitleFromValue(uint value); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
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 |
|
10645 | 1420 |
struct EndGameHighScoreBaseWindow : Window |
1421 |
{ |
|
1422 |
uint32 background_img; |
|
1423 |
int8 rank; |
|
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
1424 |
|
10645 | 1425 |
EndGameHighScoreBaseWindow(const WindowDesc *desc) : Window(desc) |
1426 |
{ |
|
1427 |
} |
|
1428 |
||
1429 |
/* Always draw a maximized window and within there the centered background */ |
|
1430 |
void SetupHighScoreEndWindow(uint *x, uint *y) |
|
1431 |
{ |
|
1432 |
/* resize window to "full-screen" */ |
|
1433 |
this->width = _screen.width; |
|
1434 |
this->height = _screen.height; |
|
1435 |
this->widget[0].right = this->width - 1; |
|
1436 |
this->widget[0].bottom = this->height - 1; |
|
1437 |
||
1438 |
this->DrawWidgets(); |
|
1439 |
||
1440 |
/* Center Highscore/Endscreen background */ |
|
1441 |
*x = max(0, (_screen.width / 2) - (640 / 2)); |
|
1442 |
*y = max(0, (_screen.height / 2) - (480 / 2)); |
|
1443 |
for (uint i = 0; i < 10; i++) { // the image is split into 10 50px high parts |
|
1444 |
DrawSprite(this->background_img + i, PAL_NONE, *x, *y + (i * 50)); |
|
1445 |
} |
|
1446 |
} |
|
1447 |
||
1448 |
virtual void OnClick(Point pt, int widget) |
|
1449 |
{ |
|
1450 |
delete this; |
|
1451 |
} |
|
1452 |
}; |
|
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
|
1453 |
|
9505 | 1454 |
/** End game window shown at the end of the game */ |
10645 | 1455 |
struct EndGameWindow : EndGameHighScoreBaseWindow { |
1456 |
EndGameWindow(const WindowDesc *desc) : EndGameHighScoreBaseWindow(desc) |
|
1457 |
{ |
|
1458 |
/* Pause in single-player to have a look at the highscore at your own leisure */ |
|
1459 |
if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
1460 |
|
10645 | 1461 |
this->background_img = SPR_TYCOON_IMG1_BEGIN; |
1462 |
||
1463 |
if (_local_player != PLAYER_SPECTATOR) { |
|
1464 |
const Player *p = GetPlayer(_local_player); |
|
1465 |
if (p->old_economy[0].performance_history == SCORE_MAX) { |
|
1466 |
this->background_img = SPR_TYCOON_IMG2_BEGIN; |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
1467 |
} |
10645 | 1468 |
} |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
1469 |
|
10645 | 1470 |
/* In a network game show the endscores of the custom difficulty 'network' which is the last one |
1471 |
* as well as generate a TOP5 of that game, and not an all-time top5. */ |
|
1472 |
if (_networking) { |
|
1473 |
this->window_number = lengthof(_highscore_table) - 1; |
|
1474 |
this->rank = SaveHighScoreValueNetwork(); |
|
1475 |
} else { |
|
1476 |
/* in single player _local player is always valid */ |
|
1477 |
const Player *p = GetPlayer(_local_player); |
|
10776 | 1478 |
this->window_number = _settings_game.difficulty.diff_level; |
10645 | 1479 |
this->rank = SaveHighScoreValue(p); |
1480 |
} |
|
1481 |
||
1482 |
MarkWholeScreenDirty(); |
|
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
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 |
|
10645 | 1485 |
~EndGameWindow() |
1486 |
{ |
|
1487 |
if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause |
|
1488 |
ShowHighscoreTable(this->window_number, this->rank); |
|
1489 |
} |
|
1490 |
||
1491 |
virtual void OnPaint() |
|
1492 |
{ |
|
1493 |
const Player *p; |
|
1494 |
uint x, y; |
|
1495 |
||
1496 |
this->SetupHighScoreEndWindow(&x, &y); |
|
1497 |
||
1498 |
if (!IsValidPlayer(_local_player)) return; |
|
1499 |
||
1500 |
p = GetPlayer(_local_player); |
|
1501 |
/* We need to get performance from last year because the image is shown |
|
1502 |
* at the start of the new year when these things have already been copied */ |
|
1503 |
if (this->background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/ |
|
1504 |
SetDParam(0, p->index); |
|
1505 |
SetDParam(1, p->index); |
|
1506 |
SetDParam(2, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history)); |
|
1507 |
DrawStringMultiCenter(x + (640 / 2), y + 107, STR_021C_OF_ACHIEVES_STATUS, 640); |
|
1508 |
} else { |
|
1509 |
SetDParam(0, p->index); |
|
1510 |
SetDParam(1, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history)); |
|
1511 |
DrawStringMultiCenter(x + (640 / 2), y + 157, STR_021B_ACHIEVES_STATUS, 640); |
|
1512 |
} |
|
1513 |
} |
|
1514 |
}; |
|
1515 |
||
1516 |
struct HighScoreWindow : EndGameHighScoreBaseWindow |
|
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
1517 |
{ |
10645 | 1518 |
HighScoreWindow(const WindowDesc *desc, int difficulty, int8 ranking) : EndGameHighScoreBaseWindow(desc) |
1519 |
{ |
|
1520 |
/* pause game to show the chart */ |
|
1521 |
if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
|
1839
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
1522 |
|
10645 | 1523 |
/* Close all always on-top windows to get a clean screen */ |
1524 |
if (_game_mode != GM_MENU) HideVitalWindows(); |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
1525 |
|
10645 | 1526 |
MarkWholeScreenDirty(); |
1527 |
this->window_number = difficulty; // show highscore chart for difficulty... |
|
1528 |
this->background_img = SPR_HIGHSCORE_CHART_BEGIN; // which background to show |
|
1529 |
this->rank = ranking; |
|
1530 |
} |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
1531 |
|
10645 | 1532 |
~HighScoreWindow() |
1533 |
{ |
|
1534 |
if (_game_mode != GM_MENU) ShowVitalWindows(); |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
1535 |
|
10645 | 1536 |
if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause |
1537 |
} |
|
1538 |
||
1539 |
virtual void OnPaint() |
|
1540 |
{ |
|
1541 |
const HighScore *hs = _highscore_table[this->window_number]; |
|
1542 |
uint x, y; |
|
1543 |
||
1544 |
this->SetupHighScoreEndWindow(&x, &y); |
|
1545 |
||
10776 | 1546 |
SetDParam(0, _settings_client.gui.ending_year); |
10645 | 1547 |
SetDParam(1, this->window_number + STR_6801_EASY); |
1548 |
DrawStringMultiCenter(x + (640 / 2), y + 62, !_networking ? STR_0211_TOP_COMPANIES_WHO_REACHED : STR_TOP_COMPANIES_NETWORK_GAME, 500); |
|
1549 |
||
1550 |
/* Draw Highscore peepz */ |
|
1551 |
for (uint8 i = 0; i < lengthof(_highscore_table[0]); i++) { |
|
1552 |
SetDParam(0, i + 1); |
|
1553 |
DrawString(x + 40, y + 140 + (i * 55), STR_0212, TC_BLACK); |
|
1554 |
||
1555 |
if (hs[i].company[0] != '\0') { |
|
1556 |
TextColour colour = (this->rank == i) ? TC_RED : TC_BLACK; // draw new highscore in red |
|
1557 |
||
1558 |
DoDrawString(hs[i].company, x + 71, y + 140 + (i * 55), colour); |
|
1559 |
SetDParam(0, hs[i].title); |
|
1560 |
SetDParam(1, hs[i].score); |
|
1561 |
DrawString(x + 71, y + 160 + (i * 55), STR_HIGHSCORE_STATS, colour); |
|
1562 |
} |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9732
diff
changeset
|
1563 |
} |
10645 | 1564 |
} |
1565 |
}; |
|
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
|
1566 |
|
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
|
1567 |
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
|
1568 |
{ 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
|
1569 |
{ 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
|
1570 |
}; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
1571 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
1572 |
static const WindowDesc _highscore_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1573 |
0, 0, 641, 481, 641, 481, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6105
diff
changeset
|
1574 |
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
|
1575 |
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
|
1576 |
_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
|
1577 |
}; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
1578 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
1579 |
static const WindowDesc _endgame_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1580 |
0, 0, 641, 481, 641, 481, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6105
diff
changeset
|
1581 |
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
|
1582 |
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
|
1583 |
_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
|
1584 |
}; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
1585 |
|
9505 | 1586 |
/** 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
|
1587 |
* 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
|
1588 |
* 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
|
1589 |
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
|
1590 |
{ |
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
|
1591 |
DeleteWindowByClass(WC_HIGHSCORE); |
10645 | 1592 |
new HighScoreWindow(&_highscore_desc, difficulty, ranking); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
1593 |
} |
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
|
1594 |
|
9505 | 1595 |
/** 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
|
1596 |
* if it was high enough */ |
6573 | 1597 |
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
|
1598 |
{ |
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
|
1599 |
/* 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
|
1600 |
if (_network_dedicated) return; |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
1601 |
|
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
|
1602 |
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
|
1603 |
DeleteWindowByClass(WC_ENDSCREEN); |
10645 | 1604 |
new EndGameWindow(&_endgame_desc); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
1605 |
} |