author | bjarni |
Sat, 22 Jan 2005 23:55:45 +0000 | |
changeset 1099 | ad7522bd5c1c |
parent 1077 | 7da1f53526cd |
child 1109 | ecb98f43ba2c |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
200
diff
changeset
|
3 |
#include "table/strings.h" |
0 | 4 |
#include "window.h" |
5 |
#include "gui.h" |
|
6 |
#include "viewport.h" |
|
7 |
#include "gfx.h" |
|
8 |
#include "player.h" |
|
9 |
#include "command.h" |
|
10 |
#include "vehicle.h" |
|
186
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
11 |
#include "economy.h" |
773
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
12 |
#include "network.h" |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
13 |
|
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
14 |
#ifdef ENABLE_NETWORK |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
15 |
#include "network_data.h" |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
16 |
#include "network_client.h" |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
17 |
#endif |
0 | 18 |
|
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
19 |
static void DoShowPlayerFinances(int player, bool show_small, bool show_stickied); |
0 | 20 |
|
21 |
||
22 |
static void DrawPlayerEconomyStats(Player *p, byte mode) |
|
23 |
{ |
|
24 |
int x,y,i,j,year; |
|
25 |
int64 (*tbl)[13], sum,cost; |
|
26 |
StringID str; |
|
27 |
||
186
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
28 |
if (!(mode & 1)) { // normal sized economics window (mode&1) is minimized status |
0 | 29 |
/* draw categories */ |
30 |
DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, 0); |
|
31 |
for(i=0; i!=13; i++) |
|
32 |
DrawString(2, 27 + i*10, STR_7011_CONSTRUCTION + i, 0); |
|
33 |
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
|
34 |
|
0 | 35 |
/* draw the price columns */ |
36 |
year = _cur_year - 2; |
|
37 |
j = 3; |
|
38 |
x = 215; |
|
39 |
tbl = p->yearly_expenses + 2; |
|
40 |
do { |
|
41 |
if (year >= p->inaugurated_year) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
42 |
SetDParam(0, year + 1920); |
0 | 43 |
DrawStringCenterUnderline(x-17, 15, STR_7010, 0); |
44 |
sum = 0; |
|
45 |
for(i=0; i!=13; i++) { |
|
46 |
/* draw one row in the price column */ |
|
47 |
cost = (*tbl)[i]; |
|
48 |
if (cost != 0) { |
|
49 |
sum += cost; |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
50 |
|
0 | 51 |
str = STR_701E; |
52 |
if (cost < 0) { cost = -cost; str++; } |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
53 |
SetDParam64(0, cost); |
0 | 54 |
DrawStringRightAligned(x, 27+i*10, str, 0); |
55 |
} |
|
56 |
} |
|
57 |
||
58 |
str = STR_701E; |
|
59 |
if (sum < 0) { sum = -sum; str++; } |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
60 |
SetDParam64(0, sum); |
0 | 61 |
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
|
62 |
|
0 | 63 |
GfxFillRect(x - 75, 27 + 10*13, x, 27 + 10*13, 215); |
64 |
x += 95; |
|
65 |
} |
|
66 |
year++; |
|
67 |
tbl--; |
|
68 |
} while (--j != 0); |
|
69 |
||
70 |
y = 171; |
|
186
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
71 |
|
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
72 |
// draw max loan aligned to loan below (y += 10) |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
73 |
SetDParam64(0, (uint64)_economy.max_loan); |
186
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
74 |
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
|
75 |
|
d6fde0ea62f0
(svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents:
176
diff
changeset
|
76 |
} else |
0 | 77 |
y = 15; |
78 |
||
79 |
DrawString(2, y, STR_7026_BANK_BALANCE, 0); |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
80 |
SetDParam64(0, p->money64); |
0 | 81 |
DrawStringRightAligned(182, y, STR_7028, 0); |
82 |
||
83 |
y += 10; |
|
84 |
||
85 |
DrawString(2, y, STR_7027_LOAN, 0); |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
86 |
SetDParam64(0, p->current_loan); |
0 | 87 |
DrawStringRightAligned(182, y, STR_7028, 0); |
88 |
||
89 |
y += 12; |
|
90 |
||
91 |
GfxFillRect(182 - 75, y-2, 182, y-2, 215); |
|
92 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
93 |
SetDParam64(0, p->money64 - p->current_loan); |
0 | 94 |
DrawStringRightAligned(182, y, STR_7028, 0); |
95 |
} |
|
96 |
||
97 |
static const Widget _player_finances_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
98 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
99 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
100 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 380, 394, 0, 13, 0x2AA, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, |
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
101 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
102 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 406, 14, 169, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
103 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 406, 170, 203, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
104 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 202, 204, 215, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
105 |
{ 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
|
106 |
{ WIDGETS_END}, |
0 | 107 |
}; |
108 |
||
109 |
static const Widget _other_player_finances_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
110 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
111 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
112 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 380, 394, 0, 13, 0x2AA, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, |
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
113 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
114 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 406, 14, 169, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
115 |
{ 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
|
116 |
{ WIDGETS_END}, |
0 | 117 |
}; |
118 |
||
119 |
static const Widget _other_player_finances_small_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
120 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
121 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 253, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
122 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 254, 267, 0, 13, 0x2AA, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, |
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
123 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 268, 279, 0, 13, 0x0, STR_STICKY_BUTTON}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
124 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
125 |
{ 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
|
126 |
{ WIDGETS_END}, |
0 | 127 |
}; |
128 |
||
129 |
static const Widget _player_finances_small_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
130 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
131 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 253, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
132 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 254, 267, 0, 13, 0x2AA, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, |
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
133 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 268, 279, 0, 13, 0x0, STR_STICKY_BUTTON}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
134 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
135 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 279, 14, 47, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
136 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 139, 48, 59, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
137 |
{ 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
|
138 |
{ WIDGETS_END}, |
0 | 139 |
}; |
140 |
||
141 |
||
142 |
static void PlayerFinancesWndProc(Window *w, WindowEvent *e) |
|
143 |
{ |
|
144 |
switch(e->event) { |
|
145 |
case WE_PAINT: { |
|
146 |
Player *p = DEREF_PLAYER(w->window_number); |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
147 |
|
893
f4698309dec7
(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
|
148 |
w->disabled_state = p->current_loan != 0 ? 0 : (1 << 7); |
0 | 149 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
150 |
SetDParam(0, p->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
151 |
SetDParam(1, p->name_2); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
152 |
SetDParam(2, GetPlayerNameString((byte)w->window_number, 3)); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
153 |
SetDParam(4, 10000); |
0 | 154 |
DrawWindowWidgets(w); |
155 |
||
156 |
DrawPlayerEconomyStats(p, (byte)WP(w,def_d).data_1); |
|
157 |
} break; |
|
158 |
||
159 |
case WE_CLICK: |
|
160 |
switch(e->click.widget) { |
|
161 |
case 2: {/* toggle size */ |
|
162 |
byte mode = (byte)WP(w,def_d).data_1; |
|
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
163 |
bool stickied = !!(w->flags4 & WF_STICKY); |
0 | 164 |
int player = w->window_number; |
165 |
DeleteWindow(w); |
|
1003
5a1516385ad5
(svn r1502) -Fix: [1101889] Crash under windows... stupid typo in player_gui.c ^ should've been &
darkvater
parents:
998
diff
changeset
|
166 |
DoShowPlayerFinances(player, !HASBIT(mode, 0), stickied); |
0 | 167 |
} break; |
168 |
||
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
169 |
case 6: /* increase loan */ |
0 | 170 |
DoCommandP(0, w->window_number, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY)); |
171 |
break; |
|
172 |
||
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
173 |
case 7: /* repay loan */ |
0 | 174 |
DoCommandP(0, w->window_number, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN)); |
175 |
break; |
|
176 |
} |
|
177 |
break; |
|
178 |
} |
|
179 |
} |
|
180 |
||
181 |
static const WindowDesc _player_finances_desc = { |
|
182 |
-1,-1, 407, 216, |
|
183 |
WC_FINANCES,0, |
|
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
184 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESTORE_DPARAM | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 185 |
_player_finances_widgets, |
186 |
PlayerFinancesWndProc |
|
187 |
}; |
|
188 |
||
189 |
static const WindowDesc _player_finances_small_desc = { |
|
190 |
-1,-1, 280, 60, |
|
191 |
WC_FINANCES,0, |
|
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
192 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESTORE_DPARAM | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 193 |
_player_finances_small_widgets, |
194 |
PlayerFinancesWndProc |
|
195 |
}; |
|
196 |
||
197 |
static const WindowDesc _other_player_finances_desc = { |
|
198 |
-1,-1, 407, 204, |
|
199 |
WC_FINANCES,0, |
|
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
200 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESTORE_DPARAM | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 201 |
_other_player_finances_widgets, |
202 |
PlayerFinancesWndProc |
|
203 |
}; |
|
204 |
||
205 |
static const WindowDesc _other_player_finances_small_desc = { |
|
206 |
-1,-1, 280, 48, |
|
207 |
WC_FINANCES,0, |
|
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
208 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESTORE_DPARAM | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 209 |
_other_player_finances_small_widgets, |
210 |
PlayerFinancesWndProc |
|
211 |
}; |
|
212 |
||
213 |
static const WindowDesc * const desc_table[2*2] = { |
|
214 |
&_player_finances_desc,&_player_finances_small_desc, |
|
215 |
&_other_player_finances_desc,&_other_player_finances_small_desc, |
|
216 |
}; |
|
217 |
||
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
218 |
static void DoShowPlayerFinances(int player, bool show_small, bool show_stickied) |
0 | 219 |
{ |
220 |
Window *w; |
|
221 |
int mode; |
|
222 |
||
790
685dca5cd34d
(svn r1260) -Fix: [1090357] Patch for braindead MinGW compiler (luzi82)
darkvater
parents:
773
diff
changeset
|
223 |
mode = ((byte)player != _local_player)*2 + show_small; |
0 | 224 |
w = AllocateWindowDescFront( desc_table[mode], player); |
225 |
if (w) { |
|
226 |
w->caption_color = w->window_number; |
|
227 |
WP(w,def_d).data_1 = mode; |
|
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
228 |
if (show_stickied) { |
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
229 |
w->flags4 |= WF_STICKY; |
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
230 |
w->click_state ^= (1 << 3); |
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
231 |
} |
0 | 232 |
} |
233 |
} |
|
234 |
||
235 |
void ShowPlayerFinances(int player) |
|
236 |
{ |
|
888
a299cab0927e
(svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents:
867
diff
changeset
|
237 |
DoShowPlayerFinances(player, false, false); |
0 | 238 |
} |
239 |
||
240 |
static void SelectPlayerColorWndProc(Window *w, WindowEvent *e) |
|
241 |
{ |
|
242 |
switch(e->event) { |
|
243 |
case WE_PAINT: { |
|
244 |
Player *p; |
|
245 |
uint used_colors = 0; |
|
246 |
int num_free = 16; |
|
247 |
int x,y,pos; |
|
248 |
int i; |
|
249 |
||
250 |
FOR_ALL_PLAYERS(p) { |
|
251 |
if (p->is_active) { |
|
252 |
SETBIT(used_colors, p->player_color); |
|
253 |
num_free--; |
|
254 |
} |
|
255 |
} |
|
256 |
WP(w,def_d).data_1 = used_colors; |
|
257 |
SetVScrollCount(w, num_free); |
|
258 |
DrawWindowWidgets(w); |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
259 |
|
0 | 260 |
x = 2; |
261 |
y = 17; |
|
262 |
pos = w->vscroll.pos; |
|
263 |
||
264 |
for(i=0; i!=16; i++) { |
|
265 |
if (!(used_colors & 1) && --pos < 0 && pos >= -8) { |
|
266 |
DrawString(x + 30, y, STR_00D1_DARK_BLUE + i, 2); |
|
267 |
DrawSprite((i << 16) + 0x3078C1A, x + 14, y + 4); |
|
268 |
y += 14; |
|
269 |
} |
|
270 |
used_colors >>= 1; |
|
271 |
} |
|
272 |
} break; |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
273 |
|
0 | 274 |
case WE_CLICK: |
275 |
if (e->click.widget == 2) { |
|
276 |
int item = (e->click.pt.y - 13) / 14; |
|
277 |
uint used_colors; |
|
278 |
int i; |
|
279 |
||
280 |
if ((uint)item >= 8) |
|
281 |
return; |
|
282 |
item += w->vscroll.pos; |
|
283 |
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
|
284 |
|
0 | 285 |
for(i=0; i!=16; i++) { |
286 |
if (!(used_colors & 1) && --item < 0) { |
|
287 |
DoCommandP(0, w->window_number, i, NULL, CMD_SET_PLAYER_COLOR); |
|
288 |
DeleteWindow(w); |
|
289 |
break; |
|
290 |
} |
|
291 |
used_colors >>= 1; |
|
292 |
} |
|
293 |
} |
|
294 |
break; |
|
295 |
} |
|
296 |
} |
|
297 |
||
298 |
static const Widget _select_player_color_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
299 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
300 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 149, 0, 13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
893
f4698309dec7
(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
|
301 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 137, 14, 127, 0x0, STR_7034_CLICK_ON_SELECTED_NEW_COLOR}, |
f4698309dec7
(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
|
302 |
{ 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
|
303 |
{ WIDGETS_END}, |
0 | 304 |
}; |
305 |
||
306 |
static const WindowDesc _select_player_color_desc = { |
|
307 |
-1,-1, 150, 128, |
|
308 |
WC_PLAYER_COLOR,0, |
|
309 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
310 |
_select_player_color_widgets, |
|
311 |
SelectPlayerColorWndProc |
|
312 |
}; |
|
313 |
||
314 |
static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e) |
|
315 |
{ |
|
316 |
switch(e->event) { |
|
317 |
case WE_PAINT: { |
|
318 |
Player *p; |
|
319 |
w->click_state = (w->click_state & ~(1<<5|1<<6)) | ((1<<5) << WP(w,facesel_d).gender); |
|
320 |
DrawWindowWidgets(w); |
|
321 |
p = DEREF_PLAYER(w->window_number); |
|
322 |
DrawPlayerFace(WP(w,facesel_d).face, p->player_color, 2, 16); |
|
323 |
} break; |
|
324 |
||
325 |
case WE_CLICK: |
|
326 |
switch(e->click.widget) { |
|
327 |
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
|
328 |
case 4: /* ok click */ |
0 | 329 |
DoCommandP(0, w->window_number, WP(w,facesel_d).face, NULL, CMD_SET_PLAYER_FACE); |
330 |
DeleteWindow(w); |
|
331 |
break; |
|
332 |
case 5: /* male click */ |
|
333 |
case 6: /* female click */ |
|
334 |
WP(w,facesel_d).gender = e->click.widget - 5; |
|
335 |
SetWindowDirty(w); |
|
336 |
break; |
|
337 |
case 7: |
|
338 |
WP(w,facesel_d).face = (InteractiveRandom() & 0x7FFFFFFF) + (WP(w,facesel_d).gender << 31); |
|
339 |
SetWindowDirty(w); |
|
340 |
break; |
|
341 |
} |
|
342 |
break; |
|
343 |
} |
|
344 |
} |
|
345 |
||
346 |
static const Widget _select_player_face_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
347 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
348 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 189, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
349 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 189, 14, 136, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
350 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 94, 137, 148, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
351 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 95, 189, 137, 148, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
352 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 95, 187, 25, 36, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
353 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 95, 187, 37, 48, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
354 |
{ 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
|
355 |
{ WIDGETS_END}, |
0 | 356 |
}; |
357 |
||
358 |
static const WindowDesc _select_player_face_desc = { |
|
359 |
-1,-1, 190, 149, |
|
360 |
WC_PLAYER_FACE,0, |
|
361 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
362 |
_select_player_face_widgets, |
|
363 |
SelectPlayerFaceWndProc |
|
364 |
}; |
|
365 |
||
366 |
static const Widget _my_player_company_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
367 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
368 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
369 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 359, 14, 157, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
370 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 89, 158, 169, STR_7004_NEW_FACE, STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
371 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 90, 179, 158, 169, STR_7005_COLOR_SCHEME, STR_7031_CHANGE_THE_COMPANY_VEHICLE}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
372 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 180, 269, 158, 169, STR_7009_PRESIDENT_NAME, STR_7032_CHANGE_THE_PRESIDENT_S}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
373 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 270, 359, 158, 169, STR_7008_COMPANY_NAME, STR_7033_CHANGE_THE_COMPANY_NAME}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
374 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 266, 355, 18, 29, STR_706F_BUILD_HQ, STR_7070_BUILD_COMPANY_HEADQUARTERS}, |
917
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
375 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 355, 32, 43, 0x0, STR_NULL}, |
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
376 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 355, 32, 43, 0x0, STR_NULL}, |
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
377 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 355, 32, 43, 0x0, STR_NULL}, |
867
dffd33233237
(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, 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
|
379 |
{ WIDGETS_END}, |
0 | 380 |
}; |
381 |
||
382 |
static const Widget _other_player_company_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
383 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
384 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
385 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 359, 14, 157, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
386 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
387 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
388 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
389 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
390 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 266, 355, 18, 29, STR_7072_VIEW_HQ, STR_7070_BUILD_COMPANY_HEADQUARTERS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
391 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
392 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 179, 158, 169, STR_7077_BUY_25_SHARE_IN_COMPANY, STR_7079_BUY_25_SHARE_IN_THIS_COMPANY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
393 |
{ 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
|
394 |
{ WIDGETS_END}, |
0 | 395 |
}; |
396 |
||
397 |
static const Widget _my_player_company_bh_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
398 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
399 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
400 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 359, 14, 157, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
401 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 89, 158, 169, STR_7004_NEW_FACE, STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
402 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 90, 179, 158, 169, STR_7005_COLOR_SCHEME, STR_7031_CHANGE_THE_COMPANY_VEHICLE}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
403 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 180, 269, 158, 169, STR_7009_PRESIDENT_NAME, STR_7032_CHANGE_THE_PRESIDENT_S}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
404 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 270, 359, 158, 169, STR_7008_COMPANY_NAME, STR_7033_CHANGE_THE_COMPANY_NAME}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
405 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 266, 355, 18, 29, STR_7072_VIEW_HQ, STR_7070_BUILD_COMPANY_HEADQUARTERS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
406 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 266, 355, 32, 43, STR_RELOCATE_HQ, STR_RELOCATE_COMPANY_HEADQUARTERS}, |
917
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
407 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 355, 32, 43, 0x0, STR_NULL}, |
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
408 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 355, 32, 43, 0x0, STR_NULL}, |
867
dffd33233237
(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, 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
|
410 |
{ WIDGETS_END}, |
0 | 411 |
}; |
412 |
||
413 |
static void DrawPlayerVehiclesAmount(int player) |
|
414 |
{ |
|
415 |
const int x = 110; |
|
416 |
int y = 72; |
|
417 |
Vehicle *v; |
|
418 |
uint train,road,air,ship; |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
419 |
|
0 | 420 |
DrawString(x, y, STR_7039_VEHICLES, 0); |
421 |
||
422 |
train = road = air = ship = 0; |
|
423 |
||
424 |
FOR_ALL_VEHICLES(v) { |
|
425 |
if (v->owner == player) { |
|
426 |
if (v->type == VEH_Train) { |
|
1067
3ba7987a004e
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
427 |
if (v->subtype == TS_Front_Engine) |
0 | 428 |
train++; |
429 |
} else if (v->type == VEH_Road) { |
|
430 |
road++; |
|
431 |
} else if (v->type == VEH_Aircraft) { |
|
432 |
if (v->subtype <= 2) |
|
433 |
air++; |
|
434 |
} else if (v->type == VEH_Ship) { |
|
435 |
ship++; |
|
436 |
} |
|
437 |
} |
|
438 |
} |
|
439 |
||
440 |
if (train+road+air+ship == 0) { |
|
441 |
DrawString(x+70, y, STR_7042_NONE, 0); |
|
442 |
} else { |
|
443 |
if (train != 0) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
444 |
SetDParam(0, train); |
0 | 445 |
DrawString(x + 70, y, train==1 ? STR_703A_TRAIN : STR_703B_TRAINS, 0); |
446 |
y += 10; |
|
447 |
} |
|
448 |
||
449 |
if (road != 0) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
450 |
SetDParam(0, road); |
0 | 451 |
DrawString(x + 70, y, road==1 ? STR_703C_ROAD_VEHICLE : STR_703D_ROAD_VEHICLES, 0); |
452 |
y += 10; |
|
453 |
} |
|
454 |
||
455 |
if (air != 0) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
456 |
SetDParam(0, air); |
0 | 457 |
DrawString(x + 70, y, air==1 ? STR_703E_AIRCRAFT : STR_703F_AIRCRAFT, 0); |
458 |
y += 10; |
|
459 |
} |
|
460 |
||
461 |
if (ship != 0) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
462 |
SetDParam(0, ship); |
0 | 463 |
DrawString(x + 70, y, ship==1 ? STR_7040_SHIP : STR_7041_SHIPS, 0); |
464 |
} |
|
465 |
} |
|
466 |
} |
|
467 |
||
599
30da691a5561
(svn r1023) -Fix: [Network] [ 1083692 ] You can no longer buy out a company in MP
truelight
parents:
543
diff
changeset
|
468 |
int GetAmountOwnedBy(Player *p, byte owner) |
0 | 469 |
{ |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
470 |
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
|
471 |
(p->share_owners[1] == owner) + |
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
472 |
(p->share_owners[2] == owner) + |
0 | 473 |
(p->share_owners[3] == owner); |
474 |
} |
|
475 |
||
476 |
static void DrawCompanyOwnerText(Player *p) |
|
477 |
{ |
|
478 |
int num = -1; |
|
479 |
Player *p2; |
|
480 |
int amt; |
|
481 |
||
482 |
FOR_ALL_PLAYERS(p2) { |
|
483 |
if ((amt=GetAmountOwnedBy(p, p2->index)) != 0) { |
|
484 |
num++; |
|
485 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
486 |
SetDParam(num*3+0, amt*25); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
487 |
SetDParam(num*3+1, p2->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
488 |
SetDParam(num*3+2, p2->name_2); |
0 | 489 |
|
490 |
if (num != 0) |
|
491 |
break; |
|
492 |
} |
|
493 |
} |
|
494 |
||
495 |
if (num >= 0) |
|
496 |
DrawString(120, 124, STR_707D_OWNED_BY+num, 0); |
|
497 |
} |
|
498 |
||
499 |
static void PlayerCompanyWndProc(Window *w, WindowEvent *e) |
|
500 |
{ |
|
501 |
switch(e->event) { |
|
502 |
case WE_PAINT: { |
|
503 |
Player *p = DEREF_PLAYER(w->window_number); |
|
914
4359607898f7
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
893
diff
changeset
|
504 |
uint32 dis = 0; |
0 | 505 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
506 |
if (!IsWindowOfPrototype(w, _other_player_company_widgets)) { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
507 |
AssignWidgetToWindow(w, (p->location_of_house != 0) ? _my_player_company_bh_widgets : _my_player_company_widgets); |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
508 |
|
930
ab42e283749d
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
509 |
if (!_networking) SETBIT(w->hidden_state, 11); // hide company-password widget |
914
4359607898f7
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
893
diff
changeset
|
510 |
} else { |
930
ab42e283749d
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
511 |
if (_patches.allow_shares) { /* shares are allowed */ |
ab42e283749d
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
512 |
if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) SETBIT(dis, 9); |
ab42e283749d
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
513 |
|
ab42e283749d
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
514 |
/* We cannot buy out real players in a network game */ |
ab42e283749d
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
515 |
if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai) SETBIT(dis, 9); |
ab42e283749d
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
516 |
|
ab42e283749d
(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, _local_player) == 0) SETBIT(dis, 10); |
ab42e283749d
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
518 |
|
ab42e283749d
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
519 |
if (_local_player == OWNER_SPECTATOR) dis |= (1 << 9) | (1 << 10); |
ab42e283749d
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
520 |
} else /* shares are not allowed, disable buy/sell buttons */ |
ab42e283749d
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
917
diff
changeset
|
521 |
dis |= (1 << 9) | (1 << 10); |
773
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
522 |
} |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
523 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
524 |
SetDParam(0, p->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
525 |
SetDParam(1, p->name_2); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
526 |
SetDParam(2, GetPlayerNameString((byte)w->window_number, 3)); |
0 | 527 |
|
528 |
w->disabled_state = dis; |
|
529 |
DrawWindowWidgets(w); |
|
530 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
531 |
SetDParam(0, p->inaugurated_year + 1920); |
0 | 532 |
DrawString(110, 25, STR_7038_INAUGURATED, 0); |
533 |
||
534 |
DrawPlayerVehiclesAmount(w->window_number); |
|
535 |
||
536 |
DrawString(110,48, STR_7006_COLOR_SCHEME, 0); |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
537 |
// Draw company-colour bus (0xC19) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
538 |
DrawSprite(PLAYER_SPRITE_COLOR(p->index) + 0x8C19, 215, 49); |
0 | 539 |
|
540 |
DrawPlayerFace(p->face, p->player_color, 2, 16); |
|
541 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
542 |
SetDParam(0, p->president_name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
543 |
SetDParam(1, p->president_name_2); |
0 | 544 |
DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94); |
545 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
546 |
SetDParam64(0, CalculateCompanyValue(p)); |
0 | 547 |
DrawString(110, 114, STR_7076_COMPANY_VALUE, 0); |
548 |
||
549 |
DrawCompanyOwnerText(p); |
|
550 |
} break; |
|
551 |
||
552 |
case WE_CLICK: |
|
553 |
switch(e->click.widget) { |
|
554 |
case 3: { /* select face */ |
|
1007
cc994e6a9b7e
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
555 |
Window *wf = AllocateWindowDescFront(&_select_player_face_desc, w->window_number); |
cc994e6a9b7e
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
556 |
if (wf) { |
cc994e6a9b7e
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
557 |
wf->caption_color = w->window_number; |
cc994e6a9b7e
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
558 |
WP(wf,facesel_d).face = DEREF_PLAYER(wf->window_number)->face; |
cc994e6a9b7e
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
559 |
WP(wf,facesel_d).gender = 0; |
0 | 560 |
} |
561 |
} break; |
|
562 |
||
563 |
case 4: {/* change color */ |
|
1007
cc994e6a9b7e
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
564 |
Window *wf = AllocateWindowDescFront(&_select_player_color_desc,w->window_number); |
cc994e6a9b7e
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
565 |
if (wf) { |
cc994e6a9b7e
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
566 |
wf->caption_color = wf->window_number; |
cc994e6a9b7e
(svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents:
1003
diff
changeset
|
567 |
wf->vscroll.cap = 8; |
0 | 568 |
} |
569 |
} break; |
|
570 |
||
571 |
case 5: {/* change president name */ |
|
572 |
Player *p = DEREF_PLAYER(w->window_number); |
|
573 |
WP(w,def_d).byte_1 = 0; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
574 |
SetDParam(0, p->president_name_2); |
0 | 575 |
ShowQueryString(p->president_name_1, STR_700B_PRESIDENT_S_NAME, 31, 94, w->window_class, w->window_number); |
576 |
} break; |
|
577 |
||
578 |
case 6: {/* change company name */ |
|
579 |
Player *p = DEREF_PLAYER(w->window_number); |
|
580 |
WP(w,def_d).byte_1 = 1; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
581 |
SetDParam(0, p->name_2); |
0 | 582 |
ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w->window_class, w->window_number); |
583 |
} break; |
|
584 |
||
585 |
case 7: {/* build hq */ |
|
586 |
TileIndex tile = DEREF_PLAYER(w->window_number)->location_of_house; |
|
587 |
if (tile == 0) { |
|
588 |
if ((byte)w->window_number != _local_player) |
|
589 |
return; |
|
590 |
SetObjectToPlaceWnd(0x2D0, 1, w); |
|
591 |
SetTileSelectSize(2, 2); |
|
592 |
} else { |
|
593 |
ScrollMainWindowToTile(tile); |
|
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
186
diff
changeset
|
594 |
} |
0 | 595 |
} break; |
596 |
||
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
|
597 |
case 8: /* relocate HQ */ |
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
|
598 |
SetObjectToPlaceWnd(0x2D0, 1, w); |
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
|
599 |
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
|
600 |
break; |
917
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
601 |
case 9: /* buy 25% */ |
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
602 |
DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS)); |
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
603 |
break; |
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
604 |
|
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
605 |
case 10: /* sell 25% */ |
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
606 |
DoCommandP(0, w->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN)); |
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
607 |
break; |
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
608 |
case 11: { /* Password protect company */ |
773
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
609 |
#ifdef ENABLE_NETWORK |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
610 |
if (!IsWindowOfPrototype(w, _other_player_company_widgets)) { |
773
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
611 |
StringID str; |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
612 |
WP(w,def_d).byte_1 = 2; |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
613 |
str = AllocateName(_network_player_info[_local_player].password, 0); |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
614 |
ShowQueryString(str, STR_SET_COMPANY_PASSWORD, sizeof(_network_player_info[_local_player].password), 250, w->window_class, w->window_number); |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
615 |
DeleteName(str); |
917
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
616 |
} |
773
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
617 |
#endif |
917
f30b62dce860
(svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents:
914
diff
changeset
|
618 |
} break; |
0 | 619 |
} |
620 |
||
621 |
case WE_MOUSELOOP: |
|
622 |
/* redraw the window every now and then */ |
|
623 |
if ((++w->vscroll.pos & 0x1F) == 0) |
|
624 |
SetWindowDirty(w); |
|
625 |
break; |
|
626 |
||
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
|
627 |
case WE_PLACE_OBJ: { |
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
|
628 |
// you cannot destroy a HQ, only relocate it. So build_HQ is called, just with different flags |
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
|
629 |
TileIndex tile = DEREF_PLAYER(w->window_number)->location_of_house; |
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
|
630 |
if (DoCommandP(e->place.tile, (tile == 0) ? 0 : (1 << 16) | w->window_number, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS))) |
0 | 631 |
ResetObjectToPlace(); |
632 |
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
|
633 |
} |
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
|
634 |
|
0 | 635 |
|
636 |
case WE_DESTROY: |
|
637 |
DeleteWindowById(WC_PLAYER_COLOR, w->window_number); |
|
638 |
DeleteWindowById(WC_PLAYER_FACE, w->window_number); |
|
639 |
break; |
|
640 |
||
641 |
case WE_ON_EDIT_TEXT: { |
|
773
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
642 |
char *b = (char*)e->edittext.str; |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
643 |
|
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
644 |
if (*b == 0 && WP(w,def_d).byte_1 != 2) // empty string is allowed for password |
0 | 645 |
return; |
773
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
646 |
|
0 | 647 |
memcpy(_decode_parameters, b, 32); |
773
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
648 |
switch (WP(w,def_d).byte_1) { |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
649 |
case 0: /* Change president name */ |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
650 |
DoCommandP(0, w->window_number, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT)); |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
651 |
break; |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
652 |
case 1: /* Change company name */ |
0 | 653 |
DoCommandP(0, w->window_number, 0, NULL, CMD_CHANGE_COMPANY_NAME | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME)); |
773
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
654 |
break; |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
655 |
#ifdef ENABLE_NETWORK |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
656 |
case 2: /* Change company password */ |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
657 |
if (*b == 0) *b = '*'; // empty password is a '*' because of console argument |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
658 |
NetworkChangeCompanyPassword(b); |
a376cebd3dc0
(svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents:
669
diff
changeset
|
659 |
#endif |
0 | 660 |
} |
661 |
} break; |
|
662 |
||
663 |
} |
|
664 |
} |
|
665 |
||
666 |
||
667 |
static const WindowDesc _my_player_company_desc = { |
|
668 |
-1,-1, 360, 170, |
|
669 |
WC_COMPANY,0, |
|
670 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
671 |
_my_player_company_widgets, |
|
672 |
PlayerCompanyWndProc |
|
673 |
}; |
|
674 |
||
675 |
static const WindowDesc _other_player_company_desc = { |
|
676 |
-1,-1, 360, 170, |
|
677 |
WC_COMPANY,0, |
|
678 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
679 |
_other_player_company_widgets, |
|
680 |
PlayerCompanyWndProc |
|
681 |
}; |
|
682 |
||
683 |
void ShowPlayerCompany(int player) |
|
684 |
{ |
|
685 |
Window *w; |
|
686 |
w = AllocateWindowDescFront((byte)player == _local_player ? &_my_player_company_desc : &_other_player_company_desc, player); |
|
687 |
if (w) |
|
688 |
w->caption_color = w->window_number; |
|
689 |
} |
|
690 |
||
691 |
||
692 |
||
693 |
static void BuyCompanyWndProc(Window *w, WindowEvent *e) |
|
694 |
{ |
|
695 |
switch(e->event) { |
|
696 |
case WE_PAINT: { |
|
697 |
Player *p = DEREF_PLAYER(w->window_number); |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
698 |
SetDParam(0, p->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
699 |
SetDParam(1, p->name_2); |
0 | 700 |
DrawWindowWidgets(w); |
701 |
||
702 |
DrawPlayerFace(p->face, p->player_color, 2, 16); |
|
703 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
704 |
SetDParam(0, p->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
705 |
SetDParam(1, p->name_2); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
706 |
SetDParam(2, p->bankrupt_value); |
0 | 707 |
DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238); |
708 |
break; |
|
709 |
} |
|
710 |
||
711 |
case WE_CLICK: |
|
712 |
switch(e->click.widget) { |
|
713 |
case 3: |
|
714 |
DeleteWindow(w); |
|
715 |
break; |
|
716 |
case 4: { |
|
717 |
DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY)); |
|
718 |
break; |
|
719 |
} |
|
720 |
} |
|
721 |
break; |
|
722 |
} |
|
723 |
} |
|
724 |
||
725 |
static const Widget _buy_company_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
726 |
{ WWT_TEXTBTN, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
727 |
{ WWT_CAPTION, RESIZE_NONE, 5, 11, 333, 0, 13, STR_00B3_MESSAGE_FROM, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
728 |
{ WWT_IMGBTN, RESIZE_NONE, 5, 0, 333, 14, 136, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
729 |
{ WWT_TEXTBTN, RESIZE_NONE, 5, 148, 207, 117, 128, STR_00C9_NO, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
790
diff
changeset
|
730 |
{ 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
|
731 |
{ WIDGETS_END}, |
0 | 732 |
}; |
733 |
||
734 |
static const WindowDesc _buy_company_desc = { |
|
735 |
153,171, 334, 137, |
|
736 |
WC_BUY_COMPANY,0, |
|
737 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
738 |
_buy_company_widgets, |
|
739 |
BuyCompanyWndProc |
|
740 |
}; |
|
741 |
||
742 |
||
743 |
void ShowBuyCompanyDialog(uint player) |
|
744 |
{ |
|
745 |
AllocateWindowDescFront(&_buy_company_desc, player); |
|
746 |
} |
|
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
747 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
748 |
/********** HIGHSCORE and ENDGAME windows */ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
749 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
750 |
/* Always draw a maximized window and within there the centered background */ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
751 |
static void SetupHighScoreEndWindow(Window *w, uint *x, uint *y) |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
752 |
{ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
753 |
uint i; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
754 |
// resize window to "full-screen" |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
755 |
w->width = _screen.width; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
756 |
w->height = _screen.height; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
757 |
w->widget[0].right = w->width - 1; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
758 |
w->widget[0].bottom = w->height - 1; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
759 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
760 |
DrawWindowWidgets(w); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
761 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
762 |
/* Center Highscore/Endscreen background */ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
763 |
*x = max(0, (_screen.width / 2) - (640 / 2)); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
764 |
*y = max(0, (_screen.height / 2) - (480 / 2)); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
765 |
for (i = 0; i < 10; i++) // the image is split into 10 50px high parts |
998
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
766 |
DrawSprite(WP(w, highscore_d).background_img + i, *x, *y + (i * 50)); |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
767 |
} |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
768 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
769 |
extern StringID EndGameGetPerformanceTitleFromValue(uint value); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
770 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
771 |
/* End game window shown at the end of the game */ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
772 |
static void EndGameWndProc(Window *w, WindowEvent *e) |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
773 |
{ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
774 |
switch (e->event) { |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
775 |
case WE_PAINT: { |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
776 |
const Player *p = DEREF_PLAYER(_local_player); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
777 |
uint x, y; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
778 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
779 |
SetupHighScoreEndWindow(w, &x, &y); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
780 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
781 |
/* We need to get performance from last year because the image is shown |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
782 |
* at the start of the new year when these things have already been copied */ |
998
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
783 |
if (WP(w, highscore_d).background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/ |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
784 |
SetDParam(0, p->president_name_1); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
785 |
SetDParam(1, p->president_name_2); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
786 |
SetDParam(2, p->name_1); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
787 |
SetDParam(3, p->name_2); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
788 |
SetDParam(4, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history)); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
789 |
DrawStringMultiCenter(x + (640 / 2), y + 107, STR_021C_OF_ACHIEVES_STATUS, 640); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
790 |
} else { |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
791 |
SetDParam(0, p->name_1); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
792 |
SetDParam(1, p->name_2); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
793 |
SetDParam(2, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history)); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
794 |
DrawStringMultiCenter(x + (640 / 2), y + 157, STR_021B_ACHIEVES_STATUS, 640); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
795 |
} |
1017
b09bae77a850
(svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents:
1016
diff
changeset
|
796 |
} break; |
b09bae77a850
(svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents:
1016
diff
changeset
|
797 |
case WE_CLICK: { /* OnClick show the highscore chart */ |
b09bae77a850
(svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents:
1016
diff
changeset
|
798 |
int diff = w->window_number; // save values because deletewindow is called |
b09bae77a850
(svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents:
1016
diff
changeset
|
799 |
int8 rank = WP(w, highscore_d).rank; |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
800 |
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); |
1016
75b12fe9c4e1
(svn r1516) -Cheating players do not get their names added to the highscore table/file
darkvater
parents:
1007
diff
changeset
|
801 |
DeleteWindow(w); |
1017
b09bae77a850
(svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents:
1016
diff
changeset
|
802 |
|
b09bae77a850
(svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents:
1016
diff
changeset
|
803 |
ShowHighscoreTable(diff, rank); |
b09bae77a850
(svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents:
1016
diff
changeset
|
804 |
} break; |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
805 |
} |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
806 |
} |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
807 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
808 |
static void HighScoreWndProc(Window *w, WindowEvent *e) |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
809 |
{ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
810 |
switch (e->event) { |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
811 |
case WE_PAINT: { |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
812 |
const HighScore *hs = _highscore_table[w->window_number]; |
998
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
813 |
uint x, y; |
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
814 |
uint8 i; |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
815 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
816 |
SetupHighScoreEndWindow(w, &x, &y); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
817 |
|
998
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
818 |
SetDParam(0, _patches.ending_date); |
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
819 |
SetDParam(1, w->window_number + STR_6801_EASY); |
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
820 |
DrawStringMultiCenter(x + (640 / 2), y + 62, !_networking ? STR_0211_TOP_COMPANIES_WHO_REACHED : STR_TOP_COMPANIES_NETWORK_GAME, 500); |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
821 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
822 |
/* Draw Highscore peepz */ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
823 |
for (i = 0; i < lengthof(_highscore_table[0]); i++) { |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
824 |
SetDParam(0, i + 1); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
825 |
DrawString(x + 40, y + 140 + (i * 55), STR_0212, 0x10); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
826 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
827 |
if (hs[i].company[0] != '\0') { |
998
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
828 |
uint16 colour = (WP(w, highscore_d).rank == (int8)i) ? 0x3 : 0x10; // draw new highscore in red |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
829 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
830 |
DoDrawString(hs[i].company, x + 71, y + 140 + (i * 55), colour); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
831 |
SetDParam(0, hs[i].title); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
832 |
SetDParam(1, hs[i].score); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
833 |
DrawString(x + 71, y + 160 + (i * 55), STR_HIGHSCORE_STATS, colour); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
834 |
} |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
835 |
} |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1017
diff
changeset
|
836 |
} break; |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
837 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
838 |
case WE_CLICK: /* Onclick get back all hidden windows */ |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1017
diff
changeset
|
839 |
if (_game_mode != GM_MENU && !_networking) |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
840 |
ShowVitalWindows(); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
841 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
842 |
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
843 |
DeleteWindow(w); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
844 |
break; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
845 |
} |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
846 |
} |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
847 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
848 |
static const Widget _highscore_widgets[] = { |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
849 |
{ WWT_PANEL, RESIZE_NONE, 16, 0, 640, 0, 480, 0x0, STR_NULL}, |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
850 |
{ WIDGETS_END}, |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
851 |
}; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
852 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
853 |
static const WindowDesc _highscore_desc = { |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
854 |
0, 0, 641, 481, |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
855 |
WC_HIGHSCORE_ENDSCREEN,0, |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
856 |
0, |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
857 |
_highscore_widgets, |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
858 |
HighScoreWndProc |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
859 |
}; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
860 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
861 |
static const WindowDesc _endgame_desc = { |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
862 |
0, 0, 641, 481, |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
863 |
WC_HIGHSCORE_ENDSCREEN,0, |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
864 |
0, |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
865 |
_highscore_widgets, |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
866 |
EndGameWndProc |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
867 |
}; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
868 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
869 |
/* Show the highscore table for a given difficulty. When called from |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
870 |
* endgame ranking is set to the top5 element that was newly added |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
871 |
* and is thus highlighted */ |
998
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
872 |
void ShowHighscoreTable(int difficulty, int8 ranking) |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
873 |
{ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
874 |
Window *w; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
875 |
|
998
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
876 |
if (!_networking) { // pause game to show chart |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
877 |
DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
998
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
878 |
/* Close all always on-top windows to get a clean screen */ |
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
879 |
if (_game_mode != GM_MENU) |
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
880 |
HideVitalWindows(); |
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
881 |
} |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
882 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
883 |
DeleteWindowById(WC_HIGHSCORE_ENDSCREEN, 0); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
884 |
w = AllocateWindowDesc(&_highscore_desc); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
885 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
886 |
if (w != NULL) { |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
887 |
MarkWholeScreenDirty(); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
888 |
w->window_number = difficulty; // show highscore chart for difficulty... |
998
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
889 |
WP(w, highscore_d).background_img = SPR_HIGHSCORE_CHART_BEGIN; // which background to show |
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
890 |
WP(w, highscore_d).rank = ranking; |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
891 |
} |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
892 |
} |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
893 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
894 |
/* Show the endgame victory screen in 2050. Update the new highscore |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
895 |
* if it was high enough */ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
896 |
void ShowEndGameChart(void) |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
897 |
{ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
898 |
Window *w; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
899 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
900 |
if (!_networking) { // pause the game and hide all windows to show end-chart |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
901 |
DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
902 |
HideVitalWindows(); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
903 |
} |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
904 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
905 |
DeleteWindowById(WC_HIGHSCORE_ENDSCREEN, 0); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
906 |
w = AllocateWindowDesc(&_endgame_desc); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
907 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
908 |
if (w != NULL) { |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
909 |
MarkWholeScreenDirty(); |
1077
7da1f53526cd
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
910 |
|
7da1f53526cd
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
911 |
WP(w, highscore_d).background_img = SPR_TYCOON_IMG1_BEGIN; |
7da1f53526cd
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
912 |
|
7da1f53526cd
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
913 |
if (_local_player != OWNER_SPECTATOR) { |
7da1f53526cd
(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 |
const Player *p = DEREF_PLAYER(_local_player); |
7da1f53526cd
(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 |
if (p->old_economy[0].performance_history == SCORE_MAX) |
7da1f53526cd
(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 |
WP(w, highscore_d).background_img = SPR_TYCOON_IMG2_BEGIN; |
7da1f53526cd
(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 |
} |
7da1f53526cd
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
918 |
|
998
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
919 |
/* In a network game show the endscores of the custom difficulty 'network' which is the last one |
1077
7da1f53526cd
(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 |
* as well as generate a TOP5 of that game, and not an all-time top5. */ |
7da1f53526cd
(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 |
if (_networking) { |
7da1f53526cd
(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 |
w->window_number = lengthof(_highscore_table) - 1; |
7da1f53526cd
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
923 |
WP(w, highscore_d).rank = SaveHighScoreValueNetwork(); |
7da1f53526cd
(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 |
} else { |
7da1f53526cd
(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 |
// in single player _local player is always valid |
7da1f53526cd
(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 |
const Player *p = DEREF_PLAYER(_local_player); |
7da1f53526cd
(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 |
w->window_number = _opt.diff_level; |
7da1f53526cd
(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 |
WP(w, highscore_d).rank = SaveHighScoreValue(p); |
7da1f53526cd
(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 |
} |
7da1f53526cd
(svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents:
1067
diff
changeset
|
930 |
} |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
930
diff
changeset
|
931 |
} |