author | Darkvater |
Fri, 27 Jan 2006 09:45:44 +0000 | |
changeset 2896 | 44494ae027a6 |
parent 2725 | 5c632bc5be28 |
child 2952 | 6a26eeda9679 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1875
diff
changeset
|
4 |
#include "openttd.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1323
diff
changeset
|
5 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
200
diff
changeset
|
6 |
#include "table/strings.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
7 |
#include "functions.h" |
0 | 8 |
#include "window.h" |
9 |
#include "gui.h" |
|
10 |
#include "viewport.h" |
|
11 |
#include "gfx.h" |
|
12 |
#include "player.h" |
|
13 |
#include "command.h" |
|
14 |
#include "vehicle.h" |
|
186
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
15 |
#include "economy.h" |
773
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
16 |
#include "network.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2064
diff
changeset
|
17 |
#include "variables.h" |
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2642
diff
changeset
|
18 |
#include "train.h" |
773
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
19 |
|
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
20 |
#ifdef ENABLE_NETWORK |
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
21 |
#include "network_data.h" |
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
22 |
#include "network_client.h" |
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
23 |
#endif |
0 | 24 |
|
2475 | 25 |
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied); |
0 | 26 |
|
27 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2246
diff
changeset
|
28 |
static void DrawPlayerEconomyStats(const Player *p, byte mode) |
0 | 29 |
{ |
30 |
int x,y,i,j,year; |
|
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2246
diff
changeset
|
31 |
const int64 (*tbl)[13]; |
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2246
diff
changeset
|
32 |
int64 sum, cost; |
0 | 33 |
StringID str; |
34 |
||
186
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
35 |
if (!(mode & 1)) { // normal sized economics window (mode&1) is minimized status |
0 | 36 |
/* draw categories */ |
37 |
DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, 0); |
|
38 |
for(i=0; i!=13; i++) |
|
39 |
DrawString(2, 27 + i*10, STR_7011_CONSTRUCTION + i, 0); |
|
40 |
DrawStringRightAligned(111, 27 + 10*13 + 2, STR_7020_TOTAL, 0); |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
41 |
|
0 | 42 |
/* draw the price columns */ |
43 |
year = _cur_year - 2; |
|
44 |
j = 3; |
|
45 |
x = 215; |
|
46 |
tbl = p->yearly_expenses + 2; |
|
47 |
do { |
|
48 |
if (year >= p->inaugurated_year) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
49 |
SetDParam(0, year + 1920); |
0 | 50 |
DrawStringCenterUnderline(x-17, 15, STR_7010, 0); |
51 |
sum = 0; |
|
52 |
for(i=0; i!=13; i++) { |
|
53 |
/* draw one row in the price column */ |
|
54 |
cost = (*tbl)[i]; |
|
55 |
if (cost != 0) { |
|
56 |
sum += cost; |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
57 |
|
0 | 58 |
str = STR_701E; |
59 |
if (cost < 0) { cost = -cost; str++; } |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
60 |
SetDParam64(0, cost); |
0 | 61 |
DrawStringRightAligned(x, 27+i*10, str, 0); |
62 |
} |
|
63 |
} |
|
64 |
||
65 |
str = STR_701E; |
|
66 |
if (sum < 0) { sum = -sum; str++; } |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
67 |
SetDParam64(0, sum); |
0 | 68 |
DrawStringRightAligned(x, 27 + 13*10 + 2, str, 0); |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
69 |
|
0 | 70 |
GfxFillRect(x - 75, 27 + 10*13, x, 27 + 10*13, 215); |
71 |
x += 95; |
|
72 |
} |
|
73 |
year++; |
|
74 |
tbl--; |
|
75 |
} while (--j != 0); |
|
76 |
||
77 |
y = 171; |
|
186
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
78 |
|
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
79 |
// draw max loan aligned to loan below (y += 10) |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
80 |
SetDParam64(0, (uint64)_economy.max_loan); |
186
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
81 |
DrawString(202, y+10, STR_MAX_LOAN, 0); |
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
82 |
|
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
83 |
} else |
0 | 84 |
y = 15; |
85 |
||
86 |
DrawString(2, y, STR_7026_BANK_BALANCE, 0); |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
87 |
SetDParam64(0, p->money64); |
0 | 88 |
DrawStringRightAligned(182, y, STR_7028, 0); |
89 |
||
90 |
y += 10; |
|
91 |
||
92 |
DrawString(2, y, STR_7027_LOAN, 0); |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
93 |
SetDParam64(0, p->current_loan); |
0 | 94 |
DrawStringRightAligned(182, y, STR_7028, 0); |
95 |
||
96 |
y += 12; |
|
97 |
||
98 |
GfxFillRect(182 - 75, y-2, 182, y-2, 215); |
|
99 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
100 |
SetDParam64(0, p->money64 - p->current_loan); |
0 | 101 |
DrawStringRightAligned(182, y, STR_7028, 0); |
102 |
} |
|
103 |
||
104 |
static const Widget _player_finances_widgets[] = { |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2703
diff
changeset
|
105 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
888
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
106 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
107 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 380, 394, 0, 13, 0x2AA, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, |
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
108 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
109 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 406, 14, 169, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
110 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 406, 170, 203, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
111 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 202, 204, 215, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
112 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 203, 406, 204, 215, STR_702A_REPAY, STR_7036_REPAY_PART_OF_LOAN}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
150
diff
changeset
|
113 |
{ WIDGETS_END}, |
0 | 114 |
}; |
115 |
||
116 |
static const Widget _other_player_finances_widgets[] = { |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2703
diff
changeset
|
117 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
888
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
118 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
119 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 380, 394, 0, 13, 0x2AA, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, |
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
120 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
121 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 406, 14, 169, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
122 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 406, 170, 203, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
150
diff
changeset
|
123 |
{ WIDGETS_END}, |
0 | 124 |
}; |
125 |
||
126 |
static const Widget _other_player_finances_small_widgets[] = { |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2703
diff
changeset
|
127 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
888
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
128 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 253, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
129 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 254, 267, 0, 13, 0x2AA, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, |
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
130 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 268, 279, 0, 13, 0x0, STR_STICKY_BUTTON}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
131 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
132 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 279, 14, 47, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
150
diff
changeset
|
133 |
{ WIDGETS_END}, |
0 | 134 |
}; |
135 |
||
136 |
static const Widget _player_finances_small_widgets[] = { |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2703
diff
changeset
|
137 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
888
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
138 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 253, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
139 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 254, 267, 0, 13, 0x2AA, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, |
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
140 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 268, 279, 0, 13, 0x0, STR_STICKY_BUTTON}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
141 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
142 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 279, 14, 47, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
143 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 139, 48, 59, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
144 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 140, 279, 48, 59, STR_702A_REPAY, STR_7036_REPAY_PART_OF_LOAN}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
150
diff
changeset
|
145 |
{ WIDGETS_END}, |
0 | 146 |
}; |
147 |
||
148 |
||
149 |
static void PlayerFinancesWndProc(Window *w, WindowEvent *e) |
|
150 |
{ |
|
151 |
switch(e->event) { |
|
152 |
case WE_PAINT: { |
|
2475 | 153 |
PlayerID player = w->window_number; |
154 |
const Player* p = GetPlayer(player); |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
155 |
|
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
888
diff
changeset
|
156 |
w->disabled_state = p->current_loan != 0 ? 0 : (1 << 7); |
0 | 157 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
158 |
SetDParam(0, p->name_1); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
159 |
SetDParam(1, p->name_2); |
2475 | 160 |
SetDParam(2, GetPlayerNameString(player, 3)); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
161 |
SetDParam(4, 10000); |
0 | 162 |
DrawWindowWidgets(w); |
163 |
||
164 |
DrawPlayerEconomyStats(p, (byte)WP(w,def_d).data_1); |
|
165 |
} break; |
|
166 |
||
167 |
case WE_CLICK: |
|
168 |
switch(e->click.widget) { |
|
169 |
case 2: {/* toggle size */ |
|
170 |
byte mode = (byte)WP(w,def_d).data_1; |
|
888
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
171 |
bool stickied = !!(w->flags4 & WF_STICKY); |
2475 | 172 |
PlayerID player = w->window_number; |
0 | 173 |
DeleteWindow(w); |
1003
5ce43e332bab
(svn r1502) -Fix: [1101889] Crash under windows... stupid typo in player_gui.c ^ should've been &
darkvater
parents:
998
diff
changeset
|
174 |
DoShowPlayerFinances(player, !HASBIT(mode, 0), stickied); |
0 | 175 |
} break; |
176 |
||
888
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
177 |
case 6: /* increase loan */ |
1767
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1739
diff
changeset
|
178 |
DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY)); |
0 | 179 |
break; |
180 |
||
888
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
181 |
case 7: /* repay loan */ |
1767
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1739
diff
changeset
|
182 |
DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN)); |
0 | 183 |
break; |
184 |
} |
|
185 |
break; |
|
186 |
} |
|
187 |
} |
|
188 |
||
189 |
static const WindowDesc _player_finances_desc = { |
|
190 |
-1,-1, 407, 216, |
|
191 |
WC_FINANCES,0, |
|
2064
c889fcc76398
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2055
diff
changeset
|
192 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 193 |
_player_finances_widgets, |
194 |
PlayerFinancesWndProc |
|
195 |
}; |
|
196 |
||
197 |
static const WindowDesc _player_finances_small_desc = { |
|
198 |
-1,-1, 280, 60, |
|
199 |
WC_FINANCES,0, |
|
2064
c889fcc76398
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2055
diff
changeset
|
200 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 201 |
_player_finances_small_widgets, |
202 |
PlayerFinancesWndProc |
|
203 |
}; |
|
204 |
||
205 |
static const WindowDesc _other_player_finances_desc = { |
|
206 |
-1,-1, 407, 204, |
|
207 |
WC_FINANCES,0, |
|
2064
c889fcc76398
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2055
diff
changeset
|
208 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 209 |
_other_player_finances_widgets, |
210 |
PlayerFinancesWndProc |
|
211 |
}; |
|
212 |
||
213 |
static const WindowDesc _other_player_finances_small_desc = { |
|
214 |
-1,-1, 280, 48, |
|
215 |
WC_FINANCES,0, |
|
2064
c889fcc76398
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2055
diff
changeset
|
216 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 217 |
_other_player_finances_small_widgets, |
218 |
PlayerFinancesWndProc |
|
219 |
}; |
|
220 |
||
221 |
static const WindowDesc * const desc_table[2*2] = { |
|
222 |
&_player_finances_desc,&_player_finances_small_desc, |
|
223 |
&_other_player_finances_desc,&_other_player_finances_small_desc, |
|
224 |
}; |
|
225 |
||
2475 | 226 |
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied) |
0 | 227 |
{ |
228 |
Window *w; |
|
229 |
int mode; |
|
230 |
||
2475 | 231 |
mode = (player != _local_player) * 2 + show_small; |
2549 | 232 |
w = AllocateWindowDescFront(desc_table[mode], player); |
233 |
if (w != NULL) { |
|
0 | 234 |
w->caption_color = w->window_number; |
235 |
WP(w,def_d).data_1 = mode; |
|
888
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
236 |
if (show_stickied) { |
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
237 |
w->flags4 |= WF_STICKY; |
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
238 |
} |
0 | 239 |
} |
240 |
} |
|
241 |
||
2475 | 242 |
void ShowPlayerFinances(PlayerID player) |
0 | 243 |
{ |
888
127b65c07558
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
244 |
DoShowPlayerFinances(player, false, false); |
0 | 245 |
} |
246 |
||
247 |
static void SelectPlayerColorWndProc(Window *w, WindowEvent *e) |
|
248 |
{ |
|
249 |
switch(e->event) { |
|
250 |
case WE_PAINT: { |
|
2475 | 251 |
const Player* p; |
0 | 252 |
uint used_colors = 0; |
253 |
int num_free = 16; |
|
254 |
int x,y,pos; |
|
255 |
int i; |
|
256 |
||
257 |
FOR_ALL_PLAYERS(p) { |
|
258 |
if (p->is_active) { |
|
259 |
SETBIT(used_colors, p->player_color); |
|
260 |
num_free--; |
|
261 |
} |
|
262 |
} |
|
263 |
WP(w,def_d).data_1 = used_colors; |
|
264 |
SetVScrollCount(w, num_free); |
|
265 |
DrawWindowWidgets(w); |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
266 |
|
0 | 267 |
x = 2; |
268 |
y = 17; |
|
269 |
pos = w->vscroll.pos; |
|
270 |
||
271 |
for(i=0; i!=16; i++) { |
|
272 |
if (!(used_colors & 1) && --pos < 0 && pos >= -8) { |
|
273 |
DrawString(x + 30, y, STR_00D1_DARK_BLUE + i, 2); |
|
274 |
DrawSprite((i << 16) + 0x3078C1A, x + 14, y + 4); |
|
275 |
y += 14; |
|
276 |
} |
|
277 |
used_colors >>= 1; |
|
278 |
} |
|
279 |
} break; |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
280 |
|
0 | 281 |
case WE_CLICK: |
282 |
if (e->click.widget == 2) { |
|
283 |
int item = (e->click.pt.y - 13) / 14; |
|
284 |
uint used_colors; |
|
285 |
int i; |
|
286 |
||
287 |
if ((uint)item >= 8) |
|
288 |
return; |
|
289 |
item += w->vscroll.pos; |
|
290 |
used_colors = WP(w,def_d).data_1; |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
291 |
|
0 | 292 |
for(i=0; i!=16; i++) { |
293 |
if (!(used_colors & 1) && --item < 0) { |
|
1767
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1739
diff
changeset
|
294 |
DoCommandP(0, 0, i, NULL, CMD_SET_PLAYER_COLOR); |
0 | 295 |
DeleteWindow(w); |
296 |
break; |
|
297 |
} |
|
298 |
used_colors >>= 1; |
|
299 |
} |
|
300 |
} |
|
301 |
break; |
|
302 |
} |
|
303 |
} |
|
304 |
||
305 |
static const Widget _select_player_color_widgets[] = { |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2703
diff
changeset
|
306 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
307 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 149, 0, 13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
888
diff
changeset
|
308 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 137, 14, 127, 0x0, STR_7034_CLICK_ON_SELECTED_NEW_COLOR}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
888
diff
changeset
|
309 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 138, 149, 14, 127, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
150
diff
changeset
|
310 |
{ WIDGETS_END}, |
0 | 311 |
}; |
312 |
||
313 |
static const WindowDesc _select_player_color_desc = { |
|
314 |
-1,-1, 150, 128, |
|
315 |
WC_PLAYER_COLOR,0, |
|
316 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
317 |
_select_player_color_widgets, |
|
318 |
SelectPlayerColorWndProc |
|
319 |
}; |
|
320 |
||
321 |
static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e) |
|
322 |
{ |
|
323 |
switch(e->event) { |
|
324 |
case WE_PAINT: { |
|
325 |
Player *p; |
|
326 |
w->click_state = (w->click_state & ~(1<<5|1<<6)) | ((1<<5) << WP(w,facesel_d).gender); |
|
327 |
DrawWindowWidgets(w); |
|
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1914
diff
changeset
|
328 |
p = GetPlayer(w->window_number); |
0 | 329 |
DrawPlayerFace(WP(w,facesel_d).face, p->player_color, 2, 16); |
330 |
} break; |
|
331 |
||
332 |
case WE_CLICK: |
|
333 |
switch(e->click.widget) { |
|
334 |
case 3: DeleteWindow(w); break; |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
335 |
case 4: /* ok click */ |
1767
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1739
diff
changeset
|
336 |
DoCommandP(0, 0, WP(w,facesel_d).face, NULL, CMD_SET_PLAYER_FACE); |
0 | 337 |
DeleteWindow(w); |
338 |
break; |
|
339 |
case 5: /* male click */ |
|
340 |
case 6: /* female click */ |
|
341 |
WP(w,facesel_d).gender = e->click.widget - 5; |
|
342 |
SetWindowDirty(w); |
|
343 |
break; |
|
344 |
case 7: |
|
2642 | 345 |
WP(w,facesel_d).face = (WP(w,facesel_d).gender << 31) + GB(InteractiveRandom(), 0, 31); |
0 | 346 |
SetWindowDirty(w); |
347 |
break; |
|
348 |
} |
|
349 |
break; |
|
350 |
} |
|
351 |
} |
|
352 |
||
353 |
static const Widget _select_player_face_widgets[] = { |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2703
diff
changeset
|
354 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
355 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 189, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
356 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 189, 14, 136, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
357 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 94, 137, 148, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
358 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 95, 189, 137, 148, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
359 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 95, 187, 25, 36, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
360 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 95, 187, 37, 48, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
361 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 95, 187, 79, 90, STR_7046_NEW_FACE, STR_704B_GENERATE_RANDOM_NEW_FACE}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
150
diff
changeset
|
362 |
{ WIDGETS_END}, |
0 | 363 |
}; |
364 |
||
365 |
static const WindowDesc _select_player_face_desc = { |
|
366 |
-1,-1, 190, 149, |
|
367 |
WC_PLAYER_FACE,0, |
|
368 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
369 |
_select_player_face_widgets, |
|
370 |
SelectPlayerFaceWndProc |
|
371 |
}; |
|
372 |
||
373 |
static const Widget _my_player_company_widgets[] = { |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2703
diff
changeset
|
374 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
375 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
376 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 359, 14, 157, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
377 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 89, 158, 169, STR_7004_NEW_FACE, STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
378 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 90, 179, 158, 169, STR_7005_COLOR_SCHEME, STR_7031_CHANGE_THE_COMPANY_VEHICLE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
379 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 180, 269, 158, 169, STR_7009_PRESIDENT_NAME, STR_7032_CHANGE_THE_PRESIDENT_S}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
380 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 270, 359, 158, 169, STR_7008_COMPANY_NAME, STR_7033_CHANGE_THE_COMPANY_NAME}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
381 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 266, 355, 18, 29, STR_706F_BUILD_HQ, STR_7070_BUILD_COMPANY_HEADQUARTERS}, |
917
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
382 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 355, 32, 43, 0x0, STR_NULL}, |
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
383 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 355, 32, 43, 0x0, STR_NULL}, |
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
384 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 355, 32, 43, 0x0, STR_NULL}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
385 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 266, 355, 138, 149, STR_COMPANY_PASSWORD, STR_COMPANY_PASSWORD_TOOLTIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
150
diff
changeset
|
386 |
{ WIDGETS_END}, |
0 | 387 |
}; |
388 |
||
389 |
static const Widget _other_player_company_widgets[] = { |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2703
diff
changeset
|
390 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
391 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
392 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 359, 14, 157, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
393 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
394 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
395 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
396 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
397 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 266, 355, 18, 29, STR_7072_VIEW_HQ, STR_7070_BUILD_COMPANY_HEADQUARTERS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
398 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
399 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 179, 158, 169, STR_7077_BUY_25_SHARE_IN_COMPANY, STR_7079_BUY_25_SHARE_IN_THIS_COMPANY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
400 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 180, 359, 158, 169, STR_7078_SELL_25_SHARE_IN_COMPANY, STR_707A_SELL_25_SHARE_IN_THIS_COMPANY}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
150
diff
changeset
|
401 |
{ WIDGETS_END}, |
0 | 402 |
}; |
403 |
||
404 |
static const Widget _my_player_company_bh_widgets[] = { |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2703
diff
changeset
|
405 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
406 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
407 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 359, 14, 157, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
408 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 89, 158, 169, STR_7004_NEW_FACE, STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
409 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 90, 179, 158, 169, STR_7005_COLOR_SCHEME, STR_7031_CHANGE_THE_COMPANY_VEHICLE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
410 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 180, 269, 158, 169, STR_7009_PRESIDENT_NAME, STR_7032_CHANGE_THE_PRESIDENT_S}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
411 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 270, 359, 158, 169, STR_7008_COMPANY_NAME, STR_7033_CHANGE_THE_COMPANY_NAME}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
412 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 266, 355, 18, 29, STR_7072_VIEW_HQ, STR_7070_BUILD_COMPANY_HEADQUARTERS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
413 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 266, 355, 32, 43, STR_RELOCATE_HQ, STR_RELOCATE_COMPANY_HEADQUARTERS}, |
917
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
414 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 355, 32, 43, 0x0, STR_NULL}, |
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
415 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 355, 32, 43, 0x0, STR_NULL}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
416 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 266, 355, 138, 149, STR_COMPANY_PASSWORD, STR_COMPANY_PASSWORD_TOOLTIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
150
diff
changeset
|
417 |
{ WIDGETS_END}, |
0 | 418 |
}; |
419 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2246
diff
changeset
|
420 |
static void DrawPlayerVehiclesAmount(PlayerID player) |
0 | 421 |
{ |
422 |
const int x = 110; |
|
423 |
int y = 72; |
|
2630 | 424 |
const Vehicle* v; |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
425 |
uint train = 0; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
426 |
uint road = 0; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
427 |
uint air = 0; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
428 |
uint ship = 0; |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
429 |
|
0 | 430 |
DrawString(x, y, STR_7039_VEHICLES, 0); |
431 |
||
432 |
FOR_ALL_VEHICLES(v) { |
|
433 |
if (v->owner == player) { |
|
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
434 |
switch (v->type) { |
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2642
diff
changeset
|
435 |
case VEH_Train: if (IsFrontEngine(v)) train++; break; |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
436 |
case VEH_Road: road++; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
437 |
case VEH_Aircraft: if (v->subtype <= 2) air++; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
438 |
case VEH_Ship: ship++; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
439 |
default: break; |
0 | 440 |
} |
441 |
} |
|
442 |
} |
|
443 |
||
444 |
if (train+road+air+ship == 0) { |
|
445 |
DrawString(x+70, y, STR_7042_NONE, 0); |
|
446 |
} else { |
|
447 |
if (train != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
448 |
SetDParam(0, train); |
2246
f25de67915ee
(svn r2766) Remove string and make use of the plural feature
tron
parents:
2187
diff
changeset
|
449 |
DrawString(x + 70, y, STR_TRAINS, 0); |
0 | 450 |
y += 10; |
451 |
} |
|
452 |
||
453 |
if (road != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
454 |
SetDParam(0, road); |
2246
f25de67915ee
(svn r2766) Remove string and make use of the plural feature
tron
parents:
2187
diff
changeset
|
455 |
DrawString(x + 70, y, STR_ROAD_VEHICLES, 0); |
0 | 456 |
y += 10; |
457 |
} |
|
458 |
||
459 |
if (air != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
460 |
SetDParam(0, air); |
2246
f25de67915ee
(svn r2766) Remove string and make use of the plural feature
tron
parents:
2187
diff
changeset
|
461 |
DrawString(x + 70, y, STR_AIRCRAFT, 0); |
0 | 462 |
y += 10; |
463 |
} |
|
464 |
||
465 |
if (ship != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
466 |
SetDParam(0, ship); |
2246
f25de67915ee
(svn r2766) Remove string and make use of the plural feature
tron
parents:
2187
diff
changeset
|
467 |
DrawString(x + 70, y, STR_SHIPS, 0); |
0 | 468 |
} |
469 |
} |
|
470 |
} |
|
471 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2246
diff
changeset
|
472 |
int GetAmountOwnedBy(const Player *p, PlayerID owner) |
0 | 473 |
{ |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
474 |
return (p->share_owners[0] == owner) + |
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
475 |
(p->share_owners[1] == owner) + |
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
476 |
(p->share_owners[2] == owner) + |
0 | 477 |
(p->share_owners[3] == owner); |
478 |
} |
|
479 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2246
diff
changeset
|
480 |
static void DrawCompanyOwnerText(const Player *p) |
0 | 481 |
{ |
2475 | 482 |
const Player* p2; |
0 | 483 |
int num = -1; |
484 |
||
485 |
FOR_ALL_PLAYERS(p2) { |
|
2549 | 486 |
uint amt = GetAmountOwnedBy(p, p2->index); |
487 |
if (amt != 0) { |
|
0 | 488 |
num++; |
489 |
||
2549 | 490 |
SetDParam(num * 3 + 0, amt * 25); |
491 |
SetDParam(num * 3 + 1, p2->name_1); |
|
492 |
SetDParam(num * 3 + 2, p2->name_2); |
|
0 | 493 |
|
2549 | 494 |
if (num != 0) break; |
0 | 495 |
} |
496 |
} |
|
497 |
||
2549 | 498 |
if (num >= 0) DrawString(120, 124, STR_707D_OWNED_BY + num, 0); |
0 | 499 |
} |
500 |
||
501 |
static void PlayerCompanyWndProc(Window *w, WindowEvent *e) |
|
502 |
{ |
|
2549 | 503 |
switch (e->event) { |
0 | 504 |
case WE_PAINT: { |
2475 | 505 |
const Player* p = GetPlayer(w->window_number); |
914
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
893
diff
changeset
|
506 |
uint32 dis = 0; |
0 | 507 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
508 |
if (!IsWindowOfPrototype(w, _other_player_company_widgets)) { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
509 |
AssignWidgetToWindow(w, (p->location_of_house != 0) ? _my_player_company_bh_widgets : _my_player_company_widgets); |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
510 |
|
930
524b02923ede
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
511 |
if (!_networking) SETBIT(w->hidden_state, 11); // hide company-password widget |
914
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
893
diff
changeset
|
512 |
} else { |
1811
9012558a2b02
(svn r2315) - Fix: [ 1187613 ] No HQ present for competitor, disable 'View HQ' button, inspired by lucaspiller
Darkvater
parents:
1793
diff
changeset
|
513 |
if (p->location_of_house == 0) SETBIT(dis, 7); |
9012558a2b02
(svn r2315) - Fix: [ 1187613 ] No HQ present for competitor, disable 'View HQ' button, inspired by lucaspiller
Darkvater
parents:
1793
diff
changeset
|
514 |
|
930
524b02923ede
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
515 |
if (_patches.allow_shares) { /* shares are allowed */ |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1786
diff
changeset
|
516 |
/* If all shares are owned by someone (none by nobody), disable buy button */ |
930
524b02923ede
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
517 |
if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) SETBIT(dis, 9); |
524b02923ede
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
518 |
|
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1786
diff
changeset
|
519 |
/* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */ |
930
524b02923ede
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
520 |
if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai) SETBIT(dis, 9); |
524b02923ede
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
521 |
|
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1786
diff
changeset
|
522 |
/* If the player doesn't own any shares, disable sell button */ |
930
524b02923ede
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
523 |
if (GetAmountOwnedBy(p, _local_player) == 0) SETBIT(dis, 10); |
524b02923ede
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
524 |
|
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1786
diff
changeset
|
525 |
/* Spectators cannot do anything of course */ |
930
524b02923ede
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
526 |
if (_local_player == OWNER_SPECTATOR) dis |= (1 << 9) | (1 << 10); |
524b02923ede
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
527 |
} else /* shares are not allowed, disable buy/sell buttons */ |
524b02923ede
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
528 |
dis |= (1 << 9) | (1 << 10); |
773
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
529 |
} |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
530 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
531 |
SetDParam(0, p->name_1); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
532 |
SetDParam(1, p->name_2); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
533 |
SetDParam(2, GetPlayerNameString((byte)w->window_number, 3)); |
0 | 534 |
|
535 |
w->disabled_state = dis; |
|
536 |
DrawWindowWidgets(w); |
|
537 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
538 |
SetDParam(0, p->inaugurated_year + 1920); |
0 | 539 |
DrawString(110, 25, STR_7038_INAUGURATED, 0); |
540 |
||
541 |
DrawPlayerVehiclesAmount(w->window_number); |
|
542 |
||
543 |
DrawString(110,48, STR_7006_COLOR_SCHEME, 0); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
544 |
// Draw company-colour bus (0xC19) |
2187
2a51f8925eeb
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
545 |
DrawSprite(PLAYER_SPRITE_COLOR(p->index) + (0xC19 | PALETTE_MODIFIER_COLOR), 215, 49); |
0 | 546 |
|
547 |
DrawPlayerFace(p->face, p->player_color, 2, 16); |
|
548 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
549 |
SetDParam(0, p->president_name_1); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
550 |
SetDParam(1, p->president_name_2); |
0 | 551 |
DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94); |
552 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
553 |
SetDParam64(0, CalculateCompanyValue(p)); |
0 | 554 |
DrawString(110, 114, STR_7076_COMPANY_VALUE, 0); |
555 |
||
556 |
DrawCompanyOwnerText(p); |
|
557 |
} break; |
|
558 |
||
559 |
case WE_CLICK: |
|
2549 | 560 |
switch (e->click.widget) { |
0 | 561 |
case 3: { /* select face */ |
1007
65b0cbc302cc
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
562 |
Window *wf = AllocateWindowDescFront(&_select_player_face_desc, w->window_number); |
2549 | 563 |
if (wf != NULL) { |
1007
65b0cbc302cc
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
564 |
wf->caption_color = w->window_number; |
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1914
diff
changeset
|
565 |
WP(wf,facesel_d).face = GetPlayer(wf->window_number)->face; |
1007
65b0cbc302cc
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
566 |
WP(wf,facesel_d).gender = 0; |
0 | 567 |
} |
568 |
} break; |
|
569 |
||
570 |
case 4: {/* change color */ |
|
1007
65b0cbc302cc
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
571 |
Window *wf = AllocateWindowDescFront(&_select_player_color_desc,w->window_number); |
2549 | 572 |
if (wf != NULL) { |
1007
65b0cbc302cc
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
573 |
wf->caption_color = wf->window_number; |
65b0cbc302cc
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
574 |
wf->vscroll.cap = 8; |
0 | 575 |
} |
576 |
} break; |
|
577 |
||
578 |
case 5: {/* change president name */ |
|
2549 | 579 |
const Player* p = GetPlayer(w->window_number); |
580 |
WP(w, def_d).byte_1 = 0; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
581 |
SetDParam(0, p->president_name_2); |
0 | 582 |
ShowQueryString(p->president_name_1, STR_700B_PRESIDENT_S_NAME, 31, 94, w->window_class, w->window_number); |
583 |
} break; |
|
584 |
||
585 |
case 6: {/* change company name */ |
|
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1914
diff
changeset
|
586 |
Player *p = GetPlayer(w->window_number); |
0 | 587 |
WP(w,def_d).byte_1 = 1; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
588 |
SetDParam(0, p->name_2); |
0 | 589 |
ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w->window_class, w->window_number); |
590 |
} break; |
|
591 |
||
592 |
case 7: {/* build hq */ |
|
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1914
diff
changeset
|
593 |
TileIndex tile = GetPlayer(w->window_number)->location_of_house; |
0 | 594 |
if (tile == 0) { |
595 |
if ((byte)w->window_number != _local_player) |
|
596 |
return; |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
597 |
SetObjectToPlaceWnd(SPR_CURSOR_HQ, 1, w); |
0 | 598 |
SetTileSelectSize(2, 2); |
599 |
} else { |
|
600 |
ScrollMainWindowToTile(tile); |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
601 |
} |
0 | 602 |
} break; |
603 |
||
147
d0c8100d18cf
(svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents:
16
diff
changeset
|
604 |
case 8: /* relocate HQ */ |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
605 |
SetObjectToPlaceWnd(SPR_CURSOR_HQ, 1, w); |
147
d0c8100d18cf
(svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents:
16
diff
changeset
|
606 |
SetTileSelectSize(2, 2); |
d0c8100d18cf
(svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents:
16
diff
changeset
|
607 |
break; |
917
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
608 |
case 9: /* buy 25% */ |
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
609 |
DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS)); |
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
610 |
break; |
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
611 |
|
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
612 |
case 10: /* sell 25% */ |
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
613 |
DoCommandP(0, w->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN)); |
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
614 |
break; |
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
615 |
case 11: { /* Password protect company */ |
773
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
616 |
#ifdef ENABLE_NETWORK |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
617 |
if (!IsWindowOfPrototype(w, _other_player_company_widgets)) { |
773
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
618 |
WP(w,def_d).byte_1 = 2; |
2055
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
1962
diff
changeset
|
619 |
ShowQueryString(BindCString(_network_player_info[_local_player].password), |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
1962
diff
changeset
|
620 |
STR_SET_COMPANY_PASSWORD, sizeof(_network_player_info[_local_player].password), 250, w->window_class, w->window_number); |
917
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
621 |
} |
773
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
622 |
#endif |
917
f5779d4b6c3a
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
623 |
} break; |
0 | 624 |
} |
625 |
||
626 |
case WE_MOUSELOOP: |
|
627 |
/* redraw the window every now and then */ |
|
628 |
if ((++w->vscroll.pos & 0x1F) == 0) |
|
629 |
SetWindowDirty(w); |
|
630 |
break; |
|
631 |
||
147
d0c8100d18cf
(svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents:
16
diff
changeset
|
632 |
case WE_PLACE_OBJ: { |
2473
bbc4e805214d
(svn r2999) Do not pass if the HQ gets built for the first time or gets relocated as parameter - the command function has to check this anyway
tron
parents:
2436
diff
changeset
|
633 |
if (DoCommandP(e->place.tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS))) |
0 | 634 |
ResetObjectToPlace(); |
635 |
break; |
|
147
d0c8100d18cf
(svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents:
16
diff
changeset
|
636 |
} |
d0c8100d18cf
(svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents:
16
diff
changeset
|
637 |
|
0 | 638 |
|
639 |
case WE_DESTROY: |
|
640 |
DeleteWindowById(WC_PLAYER_COLOR, w->window_number); |
|
641 |
DeleteWindowById(WC_PLAYER_FACE, w->window_number); |
|
642 |
break; |
|
643 |
||
644 |
case WE_ON_EDIT_TEXT: { |
|
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1109
diff
changeset
|
645 |
char *b = e->edittext.str; |
773
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
646 |
|
2549 | 647 |
// empty string is allowed for password |
648 |
if (*b == '\0' && WP(w,def_d).byte_1 != 2) return; |
|
773
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
649 |
|
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1811
diff
changeset
|
650 |
_cmd_text = b; |
773
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
651 |
switch (WP(w,def_d).byte_1) { |
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
652 |
case 0: /* Change president name */ |
1824
2f70ec488dda
(svn r2329) CMD_CHANGE_PRESIDENT_NAME and CMD_CHANGE_COMPANY_NAME don't use p1, so don't send any meaningful value for it when invoking these commands
tron
parents:
1820
diff
changeset
|
653 |
DoCommandP(0, 0, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT)); |
773
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
654 |
break; |
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
655 |
case 1: /* Change company name */ |
1824
2f70ec488dda
(svn r2329) CMD_CHANGE_PRESIDENT_NAME and CMD_CHANGE_COMPANY_NAME don't use p1, so don't send any meaningful value for it when invoking these commands
tron
parents:
1820
diff
changeset
|
656 |
DoCommandP(0, 0, 0, NULL, CMD_CHANGE_COMPANY_NAME | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME)); |
773
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
657 |
break; |
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
658 |
#ifdef ENABLE_NETWORK |
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
659 |
case 2: /* Change company password */ |
2549 | 660 |
if (*b == '\0') *b = '*'; // empty password is a '*' because of console argument |
1739
4f3082735fbc
(svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents:
1363
diff
changeset
|
661 |
NetworkChangeCompanyPassword(1, &b); |
773
0c5d7a4bac3d
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
662 |
#endif |
0 | 663 |
} |
664 |
} break; |
|
665 |
||
666 |
} |
|
667 |
} |
|
668 |
||
669 |
||
670 |
static const WindowDesc _my_player_company_desc = { |
|
2549 | 671 |
-1, -1, 360, 170, |
672 |
WC_COMPANY, 0, |
|
0 | 673 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
674 |
_my_player_company_widgets, |
|
675 |
PlayerCompanyWndProc |
|
676 |
}; |
|
677 |
||
678 |
static const WindowDesc _other_player_company_desc = { |
|
679 |
-1,-1, 360, 170, |
|
680 |
WC_COMPANY,0, |
|
681 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
682 |
_other_player_company_widgets, |
|
683 |
PlayerCompanyWndProc |
|
684 |
}; |
|
685 |
||
2475 | 686 |
void ShowPlayerCompany(PlayerID player) |
0 | 687 |
{ |
2639 | 688 |
Window* w; |
689 |
||
690 |
w = AllocateWindowDescFront(player == _local_player ? &_my_player_company_desc : &_other_player_company_desc, player); |
|
691 |
if (w != NULL) w->caption_color = w->window_number; |
|
0 | 692 |
} |
693 |
||
694 |
||
695 |
||
696 |
static void BuyCompanyWndProc(Window *w, WindowEvent *e) |
|
697 |
{ |
|
698 |
switch(e->event) { |
|
699 |
case WE_PAINT: { |
|
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1914
diff
changeset
|
700 |
Player *p = GetPlayer(w->window_number); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
701 |
SetDParam(0, p->name_1); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
702 |
SetDParam(1, p->name_2); |
0 | 703 |
DrawWindowWidgets(w); |
704 |
||
705 |
DrawPlayerFace(p->face, p->player_color, 2, 16); |
|
706 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
707 |
SetDParam(0, p->name_1); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
708 |
SetDParam(1, p->name_2); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
709 |
SetDParam(2, p->bankrupt_value); |
0 | 710 |
DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238); |
711 |
break; |
|
712 |
} |
|
713 |
||
714 |
case WE_CLICK: |
|
715 |
switch(e->click.widget) { |
|
716 |
case 3: |
|
717 |
DeleteWindow(w); |
|
718 |
break; |
|
719 |
case 4: { |
|
720 |
DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY)); |
|
721 |
break; |
|
722 |
} |
|
723 |
} |
|
724 |
break; |
|
725 |
} |
|
726 |
} |
|
727 |
||
728 |
static const Widget _buy_company_widgets[] = { |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2703
diff
changeset
|
729 |
{ WWT_CLOSEBOX, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
730 |
{ WWT_CAPTION, RESIZE_NONE, 5, 11, 333, 0, 13, STR_00B3_MESSAGE_FROM, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
731 |
{ WWT_IMGBTN, RESIZE_NONE, 5, 0, 333, 14, 136, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
732 |
{ WWT_TEXTBTN, RESIZE_NONE, 5, 148, 207, 117, 128, STR_00C9_NO, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
733 |
{ WWT_TEXTBTN, RESIZE_NONE, 5, 218, 277, 117, 128, STR_00C8_YES, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
150
diff
changeset
|
734 |
{ WIDGETS_END}, |
0 | 735 |
}; |
736 |
||
737 |
static const WindowDesc _buy_company_desc = { |
|
738 |
153,171, 334, 137, |
|
739 |
WC_BUY_COMPANY,0, |
|
740 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
741 |
_buy_company_widgets, |
|
742 |
BuyCompanyWndProc |
|
743 |
}; |
|
744 |
||
745 |
||
746 |
void ShowBuyCompanyDialog(uint player) |
|
747 |
{ |
|
748 |
AllocateWindowDescFront(&_buy_company_desc, player); |
|
749 |
} |
|
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
750 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
751 |
/********** HIGHSCORE and ENDGAME windows */ |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
752 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
753 |
/* Always draw a maximized window and within there the centered background */ |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
754 |
static void SetupHighScoreEndWindow(Window *w, uint *x, uint *y) |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
755 |
{ |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
756 |
uint i; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
757 |
// resize window to "full-screen" |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
758 |
w->width = _screen.width; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
759 |
w->height = _screen.height; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
760 |
w->widget[0].right = w->width - 1; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
761 |
w->widget[0].bottom = w->height - 1; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
762 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
763 |
DrawWindowWidgets(w); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
764 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
765 |
/* Center Highscore/Endscreen background */ |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
766 |
*x = max(0, (_screen.width / 2) - (640 / 2)); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
767 |
*y = max(0, (_screen.height / 2) - (480 / 2)); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
768 |
for (i = 0; i < 10; i++) // the image is split into 10 50px high parts |
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
769 |
DrawSprite(WP(w, highscore_d).background_img + i, *x, *y + (i * 50)); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
770 |
} |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
771 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
772 |
extern StringID EndGameGetPerformanceTitleFromValue(uint value); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
773 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
774 |
/* End game window shown at the end of the game */ |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
775 |
static void EndGameWndProc(Window *w, WindowEvent *e) |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
776 |
{ |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
777 |
switch (e->event) { |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
778 |
case WE_PAINT: { |
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1914
diff
changeset
|
779 |
const Player *p = GetPlayer(_local_player); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
780 |
uint x, y; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
781 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
782 |
SetupHighScoreEndWindow(w, &x, &y); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
783 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
784 |
/* We need to get performance from last year because the image is shown |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
785 |
* at the start of the new year when these things have already been copied */ |
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
786 |
if (WP(w, highscore_d).background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/ |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
787 |
SetDParam(0, p->president_name_1); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
788 |
SetDParam(1, p->president_name_2); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
789 |
SetDParam(2, p->name_1); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
790 |
SetDParam(3, p->name_2); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
791 |
SetDParam(4, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history)); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
792 |
DrawStringMultiCenter(x + (640 / 2), y + 107, STR_021C_OF_ACHIEVES_STATUS, 640); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
793 |
} else { |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
794 |
SetDParam(0, p->name_1); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
795 |
SetDParam(1, p->name_2); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
796 |
SetDParam(2, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history)); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
797 |
DrawStringMultiCenter(x + (640 / 2), y + 157, STR_021B_ACHIEVES_STATUS, 640); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
798 |
} |
1017
608592d4d7a6
(svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents:
1016
diff
changeset
|
799 |
} break; |
1839
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
800 |
case WE_CLICK: /* Close the window (and show the highscore window) */ |
1016
026b2de61647
(svn r1516) -Cheating players do not get their names added to the highscore table/file
darkvater
parents:
1007
diff
changeset
|
801 |
DeleteWindow(w); |
1875
3a1dba8ed6ea
(svn r2381) - Fix: [ 1210610 ] Endgame window on easy difficulty results in infinite loop. Oops. Seperated the window classes of endgame and highscreen.
Darkvater
parents:
1839
diff
changeset
|
802 |
break; |
1839
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
803 |
case WE_DESTROY: /* Show the highscore window when this one is closed */ |
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
804 |
if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause |
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
805 |
ShowHighscoreTable(w->window_number, WP(w, highscore_d).rank); |
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
806 |
break; |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
807 |
} |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
808 |
} |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
809 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
810 |
static void HighScoreWndProc(Window *w, WindowEvent *e) |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
811 |
{ |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
812 |
switch (e->event) { |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
813 |
case WE_PAINT: { |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
814 |
const HighScore *hs = _highscore_table[w->window_number]; |
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
815 |
uint x, y; |
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
816 |
uint8 i; |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
817 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
818 |
SetupHighScoreEndWindow(w, &x, &y); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
819 |
|
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
820 |
SetDParam(0, _patches.ending_date); |
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
821 |
SetDParam(1, w->window_number + STR_6801_EASY); |
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
822 |
DrawStringMultiCenter(x + (640 / 2), y + 62, !_networking ? STR_0211_TOP_COMPANIES_WHO_REACHED : STR_TOP_COMPANIES_NETWORK_GAME, 500); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
823 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
824 |
/* Draw Highscore peepz */ |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
825 |
for (i = 0; i < lengthof(_highscore_table[0]); i++) { |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
826 |
SetDParam(0, i + 1); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
827 |
DrawString(x + 40, y + 140 + (i * 55), STR_0212, 0x10); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
828 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
829 |
if (hs[i].company[0] != '\0') { |
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
830 |
uint16 colour = (WP(w, highscore_d).rank == (int8)i) ? 0x3 : 0x10; // draw new highscore in red |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
831 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
832 |
DoDrawString(hs[i].company, x + 71, y + 140 + (i * 55), colour); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
833 |
SetDParam(0, hs[i].title); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
834 |
SetDParam(1, hs[i].score); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
835 |
DrawString(x + 71, y + 160 + (i * 55), STR_HIGHSCORE_STATS, colour); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
836 |
} |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
837 |
} |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1017
diff
changeset
|
838 |
} break; |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
839 |
|
1839
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
840 |
case WE_CLICK: /* Onclick to close window, and in destroy event handle the rest */ |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
841 |
DeleteWindow(w); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
842 |
break; |
1839
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
843 |
|
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
844 |
case WE_DESTROY: /* Get back all the hidden windows */ |
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
845 |
if (_game_mode != GM_MENU) ShowVitalWindows(); |
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
846 |
|
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
847 |
if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause |
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
848 |
break; |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
849 |
} |
1839
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
850 |
} |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
851 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
852 |
static const Widget _highscore_widgets[] = { |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
853 |
{ WWT_PANEL, RESIZE_NONE, 16, 0, 640, 0, 480, 0x0, STR_NULL}, |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
854 |
{ WIDGETS_END}, |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
855 |
}; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
856 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
857 |
static const WindowDesc _highscore_desc = { |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
858 |
0, 0, 641, 481, |
1875
3a1dba8ed6ea
(svn r2381) - Fix: [ 1210610 ] Endgame window on easy difficulty results in infinite loop. Oops. Seperated the window classes of endgame and highscreen.
Darkvater
parents:
1839
diff
changeset
|
859 |
WC_HIGHSCORE,0, |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
860 |
0, |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
861 |
_highscore_widgets, |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
862 |
HighScoreWndProc |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
863 |
}; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
864 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
865 |
static const WindowDesc _endgame_desc = { |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
866 |
0, 0, 641, 481, |
1875
3a1dba8ed6ea
(svn r2381) - Fix: [ 1210610 ] Endgame window on easy difficulty results in infinite loop. Oops. Seperated the window classes of endgame and highscreen.
Darkvater
parents:
1839
diff
changeset
|
867 |
WC_ENDSCREEN,0, |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
868 |
0, |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
869 |
_highscore_widgets, |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
870 |
EndGameWndProc |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
871 |
}; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
872 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
873 |
/* Show the highscore table for a given difficulty. When called from |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
874 |
* endgame ranking is set to the top5 element that was newly added |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
875 |
* and is thus highlighted */ |
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
876 |
void ShowHighscoreTable(int difficulty, int8 ranking) |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
877 |
{ |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
878 |
Window *w; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
879 |
|
1839
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
880 |
// pause game to show the chart |
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
881 |
if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
882 |
|
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
883 |
/* Close all always on-top windows to get a clean screen */ |
2639 | 884 |
if (_game_mode != GM_MENU) HideVitalWindows(); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
885 |
|
1875
3a1dba8ed6ea
(svn r2381) - Fix: [ 1210610 ] Endgame window on easy difficulty results in infinite loop. Oops. Seperated the window classes of endgame and highscreen.
Darkvater
parents:
1839
diff
changeset
|
886 |
DeleteWindowByClass(WC_HIGHSCORE); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
887 |
w = AllocateWindowDesc(&_highscore_desc); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
888 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
889 |
if (w != NULL) { |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
890 |
MarkWholeScreenDirty(); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
891 |
w->window_number = difficulty; // show highscore chart for difficulty... |
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
892 |
WP(w, highscore_d).background_img = SPR_HIGHSCORE_CHART_BEGIN; // which background to show |
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
893 |
WP(w, highscore_d).rank = ranking; |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
894 |
} |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
895 |
} |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
896 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
897 |
/* Show the endgame victory screen in 2050. Update the new highscore |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
898 |
* if it was high enough */ |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
899 |
void ShowEndGameChart(void) |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
900 |
{ |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
901 |
Window *w; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
902 |
|
1839
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
903 |
/* Dedicated server doesn't need the highscore window */ |
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
904 |
if (_network_dedicated) return; |
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
905 |
/* Pause in single-player to have a look at the highscore at your own leisure */ |
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
906 |
if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
907 |
|
1839
6c0c19719fb2
(svn r2344) - Fix (regression): [ 1197216 ] Error: !invalid string id 0 in GetString. Dedicated server also had the endgame window shown and because now it is properly no-player anymore it crashed.
Darkvater
parents:
1824
diff
changeset
|
908 |
HideVitalWindows(); |
1875
3a1dba8ed6ea
(svn r2381) - Fix: [ 1210610 ] Endgame window on easy difficulty results in infinite loop. Oops. Seperated the window classes of endgame and highscreen.
Darkvater
parents:
1839
diff
changeset
|
909 |
DeleteWindowByClass(WC_ENDSCREEN); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
910 |
w = AllocateWindowDesc(&_endgame_desc); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
911 |
|
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
912 |
if (w != NULL) { |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
913 |
MarkWholeScreenDirty(); |
1077
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
914 |
|
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
915 |
WP(w, highscore_d).background_img = SPR_TYCOON_IMG1_BEGIN; |
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
916 |
|
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
917 |
if (_local_player != OWNER_SPECTATOR) { |
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1914
diff
changeset
|
918 |
const Player *p = GetPlayer(_local_player); |
1077
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
919 |
if (p->old_economy[0].performance_history == SCORE_MAX) |
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
920 |
WP(w, highscore_d).background_img = SPR_TYCOON_IMG2_BEGIN; |
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
921 |
} |
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
922 |
|
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
923 |
/* In a network game show the endscores of the custom difficulty 'network' which is the last one |
1077
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
924 |
* as well as generate a TOP5 of that game, and not an all-time top5. */ |
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
925 |
if (_networking) { |
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
926 |
w->window_number = lengthof(_highscore_table) - 1; |
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
927 |
WP(w, highscore_d).rank = SaveHighScoreValueNetwork(); |
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
928 |
} else { |
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
929 |
// in single player _local player is always valid |
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1914
diff
changeset
|
930 |
const Player *p = GetPlayer(_local_player); |
1077
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
931 |
w->window_number = _opt.diff_level; |
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
932 |
WP(w, highscore_d).rank = SaveHighScoreValue(p); |
3a38f07dddcc
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
933 |
} |
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1077
diff
changeset
|
934 |
} |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
935 |
} |