annotate src/player_gui.cpp @ 8116:9cc845deddfe draft

(svn r11677) -Codechange: move price and command related types/functions to their respective places.
author rubidium <rubidium@openttd.org>
date Fri, 21 Dec 2007 21:50:46 +0000
parents 2d6af5d7a142
children 89722abcfd91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
6352
d646bb89ca43 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas <belugas@openttd.org>
parents: 6259
diff changeset
3 /** @file player_gui.cpp */
d646bb89ca43 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas <belugas@openttd.org>
parents: 6259
diff changeset
4
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
5 #include "stdafx.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
6 #include "openttd.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
7 #include "table/sprites.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
8 #include "table/strings.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
9 #include "functions.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
10 #include "gui.h"
8107
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
11 #include "window_gui.h"
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
12 #include "textbuf_gui.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
13 #include "viewport.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
14 #include "gfx.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
15 #include "player.h"
8116
9cc845deddfe (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents: 8114
diff changeset
16 #include "command_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
17 #include "vehicle.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
18 #include "network/network.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
19 #include "variables.h"
6857
0005a9ed1903 (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros <maedhros@openttd.org>
parents: 6769
diff changeset
20 #include "roadveh.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
21 #include "train.h"
5854
b52317eb405c (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 <Darkvater@openttd.org>
parents: 5668
diff changeset
22 #include "aircraft.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
23 #include "date.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
24 #include "newgrf.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
25 #include "network/network_data.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
26 #include "network/network_client.h"
7998
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7997
diff changeset
27 #include "network/network_gui.h"
6190
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
28 #include "player_face.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8107
diff changeset
29 #include "strings_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
30
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
31 static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied);
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
32 static void DoSelectPlayerFace(PlayerID player, bool show_big);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
33
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
34 static void DrawPlayerEconomyStats(const Player *p, byte mode)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
35 {
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6352
diff changeset
36 int x, y, i, j, year;
6990
a19700261804 (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium <rubidium@openttd.org>
parents: 6952
diff changeset
37 const Money (*tbl)[13];
a19700261804 (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium <rubidium@openttd.org>
parents: 6952
diff changeset
38 Money sum, cost;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
39 StringID str;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
40
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
41 if (!(mode & 1)) { // normal sized economics window (mode&1) is minimized status
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
42 /* draw categories */
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
43 DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
44 for (i = 0; i != 13; i++)
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
45 DrawString(2, 27 + i * 10, STR_7011_CONSTRUCTION + i, TC_FROMSTRING);
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
46 DrawStringRightAligned(111, 27 + 10 * 13 + 2, STR_7020_TOTAL, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
47
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
48 /* draw the price columns */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
49 year = _cur_year - 2;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
50 j = 3;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
51 x = 215;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
52 tbl = p->yearly_expenses + 2;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
53 do {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
54 if (year >= p->inaugurated_year) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
55 SetDParam(0, year);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
56 DrawStringRightAlignedUnderline(x, 15, STR_7010, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
57 sum = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
58 for (i = 0; i != 13; i++) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
59 /* draw one row in the price column */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
60 cost = (*tbl)[i];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
61 if (cost != 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
62 sum += cost;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
63
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
64 str = STR_701E;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
65 if (cost < 0) { cost = -cost; str++; }
7002
fa75522e0249 (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents: 6991
diff changeset
66 SetDParam(0, cost);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
67 DrawStringRightAligned(x, 27 + i * 10, str, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
68 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
69 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
70
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
71 str = STR_701E;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
72 if (sum < 0) { sum = -sum; str++; }
7002
fa75522e0249 (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents: 6991
diff changeset
73 SetDParam(0, sum);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
74 DrawStringRightAligned(x, 27 + 13 * 10 + 2, str, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
75
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6352
diff changeset
76 GfxFillRect(x - 75, 27 + 10 * 13, x, 27 + 10 * 13, 215);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
77 x += 95;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
78 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
79 year++;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
80 tbl--;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
81 } while (--j != 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
82
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
83 y = 171;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
84
6352
d646bb89ca43 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas <belugas@openttd.org>
parents: 6259
diff changeset
85 /* draw max loan aligned to loan below (y += 10) */
7002
fa75522e0249 (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents: 6991
diff changeset
86 SetDParam(0, _economy.max_loan);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
87 DrawString(202, y + 10, STR_MAX_LOAN, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
88 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
89 y = 15;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
90 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
91
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
92 DrawString(2, y, STR_7026_BANK_BALANCE, TC_FROMSTRING);
7002
fa75522e0249 (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents: 6991
diff changeset
93 SetDParam(0, p->player_money);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
94 DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
95
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
96 y += 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
97
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
98 DrawString(2, y, STR_7027_LOAN, TC_FROMSTRING);
7002
fa75522e0249 (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents: 6991
diff changeset
99 SetDParam(0, p->current_loan);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
100 DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
101
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
102 y += 12;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
103
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6352
diff changeset
104 GfxFillRect(182 - 75, y - 2, 182, y - 2, 215);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
105
7002
fa75522e0249 (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents: 6991
diff changeset
106 SetDParam(0, p->player_money - p->current_loan);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
107 DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
108 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
109
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
110 static const Widget _player_finances_widgets[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
111 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
112 { WWT_CAPTION, RESIZE_NONE, 14, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
113 { WWT_IMGBTN, RESIZE_NONE, 14, 380, 394, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
114 { WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
115 { WWT_PANEL, RESIZE_NONE, 14, 0, 406, 14, 169, 0x0, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
116 { WWT_PANEL, RESIZE_NONE, 14, 0, 406, 170, 203, 0x0, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
117 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 202, 204, 215, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
118 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 203, 406, 204, 215, STR_702A_REPAY, STR_7036_REPAY_PART_OF_LOAN},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
119 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
120 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
121
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
122 static const Widget _player_finances_small_widgets[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
123 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
124 { WWT_CAPTION, RESIZE_NONE, 14, 11, 253, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
125 { WWT_IMGBTN, RESIZE_NONE, 14, 254, 267, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
126 { WWT_STICKYBOX, RESIZE_NONE, 14, 268, 279, 0, 13, 0x0, STR_STICKY_BUTTON},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
127 { WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
128 { WWT_PANEL, RESIZE_NONE, 14, 0, 279, 14, 47, STR_NULL, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
129 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 139, 48, 59, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
130 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 140, 279, 48, 59, STR_702A_REPAY, STR_7036_REPAY_PART_OF_LOAN},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
131 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
132 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
133
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
134
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
135 static void PlayerFinancesWndProc(Window *w, WindowEvent *e)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
136 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
137 switch (e->event) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
138 case WE_PAINT: {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
139 PlayerID player = (PlayerID)w->window_number;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
140 const Player *p = GetPlayer(player);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
141
7513
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
142 /* Recheck the size of the window as it might need to be resized due to the local player changing */
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
143 int new_height = ((player != _local_player) ? 0 : 12) + ((WP(w, def_d).data_1 != 0) ? 48 : 204);
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
144 if (w->height != new_height) {
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
145 /* Make window dirty before and after resizing */
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
146 SetWindowDirty(w);
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
147 w->height = new_height;
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
148 SetWindowDirty(w);
6909
6d1b28e5f91f (svn r10158) -Codechange: port some changes from NoAI and FS#872 to make the loan commands a little better readable.
rubidium <rubidium@openttd.org>
parents: 6857
diff changeset
149
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
150 w->SetWidgetHiddenState(6, player != _local_player);
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
151 w->SetWidgetHiddenState(7, player != _local_player);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
152 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
153
7513
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
154 /* Borrow button only shows when there is any more money to loan */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
155 w->SetWidgetDisabledState(6, p->current_loan == _economy.max_loan);
7513
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
156
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
157 /* Repay button only shows when there is any more money to repay */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
158 w->SetWidgetDisabledState(7, player != _local_player || p->current_loan == 0);
7513
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
159
7058
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
160 SetDParam(0, p->index);
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
161 SetDParam(1, p->index);
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
162 SetDParam(2, LOAN_INTERVAL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
163 DrawWindowWidgets(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
164
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6352
diff changeset
165 DrawPlayerEconomyStats(p, (byte)WP(w, def_d).data_1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
166 } break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
167
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
168 case WE_CLICK:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
169 switch (e->we.click.widget) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
170 case 2: {/* toggle size */
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6352
diff changeset
171 byte mode = (byte)WP(w, def_d).data_1;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
172 bool stickied = !!(w->flags4 & WF_STICKY);
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
173 PlayerID player = (PlayerID)w->window_number;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
174 DeleteWindow(w);
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7889
diff changeset
175 DoShowPlayerFinances(player, !HasBit(mode, 0), stickied);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
176 } break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
177
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
178 case 6: /* increase loan */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
179 DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
180 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
181
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
182 case 7: /* repay loan */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
183 DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
184 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
185 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
186 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
187 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
188 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
189
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
190 static const WindowDesc _player_finances_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
191 WDP_AUTO, WDP_AUTO, 407, 216, 407, 216,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5854
diff changeset
192 WC_FINANCES, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
193 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
194 _player_finances_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
195 PlayerFinancesWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
196 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
197
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
198 static const WindowDesc _player_finances_small_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
199 WDP_AUTO, WDP_AUTO, 280, 60, 280, 60,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5854
diff changeset
200 WC_FINANCES, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
201 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
202 _player_finances_small_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
203 PlayerFinancesWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
204 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
205
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
206 static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
207 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
208 if (!IsValidPlayer(player)) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
209
7513
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
210 Window *w = AllocateWindowDescFront(show_small ? &_player_finances_small_desc : &_player_finances_desc, player);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
211 if (w != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
212 w->caption_color = w->window_number;
7513
68e3f9ca1c02 (svn r11028) -Fix [FS#1177]: crash when having the Finance window opened of the player you are cheating to.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
213 WP(w, def_d).data_1 = show_small;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
214 if (show_stickied) w->flags4 |= WF_STICKY;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
215 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
216 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
217
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
218 void ShowPlayerFinances(PlayerID player)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
219 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
220 DoShowPlayerFinances(player, false, false);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
221 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
222
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
223 /* List of colours for the livery window */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
224 static const StringID _colour_dropdown[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
225 STR_00D1_DARK_BLUE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
226 STR_00D2_PALE_GREEN,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
227 STR_00D3_PINK,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
228 STR_00D4_YELLOW,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
229 STR_00D5_RED,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
230 STR_00D6_LIGHT_BLUE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
231 STR_00D7_GREEN,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
232 STR_00D8_DARK_GREEN,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
233 STR_00D9_BLUE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
234 STR_00DA_CREAM,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
235 STR_00DB_MAUVE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
236 STR_00DC_PURPLE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
237 STR_00DD_ORANGE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
238 STR_00DE_BROWN,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
239 STR_00DF_GREY,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
240 STR_00E0_WHITE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
241 INVALID_STRING_ID
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
242 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
243
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
244 /* Association of liveries to livery classes */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
245 static const LiveryClass livery_class[LS_END] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
246 LC_OTHER,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
247 LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
248 LC_ROAD, LC_ROAD,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
249 LC_SHIP, LC_SHIP,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
250 LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT,
6724
de30d61ce253 (svn r9956) -Codechange: Add tram livery schemes
peter1138 <peter1138@openttd.org>
parents: 6491
diff changeset
251 LC_ROAD, LC_ROAD,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
252 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
253
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
254 /* Number of liveries in each class, used to determine the height of the livery window */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
255 static const byte livery_height[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
256 1,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
257 11,
6724
de30d61ce253 (svn r9956) -Codechange: Add tram livery schemes
peter1138 <peter1138@openttd.org>
parents: 6491
diff changeset
258 4,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
259 2,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
260 3,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
261 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
262
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6247
diff changeset
263 struct livery_d {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
264 uint32 sel;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
265 LiveryClass livery_class;
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6247
diff changeset
266 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
267 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(livery_d));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
268
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
269 static void ShowColourDropDownMenu(Window *w, uint32 widget)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
270 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
271 uint32 used_colours = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
272 const Livery *livery;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
273 LiveryScheme scheme;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
274
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
275 /* Disallow other player colours for the primary colour */
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7889
diff changeset
276 if (HasBit(WP(w, livery_d).sel, LS_DEFAULT) && widget == 10) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
277 const Player *p;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
278 FOR_ALL_PLAYERS(p) {
7931
44ff7a6d801f (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
279 if (p->is_active && p->index != _local_player) SetBit(used_colours, p->player_color);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
280 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
281 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
282
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
283 /* Get the first selected livery to use as the default dropdown item */
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
284 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7889
diff changeset
285 if (HasBit(WP(w, livery_d).sel, scheme)) break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
286 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
287 if (scheme == LS_END) scheme = LS_DEFAULT;
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
288 livery = &GetPlayer((PlayerID)w->window_number)->livery[scheme];
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
289
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
290 ShowDropDownMenu(w, _colour_dropdown, widget == 10 ? livery->colour1 : livery->colour2, widget, used_colours, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
291 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
292
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
293 static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
294 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
295 switch (e->event) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
296 case WE_CREATE:
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
297 w->LowerWidget(WP(w, livery_d).livery_class + 2);
6914
d4c8b81ac7e4 (svn r10167) -Codechange: Change the flagging system of grf loaded feature from a bitset to a bool evaluation.
belugas <belugas@openttd.org>
parents: 6909
diff changeset
298 if (!_loaded_newgrf_features.has_2CC) {
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
299 w->HideWidget(11);
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
300 w->HideWidget(12);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
301 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
302 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
303
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
304 case WE_PAINT: {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
305 const Player *p = GetPlayer((PlayerID)w->window_number);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
306 LiveryScheme scheme = LS_DEFAULT;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
307 int y = 51;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
308
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
309 /* Disable dropdown controls if no scheme is selected */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
310 w->SetWidgetDisabledState( 9, (WP(w, livery_d).sel == 0));
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
311 w->SetWidgetDisabledState(10, (WP(w, livery_d).sel == 0));
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
312 w->SetWidgetDisabledState(11, (WP(w, livery_d).sel == 0));
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
313 w->SetWidgetDisabledState(12, (WP(w, livery_d).sel == 0));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
314
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
315 if (!(WP(w, livery_d).sel == 0)) {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
316 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7889
diff changeset
317 if (HasBit(WP(w, livery_d).sel, scheme)) break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
318 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
319 if (scheme == LS_END) scheme = LS_DEFAULT;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
320 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
321
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
322 SetDParam(0, STR_00D1_DARK_BLUE + p->livery[scheme].colour1);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
323 SetDParam(1, STR_00D1_DARK_BLUE + p->livery[scheme].colour2);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
324
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
325 DrawWindowWidgets(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
326
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
327 for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
328 if (livery_class[scheme] == WP(w, livery_d).livery_class) {
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7889
diff changeset
329 bool sel = HasBit(WP(w, livery_d).sel, scheme) != 0;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
330
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
331 if (scheme != LS_DEFAULT) {
5668
3d6d9bff3dd8 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents: 5587
diff changeset
332 DrawSprite(p->livery[scheme].in_use ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, 2, y);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
333 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
334
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
335 DrawString(15, y, STR_LIVERY_DEFAULT + scheme, sel ? TC_WHITE : TC_BLACK);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
336
5668
3d6d9bff3dd8 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents: 5587
diff changeset
337 DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour1), 152, y);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
338 DrawString(165, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour1, sel ? TC_WHITE : TC_GOLD);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
339
6914
d4c8b81ac7e4 (svn r10167) -Codechange: Change the flagging system of grf loaded feature from a bitset to a bool evaluation.
belugas <belugas@openttd.org>
parents: 6909
diff changeset
340 if (_loaded_newgrf_features.has_2CC) {
5668
3d6d9bff3dd8 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents: 5587
diff changeset
341 DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour2), 277, y);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
342 DrawString(290, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour2, sel ? TC_WHITE : TC_GOLD);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
343 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
344
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
345 y += 14;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
346 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
347 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
348 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
349 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
350
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
351 case WE_CLICK: {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
352 switch (e->we.click.widget) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
353 /* Livery Class buttons */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
354 case 2:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
355 case 3:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
356 case 4:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
357 case 5:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
358 case 6: {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
359 LiveryScheme scheme;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
360
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
361 w->RaiseWidget(WP(w, livery_d).livery_class + 2);
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
362 WP(w, livery_d).livery_class = (LiveryClass)(e->we.click.widget - 2);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
363 WP(w, livery_d).sel = 0;
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
364 w->LowerWidget(WP(w, livery_d).livery_class + 2);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
365
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
366 /* Select the first item in the list */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
367 for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
368 if (livery_class[scheme] == WP(w, livery_d).livery_class) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
369 WP(w, livery_d).sel = 1 << scheme;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
370 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
371 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
372 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
373 w->height = 49 + livery_height[WP(w, livery_d).livery_class] * 14;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
374 w->widget[13].bottom = w->height - 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
375 w->widget[13].data = livery_height[WP(w, livery_d).livery_class] << 8 | 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
376 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
377 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
378 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
379
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
380 case 9:
6352
d646bb89ca43 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas <belugas@openttd.org>
parents: 6259
diff changeset
381 case 10: /* First colour dropdown */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
382 ShowColourDropDownMenu(w, 10);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
383 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
384
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
385 case 11:
6352
d646bb89ca43 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas <belugas@openttd.org>
parents: 6259
diff changeset
386 case 12: /* Second colour dropdown */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
387 ShowColourDropDownMenu(w, 12);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
388 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
389
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
390 case 13: {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
391 LiveryScheme scheme;
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
392 LiveryScheme j = (LiveryScheme)((e->we.click.pt.y - 48) / 14);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
393
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
394 for (scheme = LS_BEGIN; scheme <= j; scheme++) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
395 if (livery_class[scheme] != WP(w, livery_d).livery_class) j++;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
396 if (scheme >= LS_END) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
397 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
398 if (j >= LS_END) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
399
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
400 /* If clicking on the left edge, toggle using the livery */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
401 if (e->we.click.pt.x < 10) {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
402 DoCommandP(0, j | (2 << 8), !GetPlayer((PlayerID)w->window_number)->livery[j].in_use, NULL, CMD_SET_PLAYER_COLOR);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
403 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
404
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
405 if (_ctrl_pressed) {
7932
712f252f0d4d (svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7931
diff changeset
406 ToggleBit(WP(w, livery_d).sel, j);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
407 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
408 WP(w, livery_d).sel = 1 << j;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
409 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
410 SetWindowDirty(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
411 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
412 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
413 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
414 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
415 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
416
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
417 case WE_DROPDOWN_SELECT: {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
418 LiveryScheme scheme;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
419
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
420 for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7889
diff changeset
421 if (HasBit(WP(w, livery_d).sel, scheme)) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
422 DoCommandP(0, scheme | (e->we.dropdown.button == 10 ? 0 : 256), e->we.dropdown.index, NULL, CMD_SET_PLAYER_COLOR);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
423 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
424 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
425 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
426 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
427 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
428 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
429
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
430 static const Widget _select_player_livery_2cc_widgets[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
431 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
432 { WWT_CAPTION, RESIZE_NONE, 14, 11, 399, 0, 13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
433 { WWT_IMGBTN, RESIZE_NONE, 14, 0, 21, 14, 35, SPR_IMG_COMPANY_GENERAL, STR_LIVERY_GENERAL_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
434 { WWT_IMGBTN, RESIZE_NONE, 14, 22, 43, 14, 35, SPR_IMG_TRAINLIST, STR_LIVERY_TRAIN_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
435 { WWT_IMGBTN, RESIZE_NONE, 14, 44, 65, 14, 35, SPR_IMG_TRUCKLIST, STR_LIVERY_ROADVEH_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
436 { WWT_IMGBTN, RESIZE_NONE, 14, 66, 87, 14, 35, SPR_IMG_SHIPLIST, STR_LIVERY_SHIP_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
437 { WWT_IMGBTN, RESIZE_NONE, 14, 88, 109, 14, 35, SPR_IMG_AIRPLANESLIST, STR_LIVERY_AIRCRAFT_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
438 { WWT_PANEL, RESIZE_NONE, 14, 110, 399, 14, 35, 0x0, STR_NULL },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
439 { WWT_PANEL, RESIZE_NONE, 14, 0, 149, 36, 47, 0x0, STR_NULL },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
440 { WWT_TEXTBTN, RESIZE_NONE, 14, 150, 262, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
441 { WWT_TEXTBTN, RESIZE_NONE, 14, 263, 274, 36, 47, STR_0225, STR_LIVERY_PRIMARY_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
442 { WWT_TEXTBTN, RESIZE_NONE, 14, 275, 387, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
443 { WWT_TEXTBTN, RESIZE_NONE, 14, 388, 399, 36, 47, STR_0225, STR_LIVERY_SECONDARY_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
444 { WWT_MATRIX, RESIZE_NONE, 14, 0, 399, 48, 48 + 1 * 14, (1 << 8) | 1, STR_LIVERY_PANEL_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
445 { WIDGETS_END },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
446 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
447
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
448 static const WindowDesc _select_player_livery_2cc_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
449 WDP_AUTO, WDP_AUTO, 400, 49 + 1 * 14, 400, 49 + 1 * 14,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5854
diff changeset
450 WC_PLAYER_COLOR, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
451 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
452 _select_player_livery_2cc_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
453 SelectPlayerLiveryWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
454 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
455
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
456
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
457 static const Widget _select_player_livery_widgets[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
458 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
459 { WWT_CAPTION, RESIZE_NONE, 14, 11, 274, 0, 13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
460 { WWT_IMGBTN, RESIZE_NONE, 14, 0, 21, 14, 35, SPR_IMG_COMPANY_GENERAL, STR_LIVERY_GENERAL_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
461 { WWT_IMGBTN, RESIZE_NONE, 14, 22, 43, 14, 35, SPR_IMG_TRAINLIST, STR_LIVERY_TRAIN_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
462 { WWT_IMGBTN, RESIZE_NONE, 14, 44, 65, 14, 35, SPR_IMG_TRUCKLIST, STR_LIVERY_ROADVEH_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
463 { WWT_IMGBTN, RESIZE_NONE, 14, 66, 87, 14, 35, SPR_IMG_SHIPLIST, STR_LIVERY_SHIP_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
464 { WWT_IMGBTN, RESIZE_NONE, 14, 88, 109, 14, 35, SPR_IMG_AIRPLANESLIST, STR_LIVERY_AIRCRAFT_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
465 { WWT_PANEL, RESIZE_NONE, 14, 110, 274, 14, 35, 0x0, STR_NULL },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
466 { WWT_PANEL, RESIZE_NONE, 14, 0, 149, 36, 47, 0x0, STR_NULL },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
467 { WWT_TEXTBTN, RESIZE_NONE, 14, 150, 262, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
468 { WWT_TEXTBTN, RESIZE_NONE, 14, 263, 274, 36, 47, STR_0225, STR_LIVERY_PRIMARY_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
469 { WWT_TEXTBTN, RESIZE_NONE, 14, 275, 275, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
470 { WWT_TEXTBTN, RESIZE_NONE, 14, 275, 275, 36, 47, STR_0225, STR_LIVERY_SECONDARY_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
471 { WWT_MATRIX, RESIZE_NONE, 14, 0, 274, 48, 48 + 1 * 14, (1 << 8) | 1, STR_LIVERY_PANEL_TIP },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
472 { WIDGETS_END },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
473 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
474
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
475 static const WindowDesc _select_player_livery_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
476 WDP_AUTO, WDP_AUTO, 275, 49 + 1 * 14, 275, 49 + 1 * 14,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5854
diff changeset
477 WC_PLAYER_COLOR, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
478 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
479 _select_player_livery_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
480 SelectPlayerLiveryWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
481 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
482
6190
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
483 /**
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
484 * Draws the face of a player.
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
485 * @param pf the player's face
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
486 * @param color the (background) color of the gradient
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
487 * @param x x-position to draw the face
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
488 * @param y y-position to draw the face
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
489 */
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
490 void DrawPlayerFace(PlayerFace pf, int color, int x, int y)
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
491 {
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
492 GenderEthnicity ge = (GenderEthnicity)GetPlayerFaceBits(pf, PFV_GEN_ETHN, GE_WM);
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
493
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7889
diff changeset
494 bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetPlayerFaceBits(pf, PFV_HAS_MOUSTACHE, ge) != 0;
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7889
diff changeset
495 bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetPlayerFaceBits(pf, PFV_HAS_TIE_EARRING, ge) != 0;
6190
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
496 bool has_glasses = GetPlayerFaceBits(pf, PFV_HAS_GLASSES, ge) != 0;
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
497 SpriteID pal;
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
498
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
499 /* Modify eye colour palette only if 2 or more valid values exist */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
500 if (_pf_info[PFV_EYE_COLOUR].valid_values[ge] < 2) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
501 pal = PAL_NONE;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
502 } else {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
503 switch (GetPlayerFaceBits(pf, PFV_EYE_COLOUR, ge)) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
504 default: NOT_REACHED();
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
505 case 0: pal = PALETTE_TO_BROWN; break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
506 case 1: pal = PALETTE_TO_BLUE; break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
507 case 2: pal = PALETTE_TO_GREEN; break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
508 }
6190
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
509 }
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
510
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
511 /* Draw the gradient (background) */
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
512 DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOR(color), x, y);
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
513
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
514 for (PlayerFaceVariable pfv = PFV_CHEEKS; pfv < PFV_END; pfv++) {
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
515 switch (pfv) {
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
516 case PFV_MOUSTACHE: if (!has_moustache) continue; break;
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
517 case PFV_LIPS: /* FALL THROUGH */
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
518 case PFV_NOSE: if (has_moustache) continue; break;
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
519 case PFV_TIE_EARRING: if (!has_tie_earring) continue; break;
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
520 case PFV_GLASSES: if (!has_glasses) continue; break;
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
521 default: break;
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
522 }
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
523 DrawSprite(GetPlayerFaceSprite(pf, pfv, ge), (pfv == PFV_EYEBROWS) ? pal : PAL_NONE, x, y);
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
524 }
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
525 }
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
526
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
527 /**
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
528 * Names of the widgets. Keep them in the same order as in the widget array.
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
529 * Do not change the order of the widgets from PFW_WIDGET_HAS_MOUSTACHE_EARRING to PFW_WIDGET_GLASSES_R,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
530 * this order is needed for the WE_CLICK event of DrawFaceStringLabel().
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
531 */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
532 enum PlayerFaceWindowWidgets {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
533 PFW_WIDGET_CLOSEBOX = 0,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
534 PFW_WIDGET_CAPTION,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
535 PFW_WIDGET_TOGGLE_LARGE_SMALL,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
536 PFW_WIDGET_SELECT_FACE,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
537 PFW_WIDGET_CANCEL,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
538 PFW_WIDGET_ACCEPT,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
539 PFW_WIDGET_MALE,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
540 PFW_WIDGET_FEMALE,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
541 PFW_WIDGET_RANDOM_NEW_FACE,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
542 PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
543 /* from here is the advanced player face selection window */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
544 PFW_WIDGET_LOAD,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
545 PFW_WIDGET_FACECODE,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
546 PFW_WIDGET_SAVE,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
547 PFW_WIDGET_ETHNICITY_EUR,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
548 PFW_WIDGET_ETHNICITY_AFR,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
549 PFW_WIDGET_HAS_MOUSTACHE_EARRING,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
550 PFW_WIDGET_HAS_GLASSES,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
551 PFW_WIDGET_EYECOLOUR_L,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
552 PFW_WIDGET_EYECOLOUR,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
553 PFW_WIDGET_EYECOLOUR_R,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
554 PFW_WIDGET_CHIN_L,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
555 PFW_WIDGET_CHIN,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
556 PFW_WIDGET_CHIN_R,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
557 PFW_WIDGET_EYEBROWS_L,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
558 PFW_WIDGET_EYEBROWS,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
559 PFW_WIDGET_EYEBROWS_R,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
560 PFW_WIDGET_LIPS_MOUSTACHE_L,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
561 PFW_WIDGET_LIPS_MOUSTACHE,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
562 PFW_WIDGET_LIPS_MOUSTACHE_R,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
563 PFW_WIDGET_NOSE_L,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
564 PFW_WIDGET_NOSE,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
565 PFW_WIDGET_NOSE_R,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
566 PFW_WIDGET_HAIR_L,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
567 PFW_WIDGET_HAIR,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
568 PFW_WIDGET_HAIR_R,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
569 PFW_WIDGET_JACKET_L,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
570 PFW_WIDGET_JACKET,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
571 PFW_WIDGET_JACKET_R,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
572 PFW_WIDGET_COLLAR_L,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
573 PFW_WIDGET_COLLAR,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
574 PFW_WIDGET_COLLAR_R,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
575 PFW_WIDGET_TIE_EARRING_L,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
576 PFW_WIDGET_TIE_EARRING,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
577 PFW_WIDGET_TIE_EARRING_R,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
578 PFW_WIDGET_GLASSES_L,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
579 PFW_WIDGET_GLASSES,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
580 PFW_WIDGET_GLASSES_R,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
581 };
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
582
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
583 /** Widget description for the normal/simple player face selection dialog */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
584 static const Widget _select_player_face_widgets[] = {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
585 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // PFW_WIDGET_CLOSEBOX
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
586 { WWT_CAPTION, RESIZE_NONE, 14, 11, 174, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // PFW_WIDGET_CAPTION
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
587 { WWT_IMGBTN, RESIZE_NONE, 14, 175, 189, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_ADVANCED_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
588 { WWT_PANEL, RESIZE_NONE, 14, 0, 189, 14, 150, 0x0, STR_NULL}, // PFW_WIDGET_SELECT_FACE
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
589 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 94, 151, 162, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // PFW_WIDGET_CANCEL
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
590 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 95, 189, 151, 162, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // PFW_WIDGET_ACCEPT
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
591 { WWT_TEXTBTN, RESIZE_NONE, 14, 95, 187, 75, 86, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // PFW_WIDGET_MALE
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
592 { WWT_TEXTBTN, RESIZE_NONE, 14, 95, 187, 87, 98, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // PFW_WIDGET_FEMALE
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
593 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 2, 93, 137, 148, STR_7046_NEW_FACE, STR_704B_GENERATE_RANDOM_NEW_FACE}, // PFW_WIDGET_RANDOM_NEW_FACE
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
594 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 95, 187, 16, 27, STR_FACE_ADVANCED, STR_FACE_ADVANCED_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
595 { WIDGETS_END},
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
596 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
597
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
598 /** Widget description for the advanced player face selection dialog */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
599 static const Widget _select_player_face_adv_widgets[] = {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
600 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // PFW_WIDGET_CLOSEBOX
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
601 { WWT_CAPTION, RESIZE_NONE, 14, 11, 204, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // PFW_WIDGET_CAPTION
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
602 { WWT_IMGBTN, RESIZE_NONE, 14, 205, 219, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_SIMPLE_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
603 { WWT_PANEL, RESIZE_NONE, 14, 0, 219, 14, 207, 0x0, STR_NULL}, // PFW_WIDGET_SELECT_FACE
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
604 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 94, 208, 219, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // PFW_WIDGET_CANCEL
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
605 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 95, 219, 208, 219, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // PFW_WIDGET_ACCEPT
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
606 { WWT_TEXTBTN, RESIZE_NONE, 14, 96, 156, 32, 43, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // PFW_WIDGET_MALE
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
607 { WWT_TEXTBTN, RESIZE_NONE, 14, 157, 217, 32, 43, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // PFW_WIDGET_FEMALE
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
608 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 2, 93, 137, 148, STR_RANDOM, STR_704B_GENERATE_RANDOM_NEW_FACE}, // PFW_WIDGET_RANDOM_NEW_FACE
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
609 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 95, 217, 16, 27, STR_FACE_SIMPLE, STR_FACE_SIMPLE_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
610 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 2, 93, 158, 169, STR_FACE_LOAD, STR_FACE_LOAD_TIP}, // PFW_WIDGET_LOAD
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
611 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 2, 93, 170, 181, STR_FACE_FACECODE, STR_FACE_FACECODE_TIP}, // PFW_WIDGET_FACECODE
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
612 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 2, 93, 182, 193, STR_FACE_SAVE, STR_FACE_SAVE_TIP}, // PFW_WIDGET_SAVE
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
613 { WWT_TEXTBTN, RESIZE_NONE, 14, 96, 156, 46, 57, STR_FACE_EUROPEAN, STR_FACE_SELECT_EUROPEAN}, // PFW_WIDGET_ETHNICITY_EUR
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
614 { WWT_TEXTBTN, RESIZE_NONE, 14, 157, 217, 46, 57, STR_FACE_AFRICAN, STR_FACE_SELECT_AFRICAN}, // PFW_WIDGET_ETHNICITY_AFR
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
615 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 175, 217, 60, 71, STR_EMPTY, STR_FACE_MOUSTACHE_EARRING_TIP}, // PFW_WIDGET_HAS_MOUSTACHE_EARRING
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
616 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 175, 217, 72, 83, STR_EMPTY, STR_FACE_GLASSES_TIP}, // PFW_WIDGET_HAS_GLASSES
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
617 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 110, 121, SPR_ARROW_LEFT, STR_FACE_EYECOLOUR_TIP}, // PFW_WIDGET_EYECOLOUR_L
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
618 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 110, 121, STR_EMPTY, STR_FACE_EYECOLOUR_TIP}, // PFW_WIDGET_EYECOLOUR
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
619 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 110, 121, SPR_ARROW_RIGHT, STR_FACE_EYECOLOUR_TIP}, // PFW_WIDGET_EYECOLOUR_R
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
620 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 158, 169, SPR_ARROW_LEFT, STR_FACE_CHIN_TIP}, // PFW_WIDGET_CHIN_L
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
621 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 158, 169, STR_EMPTY, STR_FACE_CHIN_TIP}, // PFW_WIDGET_CHIN
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
622 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 158, 169, SPR_ARROW_RIGHT, STR_FACE_CHIN_TIP}, // PFW_WIDGET_CHIN_R
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
623 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 98, 109, SPR_ARROW_LEFT, STR_FACE_EYEBROWS_TIP}, // PFW_WIDGET_EYEBROWS_L
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
624 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 98, 109, STR_EMPTY, STR_FACE_EYEBROWS_TIP}, // PFW_WIDGET_EYEBROWS
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
625 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 98, 109, SPR_ARROW_RIGHT, STR_FACE_EYEBROWS_TIP}, // PFW_WIDGET_EYEBROWS_R
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
626 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 146, 157, SPR_ARROW_LEFT, STR_FACE_LIPS_MOUSTACHE_TIP}, // PFW_WIDGET_LIPS_MOUSTACHE_L
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
627 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 146, 157, STR_EMPTY, STR_FACE_LIPS_MOUSTACHE_TIP}, // PFW_WIDGET_LIPS_MOUSTACHE
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
628 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 146, 157, SPR_ARROW_RIGHT, STR_FACE_LIPS_MOUSTACHE_TIP}, // PFW_WIDGET_LIPS_MOUSTACHE_R
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
629 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 134, 145, SPR_ARROW_LEFT, STR_FACE_NOSE_TIP}, // PFW_WIDGET_NOSE_L
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
630 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 134, 145, STR_EMPTY, STR_FACE_NOSE_TIP}, // PFW_WIDGET_NOSE
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
631 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 134, 145, SPR_ARROW_RIGHT, STR_FACE_NOSE_TIP}, // PFW_WIDGET_NOSE_R
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
632 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 86, 97, SPR_ARROW_LEFT, STR_FACE_HAIR_TIP}, // PFW_WIDGET_HAIR_L
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
633 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 86, 97, STR_EMPTY, STR_FACE_HAIR_TIP}, // PFW_WIDGET_HAIR
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
634 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 86, 97, SPR_ARROW_RIGHT, STR_FACE_HAIR_TIP}, // PFW_WIDGET_HAIR_R
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
635 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 170, 181, SPR_ARROW_LEFT, STR_FACE_JACKET_TIP}, // PFW_WIDGET_JACKET_L
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
636 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 170, 181, STR_EMPTY, STR_FACE_JACKET_TIP}, // PFW_WIDGET_JACKET
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
637 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 170, 181, SPR_ARROW_RIGHT, STR_FACE_JACKET_TIP}, // PFW_WIDGET_JACKET_R
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
638 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 182, 193, SPR_ARROW_LEFT, STR_FACE_COLLAR_TIP}, // PFW_WIDGET_COLLAR_L
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
639 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 182, 193, STR_EMPTY, STR_FACE_COLLAR_TIP}, // PFW_WIDGET_COLLAR
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
640 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 182, 193, SPR_ARROW_RIGHT, STR_FACE_COLLAR_TIP}, // PFW_WIDGET_COLLAR_R
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
641 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 194, 205, SPR_ARROW_LEFT, STR_FACE_TIE_EARRING_TIP}, // PFW_WIDGET_TIE_EARRING_L
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
642 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 194, 205, STR_EMPTY, STR_FACE_TIE_EARRING_TIP}, // PFW_WIDGET_TIE_EARRING
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
643 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 194, 205, SPR_ARROW_RIGHT, STR_FACE_TIE_EARRING_TIP}, // PFW_WIDGET_TIE_EARRING_R
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
644 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 175, 183, 122, 133, SPR_ARROW_LEFT, STR_FACE_GLASSES_TIP_2}, // PFW_WIDGET_GLASSES_L
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
645 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 184, 208, 122, 133, STR_EMPTY, STR_FACE_GLASSES_TIP_2}, // PFW_WIDGET_GLASSES
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
646 { WWT_PUSHIMGBTN, RESIZE_NONE, 14, 209, 217, 122, 133, SPR_ARROW_RIGHT, STR_FACE_GLASSES_TIP_2}, // PFW_WIDGET_GLASSES_R
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
647 { WIDGETS_END},
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
648 };
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
649
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
650 /**
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
651 * Draw dynamic a label to the left of the button and a value in the button
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
652 *
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
653 * @param w Window on which the widget is located
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
654 * @param widget_index index of this widget in the window
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
655 * @param str the label which will be draw
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
656 * @param val the value which will be draw
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
657 * @param is_bool_widget is it a bool button
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
658 */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
659 void DrawFaceStringLabel(const Window *w, byte widget_index, StringID str, uint8 val, bool is_bool_widget)
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
660 {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
661 /* Write the label in gold (0x2) to the left of the button. */
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
662 DrawStringRightAligned(w->widget[widget_index].left - (is_bool_widget ? 5 : 14), w->widget[widget_index].top + 1, str, TC_GOLD);
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
663
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
664 if (!w->IsWidgetDisabled(widget_index)) {
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
665 if (is_bool_widget) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
666 /* if it a bool button write yes or no */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
667 str = (val != 0) ? STR_FACE_YES : STR_FACE_NO;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
668 } else {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
669 /* else write the value + 1 */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
670 SetDParam(0, val + 1);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
671 str = STR_JUST_INT;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
672 }
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
673
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
674 /* Draw the value/bool in white (0xC). If the button clicked adds 1px to x and y text coordinates (IsWindowWidgetLowered()). */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
675 DrawStringCentered(w->widget[widget_index].left + (w->widget[widget_index].right - w->widget[widget_index].left) / 2 +
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
676 w->IsWidgetLowered(widget_index), w->widget[widget_index].top + 1 + w->IsWidgetLowered(widget_index), str, TC_WHITE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
677 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
678 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
679
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
680 /**
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
681 * Player face selection window event definition
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
682 *
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
683 * @param w window pointer
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
684 * @param e event been triggered
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
685 */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
686 static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e)
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
687 {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
688 PlayerFace *pf = &WP(w, facesel_d).face; // pointer to the player face bits
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
689 GenderEthnicity ge = (GenderEthnicity)GB(*pf, _pf_info[PFV_GEN_ETHN].offset, _pf_info[PFV_GEN_ETHN].length); // get the gender and ethnicity
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7889
diff changeset
690 bool is_female = HasBit(ge, GENDER_FEMALE); // get the gender: 0 == male and 1 == female
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
691 bool is_moust_male = !is_female && GetPlayerFaceBits(*pf, PFV_HAS_MOUSTACHE, ge) != 0; // is a male face with moustache
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
692
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
693 switch (e->event) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
694 case WE_PAINT:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
695 /* lower the non-selected gender button */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
696 w->SetWidgetLoweredState(PFW_WIDGET_MALE, !is_female);
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
697 w->SetWidgetLoweredState(PFW_WIDGET_FEMALE, is_female);
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
698
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
699 /* advanced player face selection window */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
700 if (WP(w, facesel_d).advanced) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
701 /* lower the non-selected ethnicity button */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
702 w->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_EUR, !HasBit(ge, ETHNICITY_BLACK));
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
703 w->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_AFR, HasBit(ge, ETHNICITY_BLACK));
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
704
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
705
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
706 /* Disable dynamically the widgets which PlayerFaceVariable has less than 2 options
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
707 * (or in other words you haven't any choice).
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
708 * If the widgets depend on a HAS-variable and this is false the widgets will be disabled, too. */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
709
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
710 /* Eye colour buttons */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
711 w->SetWidgetsDisabledState(_pf_info[PFV_EYE_COLOUR].valid_values[ge] < 2,
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
712 PFW_WIDGET_EYECOLOUR, PFW_WIDGET_EYECOLOUR_L, PFW_WIDGET_EYECOLOUR_R, WIDGET_LIST_END);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
713
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
714 /* Chin buttons */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
715 w->SetWidgetsDisabledState(_pf_info[PFV_CHIN].valid_values[ge] < 2,
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
716 PFW_WIDGET_CHIN, PFW_WIDGET_CHIN_L, PFW_WIDGET_CHIN_R, WIDGET_LIST_END);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
717
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
718 /* Eyebrows buttons */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
719 w->SetWidgetsDisabledState(_pf_info[PFV_EYEBROWS].valid_values[ge] < 2,
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
720 PFW_WIDGET_EYEBROWS, PFW_WIDGET_EYEBROWS_L, PFW_WIDGET_EYEBROWS_R, WIDGET_LIST_END);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
721
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
722 /* Lips or (if it a male face with a moustache) moustache buttons */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
723 w->SetWidgetsDisabledState(_pf_info[is_moust_male ? PFV_MOUSTACHE : PFV_LIPS].valid_values[ge] < 2,
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
724 PFW_WIDGET_LIPS_MOUSTACHE, PFW_WIDGET_LIPS_MOUSTACHE_L, PFW_WIDGET_LIPS_MOUSTACHE_R, WIDGET_LIST_END);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
725
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
726 /* Nose buttons | male faces with moustache haven't any nose options */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
727 w->SetWidgetsDisabledState(_pf_info[PFV_NOSE].valid_values[ge] < 2 || is_moust_male,
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
728 PFW_WIDGET_NOSE, PFW_WIDGET_NOSE_L, PFW_WIDGET_NOSE_R, WIDGET_LIST_END);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
729
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
730 /* Hair buttons */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
731 w->SetWidgetsDisabledState(_pf_info[PFV_HAIR].valid_values[ge] < 2,
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
732 PFW_WIDGET_HAIR, PFW_WIDGET_HAIR_L, PFW_WIDGET_HAIR_R, WIDGET_LIST_END);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
733
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
734 /* Jacket buttons */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
735 w->SetWidgetsDisabledState(_pf_info[PFV_JACKET].valid_values[ge] < 2,
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
736 PFW_WIDGET_JACKET, PFW_WIDGET_JACKET_L, PFW_WIDGET_JACKET_R, WIDGET_LIST_END);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
737
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
738 /* Collar buttons */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
739 w->SetWidgetsDisabledState(_pf_info[PFV_COLLAR].valid_values[ge] < 2,
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
740 PFW_WIDGET_COLLAR, PFW_WIDGET_COLLAR_L, PFW_WIDGET_COLLAR_R, WIDGET_LIST_END);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
741
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
742 /* Tie/earring buttons | female faces without earring haven't any earring options */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
743 w->SetWidgetsDisabledState(_pf_info[PFV_TIE_EARRING].valid_values[ge] < 2 ||
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
744 (is_female && GetPlayerFaceBits(*pf, PFV_HAS_TIE_EARRING, ge) == 0),
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
745 PFW_WIDGET_TIE_EARRING, PFW_WIDGET_TIE_EARRING_L, PFW_WIDGET_TIE_EARRING_R, WIDGET_LIST_END);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
746
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
747 /* Glasses buttons | faces without glasses haven't any glasses options */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
748 w->SetWidgetsDisabledState(_pf_info[PFV_GLASSES].valid_values[ge] < 2 || GetPlayerFaceBits(*pf, PFV_HAS_GLASSES, ge) == 0,
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
749 PFW_WIDGET_GLASSES, PFW_WIDGET_GLASSES_L, PFW_WIDGET_GLASSES_R, WIDGET_LIST_END);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
750 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
751
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
752 DrawWindowWidgets(w);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
753
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
754 /* Draw dynamic button value and labels for the advanced player face selection window */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
755 if (WP(w, facesel_d).advanced) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
756 if (is_female) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
757 /* Only for female faces */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
758 DrawFaceStringLabel(w, PFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_EARRING, GetPlayerFaceBits(*pf, PFV_HAS_TIE_EARRING, ge), true );
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
759 DrawFaceStringLabel(w, PFW_WIDGET_TIE_EARRING, STR_FACE_EARRING, GetPlayerFaceBits(*pf, PFV_TIE_EARRING, ge), false);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
760 } else {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
761 /* Only for male faces */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
762 DrawFaceStringLabel(w, PFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_MOUSTACHE, GetPlayerFaceBits(*pf, PFV_HAS_MOUSTACHE, ge), true );
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
763 DrawFaceStringLabel(w, PFW_WIDGET_TIE_EARRING, STR_FACE_TIE, GetPlayerFaceBits(*pf, PFV_TIE_EARRING, ge), false);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
764 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
765 if (is_moust_male) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
766 /* Only for male faces with moustache */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
767 DrawFaceStringLabel(w, PFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_MOUSTACHE, GetPlayerFaceBits(*pf, PFV_MOUSTACHE, ge), false);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
768 } else {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
769 /* Only for female faces or male faces without moustache */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
770 DrawFaceStringLabel(w, PFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_LIPS, GetPlayerFaceBits(*pf, PFV_LIPS, ge), false);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
771 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
772 /* For all faces */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
773 DrawFaceStringLabel(w, PFW_WIDGET_HAS_GLASSES, STR_FACE_GLASSES, GetPlayerFaceBits(*pf, PFV_HAS_GLASSES, ge), true );
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
774 DrawFaceStringLabel(w, PFW_WIDGET_HAIR, STR_FACE_HAIR, GetPlayerFaceBits(*pf, PFV_HAIR, ge), false);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
775 DrawFaceStringLabel(w, PFW_WIDGET_EYEBROWS, STR_FACE_EYEBROWS, GetPlayerFaceBits(*pf, PFV_EYEBROWS, ge), false);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
776 DrawFaceStringLabel(w, PFW_WIDGET_EYECOLOUR, STR_FACE_EYECOLOUR, GetPlayerFaceBits(*pf, PFV_EYE_COLOUR, ge), false);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
777 DrawFaceStringLabel(w, PFW_WIDGET_GLASSES, STR_FACE_GLASSES, GetPlayerFaceBits(*pf, PFV_GLASSES, ge), false);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
778 DrawFaceStringLabel(w, PFW_WIDGET_NOSE, STR_FACE_NOSE, GetPlayerFaceBits(*pf, PFV_NOSE, ge), false);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
779 DrawFaceStringLabel(w, PFW_WIDGET_CHIN, STR_FACE_CHIN, GetPlayerFaceBits(*pf, PFV_CHIN, ge), false);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
780 DrawFaceStringLabel(w, PFW_WIDGET_JACKET, STR_FACE_JACKET, GetPlayerFaceBits(*pf, PFV_JACKET, ge), false);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
781 DrawFaceStringLabel(w, PFW_WIDGET_COLLAR, STR_FACE_COLLAR, GetPlayerFaceBits(*pf, PFV_COLLAR, ge), false);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
782 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
783
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
784 /* Draw the player face picture */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
785 DrawPlayerFace(*pf, GetPlayer((PlayerID)w->window_number)->player_color, 2, 16);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
786 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
787
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
788 case WE_CLICK:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
789 switch (e->we.click.widget) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
790 /* Toggle size, advanced/simple face selection */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
791 case PFW_WIDGET_TOGGLE_LARGE_SMALL:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
792 case PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
793 DoCommandP(0, 0, *pf, NULL, CMD_SET_PLAYER_FACE);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
794 DeleteWindow(w);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
795 DoSelectPlayerFace((PlayerID)w->window_number, !WP(w, facesel_d).advanced);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
796 break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
797
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
798 /* Cancel button */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
799 case PFW_WIDGET_CANCEL:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
800 DeleteWindow(w);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
801 break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
802
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
803 /* OK button */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
804 case PFW_WIDGET_ACCEPT:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
805 DoCommandP(0, 0, *pf, NULL, CMD_SET_PLAYER_FACE);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
806 DeleteWindow(w);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
807 break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
808
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
809 /* Load button */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
810 case PFW_WIDGET_LOAD:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
811 *pf = _player_face;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
812 ScaleAllPlayerFaceBits(*pf);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
813 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_LOAD_DONE, 0, 0);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
814 SetWindowDirty(w);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
815 break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
816
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
817 /* 'Player face number' button, view and/or set player face number */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
818 case PFW_WIDGET_FACECODE:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
819 SetDParam(0, *pf);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
820 ShowQueryString(STR_JUST_INT, STR_FACE_FACECODE_CAPTION, 10 + 1, 0, w, CS_NUMERAL);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
821 break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
822
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
823 /* Save button */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
824 case PFW_WIDGET_SAVE:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
825 _player_face = *pf;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
826 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_SAVE_DONE, 0, 0);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
827 break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
828
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
829 /* Toggle gender (male/female) button */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
830 case PFW_WIDGET_MALE:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
831 case PFW_WIDGET_FEMALE:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
832 SetPlayerFaceBits(*pf, PFV_GENDER, ge, e->we.click.widget - PFW_WIDGET_MALE);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
833 ScaleAllPlayerFaceBits(*pf);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
834 SetWindowDirty(w);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
835 break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
836
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
837 /* Randomize face button */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
838 case PFW_WIDGET_RANDOM_NEW_FACE:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
839 RandomPlayerFaceBits(*pf, ge, WP(w, facesel_d).advanced);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
840 SetWindowDirty(w);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
841 break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
842
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
843 /* Toggle ethnicity (european/african) button */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
844 case PFW_WIDGET_ETHNICITY_EUR:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
845 case PFW_WIDGET_ETHNICITY_AFR:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
846 SetPlayerFaceBits(*pf, PFV_ETHNICITY, ge, e->we.click.widget - PFW_WIDGET_ETHNICITY_EUR);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
847 ScaleAllPlayerFaceBits(*pf);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
848 SetWindowDirty(w);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
849 break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
850
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
851 default:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
852 /* For all buttons from PFW_WIDGET_HAS_MOUSTACHE_EARRING to PFW_WIDGET_GLASSES_R is the same function.
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
853 * Therefor is this combined function.
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
854 * First it checks which PlayerFaceVariable will be change and then
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
855 * a: invert the value for boolean variables
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
856 * or b: it checks inside of IncreasePlayerFaceBits() if a left (_L) butten is pressed and then decrease else increase the variable */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
857 if (WP(w, facesel_d).advanced && e->we.click.widget >= PFW_WIDGET_HAS_MOUSTACHE_EARRING && e->we.click.widget <= PFW_WIDGET_GLASSES_R) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
858 PlayerFaceVariable pfv; // which PlayerFaceVariable shall be edited
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
859
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
860 if (e->we.click.widget < PFW_WIDGET_EYECOLOUR_L) { // Bool buttons
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
861 switch (e->we.click.widget - PFW_WIDGET_HAS_MOUSTACHE_EARRING) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
862 default: NOT_REACHED();
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
863 case 0: pfv = is_female ? PFV_HAS_TIE_EARRING : PFV_HAS_MOUSTACHE; break; // Has earring/moustache button
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
864 case 1: pfv = PFV_HAS_GLASSES; break; // Has glasses button
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
865 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
866 SetPlayerFaceBits(*pf, pfv, ge, !GetPlayerFaceBits(*pf, pfv, ge));
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
867 ScaleAllPlayerFaceBits(*pf);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
868
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
869 } else { // Value buttons
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
870 switch ((e->we.click.widget - PFW_WIDGET_EYECOLOUR_L) / 3) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
871 default: NOT_REACHED();
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
872 case 0: pfv = PFV_EYE_COLOUR; break; // Eye colour buttons
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
873 case 1: pfv = PFV_CHIN; break; // Chin buttons
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
874 case 2: pfv = PFV_EYEBROWS; break; // Eyebrows buttons
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
875 case 3: pfv = is_moust_male ? PFV_MOUSTACHE : PFV_LIPS; break; // Moustache or lips buttons
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
876 case 4: pfv = PFV_NOSE; break; // Nose buttons
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
877 case 5: pfv = PFV_HAIR; break; // Hair buttons
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
878 case 6: pfv = PFV_JACKET; break; // Jacket buttons
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
879 case 7: pfv = PFV_COLLAR; break; // Collar buttons
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
880 case 8: pfv = PFV_TIE_EARRING; break; // Tie/earring buttons
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
881 case 9: pfv = PFV_GLASSES; break; // Glasses buttons
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
882 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
883 /* 0 == left (_L), 1 == middle or 2 == right (_R) - button click */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
884 IncreasePlayerFaceBits(*pf, pfv, ge, (((e->we.click.widget - PFW_WIDGET_EYECOLOUR_L) % 3) != 0) ? 1 : -1);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
885 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
886
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
887 SetWindowDirty(w);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
888 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
889 break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
890 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
891 break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
892
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
893 case WE_ON_EDIT_TEXT:
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
894 /* Set a new player face number */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
895 if (!StrEmpty(e->we.edittext.str)) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
896 *pf = strtoul(e->we.edittext.str, NULL, 10);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
897 ScaleAllPlayerFaceBits(*pf);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
898 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_SET, 0, 0);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
899 SetWindowDirty(w);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
900 } else {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
901 ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_ERR, 0, 0);
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
902 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
903 break;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
904 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
905 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
906
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
907 /** normal/simple player face selection window description */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
908 static const WindowDesc _select_player_face_desc = {
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
909 WDP_AUTO, WDP_AUTO, 190, 163, 190, 163,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5854
diff changeset
910 WC_PLAYER_FACE, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
911 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
912 _select_player_face_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
913 SelectPlayerFaceWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
914 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
915
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
916 /** advanced player face selection window description */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
917 static const WindowDesc _select_player_face_adv_desc = {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
918 WDP_AUTO, WDP_AUTO, 220, 220, 220, 220,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
919 WC_PLAYER_FACE, WC_NONE,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
920 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
921 _select_player_face_adv_widgets,
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
922 SelectPlayerFaceWndProc
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
923 };
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
924
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
925 /**
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
926 * Open the simple/advanced player face selection window
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
927 *
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
928 * @param player the player which face shall be edited
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
929 * @param adv simple or advanced player face selection window
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
930 *
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
931 * @pre is player a valid player
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
932 */
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
933 static void DoSelectPlayerFace(PlayerID player, bool adv)
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
934 {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
935 if (!IsValidPlayer(player)) return;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
936
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
937 Window *w = AllocateWindowDescFront(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, player); // simple or advanced window
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
938
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
939 if (w != NULL) {
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
940 w->caption_color = w->window_number;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
941 WP(w, facesel_d).face = GetPlayer((PlayerID)w->window_number)->face;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
942 WP(w, facesel_d).advanced = adv;
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
943 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
944 }
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
945
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
946
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
947 /* Names of the widgets. Keep them in the same order as in the widget array */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
948 enum PlayerCompanyWindowWidgets {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
949 PCW_WIDGET_CLOSEBOX = 0,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
950 PCW_WIDGET_CAPTION,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
951 PCW_WIDGET_FACE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
952 PCW_WIDGET_NEW_FACE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
953 PCW_WIDGET_COLOR_SCHEME,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
954 PCW_WIDGET_PRESIDENT_NAME,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
955 PCW_WIDGET_COMPANY_NAME,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
956 PCW_WIDGET_BUILD_VIEW_HQ,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
957 PCW_WIDGET_RELOCATE_HQ,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
958 PCW_WIDGET_BUY_SHARE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
959 PCW_WIDGET_SELL_SHARE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
960 PCW_WIDGET_COMPANY_PASSWORD,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
961 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
962
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
963 static const Widget _player_company_widgets[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
964 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
965 { WWT_CAPTION, RESIZE_NONE, 14, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
966 { WWT_PANEL, RESIZE_NONE, 14, 0, 359, 14, 157, 0x0, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
967 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 89, 158, 169, STR_7004_NEW_FACE, STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
968 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 90, 179, 158, 169, STR_7005_COLOR_SCHEME, STR_7031_CHANGE_THE_COMPANY_VEHICLE},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
969 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 180, 269, 158, 169, STR_7009_PRESIDENT_NAME, STR_7032_CHANGE_THE_PRESIDENT_S},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
970 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 270, 359, 158, 169, STR_7008_COMPANY_NAME, STR_7033_CHANGE_THE_COMPANY_NAME},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
971 { WWT_TEXTBTN, RESIZE_NONE, 14, 266, 355, 18, 29, STR_7072_VIEW_HQ, STR_7070_BUILD_COMPANY_HEADQUARTERS},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
972 { WWT_TEXTBTN, RESIZE_NONE, 14, 266, 355, 32, 43, STR_RELOCATE_HQ, STR_RELOCATE_COMPANY_HEADQUARTERS},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
973 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 179, 158, 169, STR_7077_BUY_25_SHARE_IN_COMPANY, STR_7079_BUY_25_SHARE_IN_THIS_COMPANY},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
974 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 180, 359, 158, 169, STR_7078_SELL_25_SHARE_IN_COMPANY, STR_707A_SELL_25_SHARE_IN_THIS_COMPANY},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
975 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 266, 355, 138, 149, STR_COMPANY_PASSWORD, STR_COMPANY_PASSWORD_TOOLTIP},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
976 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
977 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
978
7934
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
979
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
980 /**
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
981 * Draws text "Vehicles:" and number of all vehicle types, or "(none)"
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
982 * @param player ID of player to print statistics of
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
983 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
984 static void DrawPlayerVehiclesAmount(PlayerID player)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
985 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
986 const int x = 110;
7934
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
987 int y = 63;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
988 const Vehicle *v;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
989 uint train = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
990 uint road = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
991 uint air = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
992 uint ship = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
993
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
994 DrawString(x, y, STR_7039_VEHICLES, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
995
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
996 FOR_ALL_VEHICLES(v) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
997 if (v->owner == player) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
998 switch (v->type) {
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
999 case VEH_TRAIN: if (IsFrontEngine(v)) train++; break;
6857
0005a9ed1903 (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros <maedhros@openttd.org>
parents: 6769
diff changeset
1000 case VEH_ROAD: if (IsRoadVehFront(v)) road++; break;
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
1001 case VEH_AIRCRAFT: if (IsNormalAircraft(v)) air++; break;
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
1002 case VEH_SHIP: ship++; break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1003 default: break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1004 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1005 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1006 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1007
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6352
diff changeset
1008 if (train + road + air + ship == 0) {
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
1009 DrawString(x + 70, y, STR_7042_NONE, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1010 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1011 if (train != 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1012 SetDParam(0, train);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
1013 DrawString(x + 70, y, STR_TRAINS, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1014 y += 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1015 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1016
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1017 if (road != 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1018 SetDParam(0, road);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
1019 DrawString(x + 70, y, STR_ROAD_VEHICLES, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1020 y += 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1021 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1022
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1023 if (air != 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1024 SetDParam(0, air);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
1025 DrawString(x + 70, y, STR_AIRCRAFT, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1026 y += 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1027 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1028
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1029 if (ship != 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1030 SetDParam(0, ship);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
1031 DrawString(x + 70, y, STR_SHIPS, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1032 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1033 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1034 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1035
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1036 int GetAmountOwnedBy(const Player *p, PlayerID owner)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1037 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1038 return (p->share_owners[0] == owner) +
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1039 (p->share_owners[1] == owner) +
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1040 (p->share_owners[2] == owner) +
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1041 (p->share_owners[3] == owner);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1042 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1043
7934
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1044 /**
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1045 * Draws list of all companies with shares
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1046 * @param p pointer to the Player structure
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1047 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1048 static void DrawCompanyOwnerText(const Player *p)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1049 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1050 const Player *p2;
7884
870ff6c7c551 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents: 7824
diff changeset
1051 uint num = 0;
870ff6c7c551 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents: 7824
diff changeset
1052 const byte height = GetCharacterHeight(FS_NORMAL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1053
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1054 FOR_ALL_PLAYERS(p2) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1055 uint amt = GetAmountOwnedBy(p, p2->index);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1056 if (amt != 0) {
7884
870ff6c7c551 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents: 7824
diff changeset
1057 SetDParam(0, amt * 25);
870ff6c7c551 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents: 7824
diff changeset
1058 SetDParam(1, p2->index);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1059
7884
870ff6c7c551 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents: 7824
diff changeset
1060 DrawString(120, (num++) * height + 116, STR_707D_OWNED_BY, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1061 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1062 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1063 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1064
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1065 /**
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1066 * Player company window event definition
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1067 *
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1068 * @param w window pointer
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1069 * @param e event been triggered
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1070 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1071 static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1072 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1073 switch (e->event) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1074 case WE_PAINT: {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
1075 const Player *p = GetPlayer((PlayerID)w->window_number);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1076 bool local = w->window_number == _local_player;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1077
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1078 w->SetWidgetHiddenState(PCW_WIDGET_NEW_FACE, !local);
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1079 w->SetWidgetHiddenState(PCW_WIDGET_COLOR_SCHEME, !local);
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1080 w->SetWidgetHiddenState(PCW_WIDGET_PRESIDENT_NAME, !local);
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1081 w->SetWidgetHiddenState(PCW_WIDGET_COMPANY_NAME, !local);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1082 w->widget[PCW_WIDGET_BUILD_VIEW_HQ].data = (local && p->location_of_house == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1083 if (local && p->location_of_house != 0) w->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1084 w->SetWidgetDisabledState(PCW_WIDGET_BUILD_VIEW_HQ, !local && p->location_of_house == 0);
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1085 w->SetWidgetHiddenState(PCW_WIDGET_RELOCATE_HQ, !local || p->location_of_house == 0);
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1086 w->SetWidgetHiddenState(PCW_WIDGET_BUY_SHARE, local);
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1087 w->SetWidgetHiddenState(PCW_WIDGET_SELL_SHARE, local);
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1088 w->SetWidgetHiddenState(PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1089
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1090 if (!local) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1091 if (_patches.allow_shares) { // Shares are allowed
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1092 /* If all shares are owned by someone (none by nobody), disable buy button */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1093 w->SetWidgetDisabledState(PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 ||
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1094 /* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1095 (GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) ||
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1096 /* Spectators cannot do anything of course */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1097 _local_player == PLAYER_SPECTATOR);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1098
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1099 /* If the player doesn't own any shares, disable sell button */
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1100 w->SetWidgetDisabledState(PCW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(p, _local_player) == 0) ||
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1101 /* Spectators cannot do anything of course */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1102 _local_player == PLAYER_SPECTATOR);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1103 } else { // Shares are not allowed, disable buy/sell buttons
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1104 w->DisableWidget(PCW_WIDGET_BUY_SHARE);
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1105 w->DisableWidget(PCW_WIDGET_SELL_SHARE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1106 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1107 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1108
7058
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1109 SetDParam(0, p->index);
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1110 SetDParam(1, p->index);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1111
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1112 DrawWindowWidgets(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1113
7934
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1114 /* Player face */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1115 DrawPlayerFace(p->face, p->player_color, 2, 16);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1116
7934
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1117 /* "xxx (Manager)" */
7058
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1118 SetDParam(0, p->index);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1119 DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1120
7934
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1121 /* "Inaugurated:" */
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1122 SetDParam(0, p->inaugurated_year);
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1123 DrawString(110, 23, STR_7038_INAUGURATED, TC_FROMSTRING);
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1124
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1125 /* "Colour scheme:" */
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1126 DrawString(110, 43, STR_7006_COLOR_SCHEME, TC_FROMSTRING);
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1127 /* Draw company-colour bus */
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1128 DrawSprite(SPR_VEH_BUS_SW_VIEW, PLAYER_SPRITE_COLOR(p->index), 215, 44);
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1129
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1130 /* "Vehicles:" */
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1131 DrawPlayerVehiclesAmount((PlayerID)w->window_number);
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1132
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1133 /* "Company value:" */
7002
fa75522e0249 (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents: 6991
diff changeset
1134 SetDParam(0, CalculateCompanyValue(p));
7884
870ff6c7c551 (svn r11435) -Codechange: show all players who have shares, not just the first two. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents: 7824
diff changeset
1135 DrawString(110, 106, STR_7076_COMPANY_VALUE, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1136
7934
2f3f637d58b4 (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI
smatz <smatz@openttd.org>
parents: 7932
diff changeset
1137 /* Shares list */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1138 DrawCompanyOwnerText(p);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1139
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1140 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1141 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1142
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1143 case WE_CLICK:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1144 switch (e->we.click.widget) {
7734
0352f37d7696 (svn r11269) -Feature: user customisable faces. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1145 case PCW_WIDGET_NEW_FACE: DoSelectPlayerFace((PlayerID)w->window_number, false); break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1146
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1147 case PCW_WIDGET_COLOR_SCHEME: {
6914
d4c8b81ac7e4 (svn r10167) -Codechange: Change the flagging system of grf loaded feature from a bitset to a bool evaluation.
belugas <belugas@openttd.org>
parents: 6909
diff changeset
1148 Window *wf = AllocateWindowDescFront(_loaded_newgrf_features.has_2CC ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1149 if (wf != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1150 wf->caption_color = wf->window_number;
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6352
diff changeset
1151 WP(wf, livery_d).livery_class = LC_OTHER;
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6352
diff changeset
1152 WP(wf, livery_d).sel = 1;
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1153 wf->LowerWidget(2);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1154 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1155 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1156 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1157
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1158 case PCW_WIDGET_PRESIDENT_NAME: {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
1159 const Player *p = GetPlayer((PlayerID)w->window_number);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1160 WP(w, def_d).byte_1 = 0;
7058
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1161 SetDParam(0, p->index);
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1162 ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, 31, 94, w, CS_ALPHANUMERAL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1163 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1164 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1165
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1166 case PCW_WIDGET_COMPANY_NAME: {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
1167 Player *p = GetPlayer((PlayerID)w->window_number);
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6352
diff changeset
1168 WP(w, def_d).byte_1 = 1;
7058
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1169 SetDParam(0, p->index);
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1170 ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, 31, 150, w, CS_ALPHANUMERAL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1171 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1172 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1173
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1174 case PCW_WIDGET_BUILD_VIEW_HQ: {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
1175 TileIndex tile = GetPlayer((PlayerID)w->window_number)->location_of_house;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1176 if (tile == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1177 if ((byte)w->window_number != _local_player)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1178 return;
7889
1ed44baec4d2 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents: 7884
diff changeset
1179 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1180 SetTileSelectSize(2, 2);
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1181 w->LowerWidget(PCW_WIDGET_BUILD_VIEW_HQ);
8028
936ad1eb1c04 (svn r11588) -Codechange: use the new member introduced in r11551
glx <glx@openttd.org>
parents: 7998
diff changeset
1182 w->InvalidateWidget(PCW_WIDGET_BUILD_VIEW_HQ);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1183 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1184 ScrollMainWindowToTile(tile);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1185 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1186 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1187 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1188
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1189 case PCW_WIDGET_RELOCATE_HQ:
7889
1ed44baec4d2 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents: 7884
diff changeset
1190 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1191 SetTileSelectSize(2, 2);
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7934
diff changeset
1192 w->LowerWidget(PCW_WIDGET_RELOCATE_HQ);
8028
936ad1eb1c04 (svn r11588) -Codechange: use the new member introduced in r11551
glx <glx@openttd.org>
parents: 7998
diff changeset
1193 w->InvalidateWidget(PCW_WIDGET_RELOCATE_HQ);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1194 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1195
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1196 case PCW_WIDGET_BUY_SHARE:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1197 DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1198 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1199
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1200 case PCW_WIDGET_SELL_SHARE:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1201 DoCommandP(0, w->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1202 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1203
7998
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7997
diff changeset
1204 #ifdef ENABLE_NETWORK
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1205 case PCW_WIDGET_COMPANY_PASSWORD:
7998
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7997
diff changeset
1206 if (w->window_number == _local_player) ShowNetworkCompanyPasswordWindow();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1207 break;
7998
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7997
diff changeset
1208 #endif /* ENABLE_NETWORK */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1209 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1210 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1211
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1212 case WE_MOUSELOOP:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1213 /* redraw the window every now and then */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1214 if ((++w->vscroll.pos & 0x1F) == 0) SetWindowDirty(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1215 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1216
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1217 case WE_PLACE_OBJ:
7521
f5b39ff47e0e (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium <rubidium@openttd.org>
parents: 7513
diff changeset
1218 if (DoCommandP(e->we.place.tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1219 ResetObjectToPlace();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1220 w->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button
8032
9c2c084ce541 (svn r11592) -Codechange: Use the Window member RaiseButtons and remove the now useless RaiseWindowButtons function
belugas <belugas@openttd.org>
parents: 8028
diff changeset
1221 w->RaiseButtons();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1222 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1223
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1224 case WE_ABORT_PLACE_OBJ:
8032
9c2c084ce541 (svn r11592) -Codechange: Use the Window member RaiseButtons and remove the now useless RaiseWindowButtons function
belugas <belugas@openttd.org>
parents: 8028
diff changeset
1225 w->RaiseButtons();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1226 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1227
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1228 case WE_DESTROY:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1229 DeleteWindowById(WC_PLAYER_FACE, w->window_number);
7998
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7997
diff changeset
1230 if (w->window_number == _local_player) DeleteWindowById(WC_COMPANY_PASSWORD_WINDOW, 0);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1231 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1232
7998
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7997
diff changeset
1233 case WE_ON_EDIT_TEXT:
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7997
diff changeset
1234 if (StrEmpty(e->we.edittext.str)) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1235
7998
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7997
diff changeset
1236 _cmd_text = e->we.edittext.str;
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6352
diff changeset
1237 switch (WP(w, def_d).byte_1) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1238 case 0: /* Change president name */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1239 DoCommandP(0, 0, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1240 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1241 case 1: /* Change company name */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1242 DoCommandP(0, 0, 0, NULL, CMD_CHANGE_COMPANY_NAME | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1243 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1244 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1245 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1246 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1247 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1248
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1249
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1250 static const WindowDesc _player_company_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
1251 WDP_AUTO, WDP_AUTO, 360, 170, 360, 170,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5854
diff changeset
1252 WC_COMPANY, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1253 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1254 _player_company_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1255 PlayerCompanyWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1256 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1257
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1258 void ShowPlayerCompany(PlayerID player)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1259 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1260 Window *w;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1261
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1262 if (!IsValidPlayer(player)) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1263
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1264 w = AllocateWindowDescFront(&_player_company_desc, player);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1265 if (w != NULL) w->caption_color = w->window_number;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1266 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1267
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1268
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1269
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1270 static void BuyCompanyWndProc(Window *w, WindowEvent *e)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1271 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1272 switch (e->event) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1273 case WE_PAINT: {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
1274 Player *p = GetPlayer((PlayerID)w->window_number);
7141
609929f60b39 (svn r10415) -Revert (r10403), Fix (r10323): 'message from company' test must use {STRING1}, so pass it the correct params
glx <glx@openttd.org>
parents: 7058
diff changeset
1275 SetDParam(0, STR_COMPANY_NAME);
609929f60b39 (svn r10415) -Revert (r10403), Fix (r10323): 'message from company' test must use {STRING1}, so pass it the correct params
glx <glx@openttd.org>
parents: 7058
diff changeset
1276 SetDParam(1, p->index);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1277 DrawWindowWidgets(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1278
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1279 DrawPlayerFace(p->face, p->player_color, 2, 16);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1280
7058
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1281 SetDParam(0, p->index);
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1282 SetDParam(1, p->bankrupt_value);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1283 DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1284 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1285 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1286
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1287 case WE_CLICK:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1288 switch (e->we.click.widget) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1289 case 3:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1290 DeleteWindow(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1291 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1292 case 4: {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1293 DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1294 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1295 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1296 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1297 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1298 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1299 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1300
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1301 static const Widget _buy_company_widgets[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1302 { WWT_CLOSEBOX, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1303 { WWT_CAPTION, RESIZE_NONE, 5, 11, 333, 0, 13, STR_00B3_MESSAGE_FROM, STR_018C_WINDOW_TITLE_DRAG_THIS},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1304 { WWT_PANEL, RESIZE_NONE, 5, 0, 333, 14, 136, 0x0, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1305 { WWT_TEXTBTN, RESIZE_NONE, 5, 148, 207, 117, 128, STR_00C9_NO, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1306 { WWT_TEXTBTN, RESIZE_NONE, 5, 218, 277, 117, 128, STR_00C8_YES, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1307 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1308 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1309
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1310 static const WindowDesc _buy_company_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
1311 153, 171, 334, 137, 334, 137,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5854
diff changeset
1312 WC_BUY_COMPANY, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1313 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1314 _buy_company_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1315 BuyCompanyWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1316 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1317
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1318
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1319 void ShowBuyCompanyDialog(uint player)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1320 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1321 AllocateWindowDescFront(&_buy_company_desc, player);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1322 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1323
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1324 /********** HIGHSCORE and ENDGAME windows */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1325
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1326 /* Always draw a maximized window and within there the centered background */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1327 static void SetupHighScoreEndWindow(Window *w, uint *x, uint *y)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1328 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1329 uint i;
6352
d646bb89ca43 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas <belugas@openttd.org>
parents: 6259
diff changeset
1330 /* resize window to "full-screen" */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1331 w->width = _screen.width;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1332 w->height = _screen.height;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1333 w->widget[0].right = w->width - 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1334 w->widget[0].bottom = w->height - 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1335
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1336 DrawWindowWidgets(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1337
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1338 /* Center Highscore/Endscreen background */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1339 *x = max(0, (_screen.width / 2) - (640 / 2));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1340 *y = max(0, (_screen.height / 2) - (480 / 2));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1341 for (i = 0; i < 10; i++) // the image is split into 10 50px high parts
5668
3d6d9bff3dd8 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents: 5587
diff changeset
1342 DrawSprite(WP(w, highscore_d).background_img + i, PAL_NONE, *x, *y + (i * 50));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1343 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1344
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1345 extern StringID EndGameGetPerformanceTitleFromValue(uint value);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1346
6352
d646bb89ca43 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas <belugas@openttd.org>
parents: 6259
diff changeset
1347 /** End game window shown at the end of the game */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1348 static void EndGameWndProc(Window *w, WindowEvent *e)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1349 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1350 switch (e->event) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1351 case WE_PAINT: {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1352 const Player *p;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1353 uint x, y;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1354
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1355 SetupHighScoreEndWindow(w, &x, &y);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1356
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1357 if (!IsValidPlayer(_local_player)) break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1358
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1359 p = GetPlayer(_local_player);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1360 /* We need to get performance from last year because the image is shown
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1361 * at the start of the new year when these things have already been copied */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1362 if (WP(w, highscore_d).background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/
7058
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1363 SetDParam(0, p->index);
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1364 SetDParam(1, p->index);
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1365 SetDParam(2, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1366 DrawStringMultiCenter(x + (640 / 2), y + 107, STR_021C_OF_ACHIEVES_STATUS, 640);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1367 } else {
7058
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1368 SetDParam(0, p->index);
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7002
diff changeset
1369 SetDParam(1, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1370 DrawStringMultiCenter(x + (640 / 2), y + 157, STR_021B_ACHIEVES_STATUS, 640);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1371 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1372 } break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1373 case WE_CLICK: /* Close the window (and show the highscore window) */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1374 DeleteWindow(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1375 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1376 case WE_DESTROY: /* Show the highscore window when this one is closed */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1377 if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1378 ShowHighscoreTable(w->window_number, WP(w, highscore_d).rank);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1379 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1380 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1381 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1382
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1383 static void HighScoreWndProc(Window *w, WindowEvent *e)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1384 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1385 switch (e->event) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1386 case WE_PAINT: {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1387 const HighScore *hs = _highscore_table[w->window_number];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1388 uint x, y;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1389 uint8 i;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1390
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1391 SetupHighScoreEndWindow(w, &x, &y);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1392
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1393 SetDParam(0, _patches.ending_year);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1394 SetDParam(1, w->window_number + STR_6801_EASY);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1395 DrawStringMultiCenter(x + (640 / 2), y + 62, !_networking ? STR_0211_TOP_COMPANIES_WHO_REACHED : STR_TOP_COMPANIES_NETWORK_GAME, 500);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1396
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1397 /* Draw Highscore peepz */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1398 for (i = 0; i < lengthof(_highscore_table[0]); i++) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1399 SetDParam(0, i + 1);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
1400 DrawString(x + 40, y + 140 + (i * 55), STR_0212, TC_BLACK);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1401
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1402 if (hs[i].company[0] != '\0') {
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7734
diff changeset
1403 TextColour colour = (WP(w, highscore_d).rank == (int8)i) ? TC_RED : TC_BLACK; // draw new highscore in red
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1404
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1405 DoDrawString(hs[i].company, x + 71, y + 140 + (i * 55), colour);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1406 SetDParam(0, hs[i].title);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1407 SetDParam(1, hs[i].score);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1408 DrawString(x + 71, y + 160 + (i * 55), STR_HIGHSCORE_STATS, colour);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1409 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1410 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1411 } break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1412
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1413 case WE_CLICK: /* Onclick to close window, and in destroy event handle the rest */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1414 DeleteWindow(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1415 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1416
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1417 case WE_DESTROY: /* Get back all the hidden windows */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1418 if (_game_mode != GM_MENU) ShowVitalWindows();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1419
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1420 if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1421 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1422 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1423 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1424
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1425 static const Widget _highscore_widgets[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1426 { WWT_PANEL, RESIZE_NONE, 16, 0, 640, 0, 480, 0x0, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1427 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1428 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1429
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1430 static const WindowDesc _highscore_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
1431 0, 0, 641, 481, 641, 481,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5854
diff changeset
1432 WC_HIGHSCORE, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1433 0,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1434 _highscore_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1435 HighScoreWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1436 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1437
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1438 static const WindowDesc _endgame_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
1439 0, 0, 641, 481, 641, 481,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5854
diff changeset
1440 WC_ENDSCREEN, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1441 0,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1442 _highscore_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1443 EndGameWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1444 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1445
6352
d646bb89ca43 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas <belugas@openttd.org>
parents: 6259
diff changeset
1446 /** Show the highscore table for a given difficulty. When called from
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1447 * endgame ranking is set to the top5 element that was newly added
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1448 * and is thus highlighted */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1449 void ShowHighscoreTable(int difficulty, int8 ranking)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1450 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1451 Window *w;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1452
6352
d646bb89ca43 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas <belugas@openttd.org>
parents: 6259
diff changeset
1453 /* pause game to show the chart */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1454 if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1455
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1456 /* Close all always on-top windows to get a clean screen */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1457 if (_game_mode != GM_MENU) HideVitalWindows();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1458
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1459 DeleteWindowByClass(WC_HIGHSCORE);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1460 w = AllocateWindowDesc(&_highscore_desc);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1461
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1462 if (w != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1463 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1464 w->window_number = difficulty; // show highscore chart for difficulty...
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1465 WP(w, highscore_d).background_img = SPR_HIGHSCORE_CHART_BEGIN; // which background to show
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1466 WP(w, highscore_d).rank = ranking;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1467 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1468 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1469
6352
d646bb89ca43 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas <belugas@openttd.org>
parents: 6259
diff changeset
1470 /** Show the endgame victory screen in 2050. Update the new highscore
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1471 * if it was high enough */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6190
diff changeset
1472 void ShowEndGameChart()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1473 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1474 Window *w;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1475
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1476 /* Dedicated server doesn't need the highscore window */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1477 if (_network_dedicated) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1478 /* Pause in single-player to have a look at the highscore at your own leisure */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1479 if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1480
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1481 HideVitalWindows();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1482 DeleteWindowByClass(WC_ENDSCREEN);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1483 w = AllocateWindowDesc(&_endgame_desc);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1484
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1485 if (w != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1486 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1487
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1488 WP(w, highscore_d).background_img = SPR_TYCOON_IMG1_BEGIN;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1489
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1490 if (_local_player != PLAYER_SPECTATOR) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1491 const Player *p = GetPlayer(_local_player);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1492 if (p->old_economy[0].performance_history == SCORE_MAX)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1493 WP(w, highscore_d).background_img = SPR_TYCOON_IMG2_BEGIN;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1494 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1495
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1496 /* In a network game show the endscores of the custom difficulty 'network' which is the last one
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1497 * as well as generate a TOP5 of that game, and not an all-time top5. */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1498 if (_networking) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1499 w->window_number = lengthof(_highscore_table) - 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1500 WP(w, highscore_d).rank = SaveHighScoreValueNetwork();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1501 } else {
6352
d646bb89ca43 (svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas <belugas@openttd.org>
parents: 6259
diff changeset
1502 /* in single player _local player is always valid */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1503 const Player *p = GetPlayer(_local_player);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1504 w->window_number = _opt.diff_level;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1505 WP(w, highscore_d).rank = SaveHighScoreValue(p);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1506 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1507 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1508 }