author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 1390 | e7cdf3ce0fb6 |
child 1648 | 41c3d5de9994 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
1317
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
1309
diff
changeset
|
3 |
#include "string.h" |
1309
4403a69da4f8
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1304
diff
changeset
|
4 |
#include "strings.h" |
1363
775a7ee52369
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1344
diff
changeset
|
5 |
#include "table/sprites.h" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
6 |
#include "network.h" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
7 |
#include "saveload.h" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
8 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
9 |
#include "hal.h" // for file list |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
10 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
11 |
#ifdef ENABLE_NETWORK |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
12 |
|
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
228
diff
changeset
|
13 |
#include "table/strings.h" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
14 |
#include "network_data.h" |
738
b96ab9e63d22
(svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents:
735
diff
changeset
|
15 |
#include "network_gamelist.h" |
0 | 16 |
#include "window.h" |
17 |
#include "gui.h" |
|
18 |
#include "gfx.h" |
|
19 |
#include "command.h" |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
20 |
#include "functions.h" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
21 |
#include "variables.h" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
22 |
#include "network_server.h" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
23 |
#include "network_udp.h" |
0 | 24 |
|
25 |
#define BGC 5 |
|
26 |
#define BTC 15 |
|
27 |
#define MAX_QUERYSTR_LEN 64 |
|
1323
bac2e38e8b60
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1317
diff
changeset
|
28 |
static char _edit_str_buf[MAX_QUERYSTR_LEN*2]; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
29 |
static void ShowNetworkStartServerWindow(void); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
30 |
static void ShowNetworkLobbyWindow(void); |
0 | 31 |
|
32 |
static byte _selected_field; |
|
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
33 |
static bool _first_time_show_network_game_window = true; |
0 | 34 |
|
35 |
static const StringID _connection_types_dropdown[] = { |
|
675
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
36 |
STR_NETWORK_LAN_INTERNET, |
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
37 |
STR_NETWORK_INTERNET_ADVERTISE, |
0 | 38 |
INVALID_STRING_ID |
39 |
}; |
|
40 |
||
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
41 |
static const StringID _lan_internet_types_dropdown[] = { |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
42 |
STR_NETWORK_LAN, |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
43 |
STR_NETWORK_INTERNET, |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
44 |
INVALID_STRING_ID |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
45 |
}; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
46 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
47 |
static StringID _str_map_name, _str_game_name, _str_server_version, _str_server_address; |
172
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
48 |
|
211 | 49 |
enum { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
50 |
NET_PRC__OFFSET_TOP_WIDGET = 74, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
51 |
NET_PRC__OFFSET_TOP_WIDGET_COMPANY = 42, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
52 |
NET_PRC__SIZE_OF_ROW = 14, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
53 |
NET_PRC__SIZE_OF_ROW_COMPANY = 12, |
211 | 54 |
}; |
55 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
56 |
static NetworkGameList *_selected_item = NULL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
57 |
static int8 _selected_company_item = -1; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
58 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
59 |
// Truncates a string to max_width (via GetStringWidth) and adds 3 dots |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
60 |
// at the end of the name. |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
61 |
static void NetworkTruncateString(char *name, const int max_width) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
62 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
63 |
char temp[NETWORK_NAME_LENGTH]; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
64 |
char internal_name[NETWORK_NAME_LENGTH]; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
65 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
66 |
ttd_strlcpy(internal_name, name, sizeof(internal_name)); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
67 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
68 |
if (GetStringWidth(internal_name) > max_width) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
69 |
// Servername is too long, trunc it! |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
70 |
snprintf(temp, sizeof(temp), "%s...", internal_name); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
71 |
// Continue to delete 1 char of the string till it is in range |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
72 |
while (GetStringWidth(temp) > max_width) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
73 |
internal_name[strlen(internal_name) - 1] = '\0'; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
74 |
snprintf(temp, sizeof(temp), "%s...", internal_name); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
75 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
76 |
ttd_strlcpy(name, temp, sizeof(temp)); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
77 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
78 |
} |
211 | 79 |
|
659
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
80 |
extern const char _openttd_revision[]; |
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
81 |
|
897
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
82 |
static FiosItem *selected_map = NULL; // to highlight slected map |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
83 |
|
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
84 |
// called when a new server is found on the network |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
85 |
void UpdateNetworkGameWindow(bool unselect) |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
86 |
{ |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
87 |
Window *w; |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
88 |
w = FindWindowById(WC_NETWORK_WINDOW, 0); |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
89 |
if (w != NULL) { |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
90 |
if (unselect) |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
91 |
_selected_item = NULL; |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
92 |
w->vscroll.count = _network_game_count; |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
93 |
SetWindowDirty(w); |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
94 |
} |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
95 |
} |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
96 |
|
0 | 97 |
static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) |
98 |
{ |
|
99 |
switch(e->event) { |
|
100 |
case WE_PAINT: { |
|
659
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
101 |
w->disabled_state = 0; |
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
102 |
|
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
103 |
if (_selected_item == NULL) { |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
104 |
SETBIT(w->disabled_state, 17); SETBIT(w->disabled_state, 18); |
659
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
105 |
} else if (!_selected_item->online) { |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
106 |
SETBIT(w->disabled_state, 17); // Server offline, join button disabled |
659
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
107 |
} else if (_selected_item->info.clients_on == _selected_item->info.clients_max) { |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
108 |
SETBIT(w->disabled_state, 17); // Server full, join button disabled |
659
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
109 |
|
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
110 |
// revisions don't match, check if server has no revision; then allow connection |
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
111 |
} else if (strncmp(_selected_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) { |
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
112 |
if (strncmp(_selected_item->info.server_revision, NOREV_STRING, sizeof(_selected_item->info.server_revision)) != 0) |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
113 |
SETBIT(w->disabled_state, 17); // Revision mismatch, join button disabled |
622
19e529637d18
(svn r1052) -Fix: [Network] You can't join a server when revision mismatches.
truelight
parents:
621
diff
changeset
|
114 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
115 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
116 |
SetDParam(0, 0x00); |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
117 |
SetDParam(7, _lan_internet_types_dropdown[_network_lan_internet]); |
0 | 118 |
DrawWindowWidgets(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
119 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
120 |
DrawEditBox(w, 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
121 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
122 |
DrawString(9, 23, STR_NETWORK_PLAYER_NAME, 2); |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
123 |
DrawString(9, 43, STR_NETWORK_CONNECTION, 2); |
0 | 124 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
125 |
DrawString(15, 63, STR_NETWORK_GAME_NAME, 2); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
126 |
DrawString(135, 63, STR_NETWORK_CLIENTS_CAPTION, 2); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
127 |
|
211 | 128 |
{ // draw list of games |
129 |
uint16 y = NET_PRC__OFFSET_TOP_WIDGET + 3; |
|
130 |
int32 n = 0; |
|
809
e275914bfd14
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
131 |
int32 pos = w->vscroll.pos; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
132 |
char servername[NETWORK_NAME_LENGTH]; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
133 |
const NetworkGameList *cur_item = _network_game_list; |
809
e275914bfd14
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
134 |
|
e275914bfd14
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
135 |
while (pos > 0 && cur_item != NULL) { |
e275914bfd14
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
136 |
pos--; |
808
ae0f50883ac0
(svn r1279) Fixed the scrollbar in the network gui(server list). It now updates when scrolling (HackyKid)
bjarni
parents:
793
diff
changeset
|
137 |
cur_item = cur_item->next; |
ae0f50883ac0
(svn r1279) Fixed the scrollbar in the network gui(server list). It now updates when scrolling (HackyKid)
bjarni
parents:
793
diff
changeset
|
138 |
} |
809
e275914bfd14
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
139 |
|
211 | 140 |
while (cur_item != NULL) { |
624
f834e073c2dc
(svn r1054) -Fix: [Network] Redid revision 1024, only a bit more nice this time
truelight
parents:
622
diff
changeset
|
141 |
bool compatible = (strncmp(cur_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) == 0); |
659
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
142 |
if (strncmp(cur_item->info.server_revision, NOREV_STRING, sizeof(cur_item->info.server_revision)) == 0) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
143 |
compatible = true; |
211 | 144 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
145 |
if (cur_item == _selected_item) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
146 |
GfxFillRect(11, y - 2, 218, y + 9, 10); // show highlighted item with a different colour |
211 | 147 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
148 |
snprintf(servername, sizeof(servername), "%s", cur_item->info.server_name); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
149 |
NetworkTruncateString(servername, 110); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
150 |
DoDrawString(servername, 15, y, 16); // server name |
211 | 151 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
152 |
SetDParam(0, cur_item->info.clients_on); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
153 |
SetDParam(1, cur_item->info.clients_max); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
154 |
DrawString(135, y, STR_NETWORK_CLIENTS_ONLINE, 2); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
155 |
|
579
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
156 |
// only draw icons if the server is online |
591
b4c4386318e5
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
157 |
if (cur_item->online) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
158 |
|
579
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
159 |
// draw a lock if the server is password protected. |
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
160 |
if(cur_item->info.use_password) |
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
161 |
DrawSprite(SPR_LOCK, 186, y-1); |
591
b4c4386318e5
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
162 |
|
579
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
163 |
// draw red or green icon, depending on compatibility with server. |
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
164 |
DrawSprite(SPR_BLOT | (compatible?0x30d8000:0x30b8000), 195, y); |
591
b4c4386318e5
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
165 |
|
579
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
166 |
// draw flag according to server language |
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
167 |
DrawSprite(SPR_FLAGS_BASE + cur_item->info.server_lang, 206, y); |
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
168 |
} |
591
b4c4386318e5
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
169 |
|
b4c4386318e5
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
170 |
cur_item = cur_item->next; |
b4c4386318e5
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
171 |
y += NET_PRC__SIZE_OF_ROW; |
b4c4386318e5
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
172 |
if (++n == w->vscroll.cap) { break;} // max number of games in the window |
211 | 173 |
} |
174 |
} |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
175 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
176 |
// right menu |
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
177 |
GfxFillRect(252, 23, 478, 65, 157); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
178 |
if (_selected_item == NULL) { |
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
179 |
DrawStringMultiCenter(365, 40, STR_NETWORK_GAME_INFO, 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
180 |
} else if (!_selected_item->online) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
181 |
SetDParam(0, _str_game_name); |
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
182 |
DrawStringMultiCenter(365, 42, STR_ORANGE, 2); // game name |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
183 |
|
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
184 |
DrawStringMultiCenter(365, 110, STR_NETWORK_SERVER_OFFLINE, 2); // server offline |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
185 |
} else { // show game info |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
186 |
uint16 y = 70; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
187 |
|
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
188 |
DrawStringMultiCenter(365, 30, STR_NETWORK_GAME_INFO, 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
189 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
190 |
SetDParam(0, _str_game_name); |
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
191 |
DrawStringMultiCenter(365, 42, STR_ORANGE, 2); // game name |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
192 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
193 |
SetDParam(0, _str_map_name); |
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
194 |
DrawStringMultiCenter(365, 54, STR_02BD, 2); // map name |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
195 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
196 |
SetDParam(0, _selected_item->info.clients_on); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
197 |
SetDParam(1, _selected_item->info.clients_max); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
198 |
DrawString(260, y, STR_NETWORK_CLIENTS, 2); // clients on the server / maximum slots |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
199 |
y+=10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
200 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
201 |
SetDParam(0, STR_NETWORK_LANG_ANY+_selected_item->info.server_lang); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
202 |
DrawString(260, y, STR_NETWORK_LANGUAGE, 2); // server language |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
203 |
y+=10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
204 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
205 |
SetDParam(0, STR_TEMPERATE_LANDSCAPE+_selected_item->info.map_set); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
206 |
DrawString(260, y, STR_NETWORK_TILESET, 2); // tileset |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
207 |
y+=10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
208 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
209 |
SetDParam(0, _selected_item->info.map_width); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
210 |
SetDParam(1, _selected_item->info.map_height); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
211 |
DrawString(260, y, STR_NETWORK_MAP_SIZE, 2); // map size |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
212 |
y+=10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
213 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
214 |
SetDParam(0, _str_server_version); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
215 |
DrawString(260, y, STR_NETWORK_SERVER_VERSION, 2); // server version |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
216 |
y+=10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
217 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
218 |
SetDParam(0, _str_server_address); |
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
219 |
SetDParam(1, _selected_item->port); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
220 |
DrawString(260, y, STR_NETWORK_SERVER_ADDRESS, 2); // server address |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
221 |
y+=10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
222 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
223 |
SetDParam(0, _selected_item->info.start_date); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
224 |
DrawString(260, y, STR_NETWORK_START_DATE, 2); // start date |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
225 |
y+=10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
226 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
227 |
SetDParam(0, _selected_item->info.game_date); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
228 |
DrawString(260, y, STR_NETWORK_CURRENT_DATE, 2); // current date |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
229 |
y+=10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
230 |
|
622
19e529637d18
(svn r1052) -Fix: [Network] You can't join a server when revision mismatches.
truelight
parents:
621
diff
changeset
|
231 |
y+=2; |
19e529637d18
(svn r1052) -Fix: [Network] You can't join a server when revision mismatches.
truelight
parents:
621
diff
changeset
|
232 |
|
624
f834e073c2dc
(svn r1054) -Fix: [Network] Redid revision 1024, only a bit more nice this time
truelight
parents:
622
diff
changeset
|
233 |
if (strncmp(_selected_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) { |
659
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
234 |
if (strncmp(_selected_item->info.server_revision, NOREV_STRING, sizeof(_selected_item->info.server_revision)) != 0) |
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
235 |
DrawStringMultiCenter(365, y, STR_NETWORK_VERSION_MISMATCH, 2); // server mismatch |
659
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
236 |
} else if (_selected_item->info.clients_on == _selected_item->info.clients_max) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
237 |
// Show: server full, when clients_on == clients_max |
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
238 |
DrawStringMultiCenter(365, y, STR_NETWORK_SERVER_FULL, 2); // server full |
659
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
239 |
} else if (_selected_item->info.use_password) |
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
240 |
DrawStringMultiCenter(365, y, STR_NETWORK_PASSWORD, 2); // password warning |
659
a9733f856cd0
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
241 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
242 |
y+=10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
243 |
} |
172
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
244 |
} break; |
0 | 245 |
|
246 |
case WE_CLICK: |
|
247 |
_selected_field = e->click.widget; |
|
248 |
switch(e->click.widget) { |
|
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
249 |
case 0: case 14: /* Close 'X' | Cancel button */ |
0 | 250 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
251 |
break; |
|
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
252 |
case 4: case 5: |
842 | 253 |
ShowDropDownMenu(w, _lan_internet_types_dropdown, _network_lan_internet, 5, 0, 0); // do it for widget 5 |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
254 |
break; |
982
d3ce4d6a65f8
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
970
diff
changeset
|
255 |
case 9: { /* Matrix to show networkgames */ |
211 | 256 |
uint32 id_v = (e->click.pt.y - NET_PRC__OFFSET_TOP_WIDGET) / NET_PRC__SIZE_OF_ROW; |
257 |
||
258 |
if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
|
259 |
id_v += w->vscroll.pos; |
|
260 |
||
261 |
{ |
|
262 |
NetworkGameList *cur_item = _network_game_list; |
|
216
1be476b97e32
(svn r217) -Fix: remove warning and simplify loop network_gui.c (Tron)
darkvater
parents:
214
diff
changeset
|
263 |
for (; id_v > 0 && cur_item != NULL; id_v--) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
264 |
cur_item = cur_item->next; |
211 | 265 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
266 |
if (cur_item == NULL) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
267 |
// click out of vehicle bounds |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
268 |
_selected_item = NULL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
269 |
SetWindowDirty(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
270 |
return; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
271 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
272 |
_selected_item = cur_item; |
211 | 273 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
274 |
DeleteName(_str_game_name); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
275 |
DeleteName(_str_map_name); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
276 |
DeleteName(_str_server_version); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
277 |
DeleteName(_str_server_address); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
278 |
if (_selected_item->info.server_name[0] != '\0') |
1328
eacd8225ed42
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1323
diff
changeset
|
279 |
_str_game_name = AllocateName(_selected_item->info.server_name, 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
280 |
else |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
281 |
_str_game_name = STR_EMPTY; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
282 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
283 |
if (_selected_item->info.map_name[0] != '\0') |
1328
eacd8225ed42
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1323
diff
changeset
|
284 |
_str_map_name = AllocateName(_selected_item->info.map_name, 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
285 |
else |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
286 |
_str_map_name = STR_EMPTY; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
287 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
288 |
if (_selected_item->info.server_revision[0] != '\0') |
1328
eacd8225ed42
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1323
diff
changeset
|
289 |
_str_server_version = AllocateName(_selected_item->info.server_revision, 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
290 |
else |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
291 |
_str_server_version = STR_EMPTY; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
292 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
293 |
if (_selected_item->info.hostname[0] != '\0') |
1328
eacd8225ed42
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1323
diff
changeset
|
294 |
_str_server_address = AllocateName(_selected_item->info.hostname, 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
295 |
else |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
296 |
_str_server_address = STR_EMPTY; |
211 | 297 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
298 |
SetWindowDirty(w); |
211 | 299 |
} break; |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
300 |
case 11: /* Find server automatically */ |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
301 |
switch (_network_lan_internet) { |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
302 |
case 0: NetworkUDPSearchGame(); break; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
303 |
case 1: NetworkUDPQueryMasterServer(); break; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
304 |
} |
211 | 305 |
break; |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
306 |
case 12: { // Add a server |
1328
eacd8225ed42
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1323
diff
changeset
|
307 |
StringID str = AllocateName(_network_default_ip, 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
308 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
309 |
ShowQueryString( |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
310 |
str, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
311 |
STR_NETWORK_ENTER_IP, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
312 |
31 | 0x1000, // maximum number of characters OR |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
313 |
250, // characters up to this width pixels, whichever is satisfied first |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
314 |
w->window_class, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
315 |
w->window_number); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
316 |
DeleteName(str); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
317 |
} break; |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
318 |
case 13: /* Start server */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
319 |
ShowNetworkStartServerWindow(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
320 |
break; |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
321 |
case 17: /* Join Game */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
322 |
if (_selected_item != NULL) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
323 |
memcpy(&_network_game_info, &_selected_item->info, sizeof(NetworkGameInfo)); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
324 |
snprintf(_network_last_host, sizeof(_network_last_host), "%s", inet_ntoa(*(struct in_addr *)&_selected_item->ip)); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
325 |
_network_last_port = _selected_item->port; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
326 |
ShowNetworkLobbyWindow(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
327 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
328 |
break; |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
329 |
case 18: // Refresh |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
330 |
if (_selected_item != NULL) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
331 |
NetworkQueryServer(_selected_item->info.hostname, _selected_item->port, true); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
332 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
333 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
334 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
335 |
} break; |
172
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
336 |
|
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
337 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
338 |
switch(e->dropdown.button) { |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
339 |
case 5: |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
340 |
_network_lan_internet = e->dropdown.index; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
341 |
break; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
342 |
} |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
343 |
|
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
344 |
SetWindowDirty(w); |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
345 |
break; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
346 |
|
0 | 347 |
case WE_MOUSELOOP: |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
348 |
if (_selected_field == 3) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
349 |
HandleEditBox(w, 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
350 |
|
0 | 351 |
break; |
352 |
||
353 |
case WE_KEYPRESS: |
|
738
b96ab9e63d22
(svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents:
735
diff
changeset
|
354 |
if (_selected_field != 3) { |
b96ab9e63d22
(svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents:
735
diff
changeset
|
355 |
if ( e->keypress.keycode == WKC_DELETE ) { // press 'delete' to remove servers |
897
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
356 |
if (_selected_item != NULL) { |
738
b96ab9e63d22
(svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents:
735
diff
changeset
|
357 |
NetworkGameListRemoveItem(_selected_item); |
b96ab9e63d22
(svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents:
735
diff
changeset
|
358 |
NetworkRebuildHostList(); |
b96ab9e63d22
(svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents:
735
diff
changeset
|
359 |
SetWindowDirty(w); |
897
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
360 |
_network_game_count--; |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
361 |
// reposition scrollbar |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
362 |
if (_network_game_count >= w->vscroll.cap && w->vscroll.pos > _network_game_count-w->vscroll.cap) w->vscroll.pos--; |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
363 |
UpdateNetworkGameWindow(false); |
738
b96ab9e63d22
(svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents:
735
diff
changeset
|
364 |
_selected_item = NULL; |
b96ab9e63d22
(svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents:
735
diff
changeset
|
365 |
} |
b96ab9e63d22
(svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents:
735
diff
changeset
|
366 |
} |
741
422ce499322b
(svn r1197) -Fix: [GUI] in r1194 someone deleted too much code from WE_KEYPRESS. Now
truelight
parents:
738
diff
changeset
|
367 |
break; |
422ce499322b
(svn r1197) -Fix: [GUI] in r1194 someone deleted too much code from WE_KEYPRESS. Now
truelight
parents:
738
diff
changeset
|
368 |
} |
422ce499322b
(svn r1197) -Fix: [GUI] in r1194 someone deleted too much code from WE_KEYPRESS. Now
truelight
parents:
738
diff
changeset
|
369 |
|
982
d3ce4d6a65f8
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
970
diff
changeset
|
370 |
if (HandleEditBoxKey(w, 3, e) == 1) break; // enter pressed |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
371 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
372 |
// The name is only allowed when it starts with a letter! |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
373 |
if (_edit_str_buf[0] != '\0' && _edit_str_buf[0] != ' ') |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
374 |
ttd_strlcpy(_network_player_name, _edit_str_buf, lengthof(_network_player_name)); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
375 |
else |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
376 |
ttd_strlcpy(_network_player_name, "Player", lengthof(_network_player_name)); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
377 |
|
0 | 378 |
break; |
379 |
||
380 |
case WE_ON_EDIT_TEXT: { |
|
716
8af847728d5b
(svn r1168) -Cleanup: [Network] Cleaned the network code a bit. Added 'const'
truelight
parents:
710
diff
changeset
|
381 |
NetworkAddServer(e->edittext.str); |
738
b96ab9e63d22
(svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents:
735
diff
changeset
|
382 |
NetworkRebuildHostList(); |
211 | 383 |
} break; |
384 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
385 |
case WE_CREATE: { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
386 |
_selected_item = NULL; |
0 | 387 |
} break; |
388 |
} |
|
389 |
} |
|
390 |
||
391 |
static const Widget _network_game_window_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
392 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
393 |
{ WWT_CAPTION, RESIZE_NONE, BGC, 11, 489, 0, 13, STR_NETWORK_MULTIPLAYER, STR_NULL}, |
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
394 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 0, 489, 14, 214, 0x0, STR_NULL}, |
0 | 395 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
396 |
/* LEFT SIDE */ |
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:
867
diff
changeset
|
397 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 90, 231, 22, 33, 0x0, STR_NETWORK_ENTER_NAME_TIP}, |
172
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
398 |
|
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:
867
diff
changeset
|
399 |
{ WWT_6, RESIZE_NONE, BGC, 90, 231, 42, 53, STR_NETWORK_COMBO1, STR_NETWORK_CONNECTION_TIP}, |
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:
867
diff
changeset
|
400 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 220, 230, 43, 52, STR_0225, STR_NETWORK_CONNECTION_TIP}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
401 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
402 |
{ WWT_IMGBTN, RESIZE_NONE, BTC, 10, 130, 62, 73, 0x0, STR_NETWORK_GAME_NAME_TIP }, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
403 |
{ WWT_IMGBTN, RESIZE_NONE, BTC, 131, 180, 62, 73, 0x0, STR_NETWORK_CLIENTS_CAPTION_TIP }, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
404 |
{ WWT_IMGBTN, RESIZE_NONE, BTC, 181, 219, 62, 73, 0x0, STR_NETWORK_INFO_ICONS_TIP }, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
405 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
406 |
{ WWT_MATRIX, RESIZE_NONE, BGC, 10, 219, 74, 185, 0x801, STR_NETWORK_CLICK_GAME_TO_SELECT}, |
982
d3ce4d6a65f8
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
970
diff
changeset
|
407 |
{ WWT_SCROLLBAR, RESIZE_NONE, BGC, 220, 231, 62, 185, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
408 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
409 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 10, 115, 195, 206, STR_NETWORK_FIND_SERVER, STR_NETWORK_FIND_SERVER_TIP}, |
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:
867
diff
changeset
|
410 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 125, 231, 195, 206, STR_NETWORK_ADD_SERVER, STR_NETWORK_ADD_SERVER_TIP}, |
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
411 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 250, 360, 195, 206, STR_NETWORK_START_SERVER, STR_NETWORK_START_SERVER_TIP}, |
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
412 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 370, 480, 195, 206, STR_012E_CANCEL, STR_NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
413 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
414 |
/* RIGHT SIDE */ |
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
415 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 250, 480, 22, 185, 0x0, STR_NULL}, |
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
416 |
{ WWT_6, RESIZE_NONE, BGC, 251, 479, 23, 184, 0x0, STR_NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
417 |
|
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
418 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 257, 360, 164, 175, STR_NETWORK_JOIN_GAME, STR_NULL}, |
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
419 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 370, 473, 164, 175, STR_NETWORK_REFRESH, STR_NETWORK_REFRESH_TIP}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
420 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
175
diff
changeset
|
421 |
{ WIDGETS_END}, |
0 | 422 |
}; |
423 |
||
424 |
static const WindowDesc _network_game_window_desc = { |
|
1110
baffa04c6417
(svn r1611) Display server port in the multiplayer game info window
dominik
parents:
1093
diff
changeset
|
425 |
WDP_CENTER, WDP_CENTER, 490, 215, |
0 | 426 |
WC_NETWORK_WINDOW,0, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
427 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, |
0 | 428 |
_network_game_window_widgets, |
429 |
NetworkGameWindowWndProc, |
|
430 |
}; |
|
431 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1025
diff
changeset
|
432 |
void ShowNetworkGameWindow(void) |
0 | 433 |
{ |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
434 |
uint i; |
0 | 435 |
Window *w; |
436 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
|
105 | 437 |
|
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
438 |
/* Only show once */ |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
439 |
if (_first_time_show_network_game_window) { |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
440 |
_first_time_show_network_game_window = false; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
441 |
// add all servers from the config file to our list |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
442 |
for (i=0; i != lengthof(_network_host_list); i++) { |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
443 |
if (_network_host_list[i] == NULL) break; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
444 |
NetworkAddServer(_network_host_list[i]); |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
445 |
} |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
446 |
} |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
447 |
|
0 | 448 |
w = AllocateWindowDesc(&_network_game_window_desc); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
449 |
ttd_strlcpy(_edit_str_buf, _network_player_name, MAX_QUERYSTR_LEN); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
450 |
w->vscroll.cap = 8; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
451 |
|
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
452 |
WP(w, querystr_d).text.caret = true; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
453 |
WP(w, querystr_d).text.maxlength = MAX_QUERYSTR_LEN - 1; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
454 |
WP(w, querystr_d).text.maxwidth = 120; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
455 |
WP(w, querystr_d).text.buf = _edit_str_buf; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
456 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
0 | 457 |
|
827
c812c6de160d
(svn r1298) -Fix: [ 1092661 ] On create, the scrollbar of the server-list was not updated
truelight
parents:
809
diff
changeset
|
458 |
UpdateNetworkGameWindow(true); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
459 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
460 |
|
0 | 461 |
static const StringID _players_dropdown[] = { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
462 |
STR_NETWORK_2_CLIENTS, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
463 |
STR_NETWORK_3_CLIENTS, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
464 |
STR_NETWORK_4_CLIENTS, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
465 |
STR_NETWORK_5_CLIENTS, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
466 |
STR_NETWORK_6_CLIENTS, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
467 |
STR_NETWORK_7_CLIENTS, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
468 |
STR_NETWORK_8_CLIENTS, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
469 |
STR_NETWORK_9_CLIENTS, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
470 |
STR_NETWORK_10_CLIENTS, |
0 | 471 |
INVALID_STRING_ID |
472 |
}; |
|
473 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
474 |
static const StringID _language_dropdown[] = { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
475 |
STR_NETWORK_LANG_ANY, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
476 |
STR_NETWORK_LANG_ENGLISH, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
477 |
STR_NETWORK_LANG_GERMAN, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
478 |
STR_NETWORK_LANG_FRENCH, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
479 |
INVALID_STRING_ID |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
480 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
481 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
482 |
enum { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
483 |
NSSWND_START = 64, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
484 |
NSSWND_ROWSIZE = 12 |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
485 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
486 |
|
0 | 487 |
static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e) |
488 |
{ |
|
489 |
switch(e->event) { |
|
490 |
case WE_PAINT: { |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
491 |
int y = NSSWND_START, pos; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
492 |
const FiosItem *item; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
493 |
|
675
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
494 |
SetDParam(7, STR_NETWORK_LAN_INTERNET + _network_advertise); |
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
495 |
SetDParam(9, STR_NETWORK_2_CLIENTS + _network_game_info.clients_max - 2); |
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
496 |
SetDParam(11, STR_NETWORK_LANG_ANY + _network_game_info.server_lang); |
0 | 497 |
DrawWindowWidgets(w); |
498 |
||
853
8c98eb5c2e11
(svn r1334) Fix: [ 1093466 ] no more glitches with many maps in the scenario list when creating server
dominik
parents:
842
diff
changeset
|
499 |
GfxFillRect(11, 63, 259, 171, 0xD7); |
0 | 500 |
|
501 |
DrawEditBox(w, 3); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
502 |
|
0 | 503 |
DrawString(10, 22, STR_NETWORK_NEW_GAME_NAME, 2); |
504 |
||
505 |
DrawString(10, 43, STR_NETWORK_SELECT_MAP, 2); |
|
749
64499422315d
(svn r1205) Fix: Made the network window a bit wider, so that other languages don't have overlapping strings
dominik
parents:
741
diff
changeset
|
506 |
DrawString(280, 63, STR_NETWORK_CONNECTION, 2); |
64499422315d
(svn r1205) Fix: Made the network window a bit wider, so that other languages don't have overlapping strings
dominik
parents:
741
diff
changeset
|
507 |
DrawString(280, 95, STR_NETWORK_NUMBER_OF_CLIENTS, 2); |
64499422315d
(svn r1205) Fix: Made the network window a bit wider, so that other languages don't have overlapping strings
dominik
parents:
741
diff
changeset
|
508 |
DrawString(280, 127, STR_NETWORK_LANGUAGE_SPOKEN, 2); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
509 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
510 |
// draw list of maps |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
511 |
pos = w->vscroll.pos; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
512 |
while (pos < _fios_num + 1) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
513 |
item = _fios_list + pos - 1; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
514 |
if (item == selected_map || (pos == 0 && selected_map == NULL)) |
749
64499422315d
(svn r1205) Fix: Made the network window a bit wider, so that other languages don't have overlapping strings
dominik
parents:
741
diff
changeset
|
515 |
GfxFillRect(11, y - 1, 259, y + 10, 155); // show highlighted item with a different colour |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
516 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
517 |
if (pos == 0) DrawString(14, y, STR_4010_GENERATE_RANDOM_NEW_GAME, 9); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
518 |
else DoDrawString(item->title[0] ? item->title : item->name, 14, y, _fios_colors[item->type] ); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
519 |
pos++; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
520 |
y += NSSWND_ROWSIZE; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
521 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
522 |
if (y >= w->vscroll.cap * NSSWND_ROWSIZE + NSSWND_START) break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
523 |
} |
172
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
524 |
} break; |
0 | 525 |
|
526 |
case WE_CLICK: |
|
527 |
_selected_field = e->click.widget; |
|
528 |
switch(e->click.widget) { |
|
675
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
529 |
case 0: case 15: /* Close 'X' | Cancel button */ |
0 | 530 |
ShowNetworkGameWindow(); |
531 |
break; |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
532 |
case 4: { /* Set password button */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
533 |
StringID str; |
1142
072cbf2d9d7b
(svn r1643) -Fix: [ 1108547 ] You can now change the server-password via the GUI again
truelight
parents:
1110
diff
changeset
|
534 |
str = AllocateName(_network_server_password, 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
535 |
ShowQueryString(str, STR_NETWORK_SET_PASSWORD, 20, 250, w->window_class, w->window_number); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
536 |
DeleteName(str); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
537 |
} break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
538 |
case 5: { /* Select map */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
539 |
int y = (e->click.pt.y - NSSWND_START) / NSSWND_ROWSIZE; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
540 |
if ((y += w->vscroll.pos) >= w->vscroll.count) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
541 |
return; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
542 |
if (y == 0) selected_map = NULL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
543 |
else selected_map = _fios_list + y-1; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
544 |
SetWindowDirty(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
545 |
} break; |
675
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
546 |
case 7: case 8: /* Connection type */ |
842 | 547 |
ShowDropDownMenu(w, _connection_types_dropdown, _network_advertise, 8, 0, 0); // do it for widget 8 |
675
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
548 |
break; |
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
549 |
case 9: case 10: /* Number of Players */ |
842 | 550 |
ShowDropDownMenu(w, _players_dropdown, _network_game_info.clients_max - 2, 10, 0, 0); // do it for widget 10 |
0 | 551 |
return; |
675
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
552 |
case 11: case 12: /* Language */ |
842 | 553 |
ShowDropDownMenu(w, _language_dropdown, _network_game_info.server_lang, 12, 0, 0); // do it for widget 12 |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
554 |
return; |
675
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
555 |
case 13: /* Start game */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
556 |
_is_network_server = true; |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
557 |
ttd_strlcpy(_network_server_name, WP(w, querystr_d).text.buf, sizeof(_network_server_name)); |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
558 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
559 |
if(selected_map==NULL) { // start random new game |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
560 |
DoCommandP(0, Random(), InteractiveRandom(), NULL, CMD_GEN_RANDOM_NEW_GAME); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
561 |
} else { // load a scenario |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
562 |
char *name; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
563 |
if ((name = FiosBrowseTo(selected_map)) != NULL) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
564 |
SetFiosType(selected_map->type); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
565 |
strcpy(_file_to_saveload.name, name); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
566 |
snprintf(_network_game_info.map_name, sizeof(_network_game_info.map_name), "Loaded scenario"); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
567 |
DeleteWindow(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
568 |
DoCommandP(0, Random(), InteractiveRandom(), NULL, CMD_START_SCENARIO); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
569 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
570 |
} |
0 | 571 |
break; |
675
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
572 |
case 14: /* Load game */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
573 |
_is_network_server = true; |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
574 |
ttd_strlcpy(_network_server_name, WP(w, querystr_d).text.buf, sizeof(_network_server_name)); |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
575 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
576 |
snprintf(_network_game_info.map_name, sizeof(_network_game_info.map_name), "Loaded game"); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
577 |
/* XXX - WC_NETWORK_WINDOW should stay, but if it stays, it gets |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
578 |
* copied all the elements of 'load game' and upon closing that, it segfaults */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
579 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
172
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
580 |
ShowSaveLoadDialog(SLD_LOAD_GAME); |
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
581 |
break; |
0 | 582 |
} |
172
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
583 |
break; |
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
584 |
|
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
585 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
586 |
switch(e->dropdown.button) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
587 |
case 8: |
675
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
588 |
_network_advertise = (e->dropdown.index == 0) ? false : true; |
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
589 |
break; |
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
590 |
case 10: |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
591 |
_network_game_info.clients_max = e->dropdown.index + 2; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
592 |
break; |
675
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
593 |
case 12: |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
594 |
_network_game_info.server_lang = e->dropdown.index; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
595 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
596 |
} |
172
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
597 |
|
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
598 |
SetWindowDirty(w); |
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
599 |
break; |
0 | 600 |
|
601 |
case WE_MOUSELOOP: |
|
172
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
602 |
if(_selected_field == 3 || _selected_field == 4) |
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
603 |
HandleEditBox(w, _selected_field); |
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
105
diff
changeset
|
604 |
|
0 | 605 |
break; |
606 |
||
607 |
case WE_KEYPRESS: |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
608 |
if(_selected_field != 3) |
0 | 609 |
break; |
610 |
switch (HandleEditBoxKey(w, _selected_field, e)) { |
|
611 |
case 1: |
|
612 |
HandleButtonClick(w, 9); |
|
613 |
break; |
|
614 |
} |
|
615 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
616 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
617 |
case WE_ON_EDIT_TEXT: { |
1323
bac2e38e8b60
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1317
diff
changeset
|
618 |
const char *b = e->edittext.str; |
1142
072cbf2d9d7b
(svn r1643) -Fix: [ 1108547 ] You can now change the server-password via the GUI again
truelight
parents:
1110
diff
changeset
|
619 |
ttd_strlcpy(_network_server_password, b, sizeof(_network_server_password)); |
072cbf2d9d7b
(svn r1643) -Fix: [ 1108547 ] You can now change the server-password via the GUI again
truelight
parents:
1110
diff
changeset
|
620 |
if (_network_server_password[0] == '\0') { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
621 |
_network_game_info.use_password = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
622 |
} else { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
623 |
_network_game_info.use_password = 1; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
624 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
625 |
} break; |
0 | 626 |
} |
627 |
} |
|
628 |
||
629 |
static const Widget _network_start_server_window_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
630 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 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:
853
diff
changeset
|
631 |
{ WWT_CAPTION, RESIZE_NONE, BGC, 11, 419, 0, 13, STR_NETWORK_START_GAME_WINDOW, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
632 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 0, 419, 14, 199, 0x0, STR_NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
633 |
|
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:
867
diff
changeset
|
634 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 100, 272, 22, 33, 0x0, STR_NETWORK_NEW_GAME_NAME_TIP}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
635 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 285, 405, 22, 33, STR_NETWORK_SET_PASSWORD, STR_NETWORK_PASSWORD_TIP}, |
749
64499422315d
(svn r1205) Fix: Made the network window a bit wider, so that other languages don't have overlapping strings
dominik
parents:
741
diff
changeset
|
636 |
|
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:
867
diff
changeset
|
637 |
{ WWT_6, RESIZE_NONE, BGC, 10, 271, 62, 172, 0x0, STR_NETWORK_SELECT_MAP_TIP}, |
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:
867
diff
changeset
|
638 |
{ WWT_SCROLLBAR, RESIZE_NONE, BGC, 260, 271, 63, 171, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
749
64499422315d
(svn r1205) Fix: Made the network window a bit wider, so that other languages don't have overlapping strings
dominik
parents:
741
diff
changeset
|
639 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
640 |
{ WWT_6, RESIZE_NONE, BGC, 280, 410, 77, 88, STR_NETWORK_COMBO1, STR_NETWORK_CONNECTION_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
641 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 399, 409, 78, 87, STR_0225, STR_NETWORK_CONNECTION_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
642 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
643 |
{ WWT_6, RESIZE_NONE, BGC, 280, 410, 109, 120, STR_NETWORK_COMBO2, STR_NETWORK_NUMBER_OF_CLIENTS_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
644 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 399, 409, 110, 119, STR_0225, STR_NETWORK_NUMBER_OF_CLIENTS_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
645 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
646 |
{ WWT_6, RESIZE_NONE, BGC, 280, 410, 141, 152, STR_NETWORK_COMBO3, STR_NETWORK_LANGUAGE_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
647 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 399, 409, 142, 151, STR_0225, STR_NETWORK_LANGUAGE_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
648 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
649 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 40, 140, 180, 191, STR_NETWORK_START_GAME, STR_NETWORK_START_GAME_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
650 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 150, 250, 180, 191, STR_NETWORK_LOAD_GAME, STR_NETWORK_LOAD_GAME_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
651 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 260, 360, 180, 191, STR_012E_CANCEL, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
175
diff
changeset
|
652 |
{ WIDGETS_END}, |
0 | 653 |
}; |
654 |
||
655 |
static const WindowDesc _network_start_server_window_desc = { |
|
749
64499422315d
(svn r1205) Fix: Made the network window a bit wider, so that other languages don't have overlapping strings
dominik
parents:
741
diff
changeset
|
656 |
WDP_CENTER, WDP_CENTER, 420, 200, |
0 | 657 |
WC_NETWORK_WINDOW,0, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
658 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, |
0 | 659 |
_network_start_server_window_widgets, |
660 |
NetworkStartServerWindowWndProc, |
|
661 |
}; |
|
662 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
663 |
static void ShowNetworkStartServerWindow(void) |
0 | 664 |
{ |
665 |
Window *w; |
|
666 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
667 |
|
0 | 668 |
w = AllocateWindowDesc(&_network_start_server_window_desc); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
669 |
ttd_strlcpy(_edit_str_buf, _network_server_name, MAX_QUERYSTR_LEN); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
670 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
671 |
_saveload_mode = SLD_NEW_GAME; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
672 |
BuildFileList(); |
853
8c98eb5c2e11
(svn r1334) Fix: [ 1093466 ] no more glitches with many maps in the scenario list when creating server
dominik
parents:
842
diff
changeset
|
673 |
w->vscroll.cap = 9; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
674 |
w->vscroll.count = _fios_num+1; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
675 |
|
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
676 |
WP(w, querystr_d).text.caret = true; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
677 |
WP(w, querystr_d).text.maxlength = MAX_QUERYSTR_LEN - 1; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
678 |
WP(w, querystr_d).text.maxwidth = 160; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
679 |
WP(w, querystr_d).text.buf = _edit_str_buf; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
680 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
0 | 681 |
} |
682 |
||
734
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
683 |
static byte NetworkLobbyFindCompanyIndex(byte pos) |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
684 |
{ |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
685 |
byte i; |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
686 |
/* Scroll through all _network_player_info and get the 'pos' item |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
687 |
that is not empty */ |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
688 |
for (i = 0; i < MAX_PLAYERS; i++) { |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
689 |
if (_network_player_info[i].company_name[0] != '\0') { |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
690 |
if (pos-- == 0) |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
691 |
return i; |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
692 |
} |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
693 |
} |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
694 |
|
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
695 |
return 0; |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
696 |
} |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
697 |
|
0 | 698 |
static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) |
699 |
{ |
|
700 |
switch(e->event) { |
|
701 |
case WE_PAINT: { |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
702 |
int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
703 |
StringID str; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
704 |
|
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
705 |
w->disabled_state = (_selected_company_item == -1) ? 1 << 7 : 0; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
706 |
|
621
31b12c30b54c
(svn r1051) -Fix: [Network] New Company button is disabled when there is no more
truelight
parents:
618
diff
changeset
|
707 |
if (_network_lobby_company_count == MAX_PLAYERS) |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
708 |
SETBIT(w->disabled_state, 8); |
735
995f97df3bd7
(svn r1187) -Fix: [Network] You can no longer join as spectator a game with no
truelight
parents:
734
diff
changeset
|
709 |
/* You can not join a server as spectator when it has no companies active.. |
995f97df3bd7
(svn r1187) -Fix: [Network] You can no longer join as spectator a game with no
truelight
parents:
734
diff
changeset
|
710 |
it causes some nasty crashes */ |
995f97df3bd7
(svn r1187) -Fix: [Network] You can no longer join as spectator a game with no
truelight
parents:
734
diff
changeset
|
711 |
if (_network_lobby_company_count == 0) |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
712 |
SETBIT(w->disabled_state, 9); |
621
31b12c30b54c
(svn r1051) -Fix: [Network] New Company button is disabled when there is no more
truelight
parents:
618
diff
changeset
|
713 |
|
0 | 714 |
DrawWindowWidgets(w); |
715 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
716 |
SetDParam(0, _str_game_name); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
717 |
DrawString(10, 22, STR_NETWORK_PREPARE_TO_JOIN, 2); |
0 | 718 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
719 |
// draw company list |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
720 |
GfxFillRect(11, 41, 154, 165, 0xD7); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
721 |
pos = w->vscroll.pos; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
722 |
while (pos < _network_lobby_company_count) { |
734
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
723 |
byte index = NetworkLobbyFindCompanyIndex(pos); |
1011
933efc472c62
(svn r1510) -Add: Improved Network Lobby GUI: (bociusz)
truelight
parents:
1009
diff
changeset
|
724 |
bool income = false; |
734
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
725 |
if (_selected_company_item == index) |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
726 |
GfxFillRect(11, y - 1, 154, y + 10, 155); // show highlighted item with a different colour |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
727 |
|
734
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
728 |
DoDrawString(_network_player_info[index].company_name, 13, y, 2); |
1011
933efc472c62
(svn r1510) -Add: Improved Network Lobby GUI: (bociusz)
truelight
parents:
1009
diff
changeset
|
729 |
if(_network_player_info[index].use_password != 0) |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
730 |
DrawSprite(SPR_LOCK, 135, y); |
1011
933efc472c62
(svn r1510) -Add: Improved Network Lobby GUI: (bociusz)
truelight
parents:
1009
diff
changeset
|
731 |
|
933efc472c62
(svn r1510) -Add: Improved Network Lobby GUI: (bociusz)
truelight
parents:
1009
diff
changeset
|
732 |
/* If the company's income was positive puts a green dot else a red dot */ |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
733 |
if ((_network_player_info[index].income) >= 0) |
1011
933efc472c62
(svn r1510) -Add: Improved Network Lobby GUI: (bociusz)
truelight
parents:
1009
diff
changeset
|
734 |
income = true; |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
735 |
DrawSprite(SPR_BLOT | (income ? PALETTE_TO_GREEN : PALETTE_TO_RED), 145, y); |
0 | 736 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
737 |
pos++; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
738 |
y += NET_PRC__SIZE_OF_ROW_COMPANY; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
739 |
if (pos >= w->vscroll.cap) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
740 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
741 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
742 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
743 |
// draw info about selected company |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
744 |
DrawStringMultiCenter(290, 48, STR_NETWORK_COMPANY_INFO, 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
745 |
if (_selected_company_item != -1) { // if a company is selected... |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
746 |
// show company info |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
747 |
const uint x = 183; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
748 |
uint xm; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
749 |
y = 65; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
750 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
751 |
str = AllocateName(_network_player_info[_selected_company_item].company_name, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
752 |
SetDParam(0, str); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
753 |
DrawString(x, y, STR_NETWORK_COMPANY_NAME, 2); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
754 |
DeleteName(str); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
755 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
756 |
|
970
24abd02b1092
(svn r1465) -Fix: [1099101] starting year patch goes out of range. Clamped year between 1920-2090 as wel as adding defines for it.
darkvater
parents:
897
diff
changeset
|
757 |
SetDParam(0, _network_player_info[_selected_company_item].inaugurated_year + MAX_YEAR_BEGIN_REAL); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
758 |
DrawString(x, y, STR_NETWORK_INAUGURATION_YEAR, 2); // inauguration year |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
759 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
760 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
761 |
SetDParam64(0, _network_player_info[_selected_company_item].company_value); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
762 |
DrawString(x, y, STR_NETWORK_VALUE, 2); // company value |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
763 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
764 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
765 |
SetDParam64(0, _network_player_info[_selected_company_item].money); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
766 |
DrawString(x, y, STR_NETWORK_CURRENT_BALANCE, 2); // current balance |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
767 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
768 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
769 |
SetDParam64(0, _network_player_info[_selected_company_item].income); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
770 |
DrawString(x, y, STR_NETWORK_LAST_YEARS_INCOME, 2); // last year's income |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
771 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
772 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
773 |
SetDParam(0, _network_player_info[_selected_company_item].performance); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
774 |
DrawString(x, y, STR_NETWORK_PERFORMANCE, 2); // performance |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
775 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
776 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
777 |
SetDParam(0, _network_player_info[_selected_company_item].num_vehicle[0]); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
778 |
SetDParam(1, _network_player_info[_selected_company_item].num_vehicle[1]); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
779 |
SetDParam(2, _network_player_info[_selected_company_item].num_vehicle[2]); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
780 |
SetDParam(3, _network_player_info[_selected_company_item].num_vehicle[3]); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
781 |
SetDParam(4, _network_player_info[_selected_company_item].num_vehicle[4]); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
782 |
DrawString(x, y, STR_NETWORK_VEHICLES, 2); // vehicles |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
783 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
784 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
785 |
SetDParam(0, _network_player_info[_selected_company_item].num_station[0]); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
786 |
SetDParam(1, _network_player_info[_selected_company_item].num_station[1]); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
787 |
SetDParam(2, _network_player_info[_selected_company_item].num_station[2]); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
788 |
SetDParam(3, _network_player_info[_selected_company_item].num_station[3]); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
789 |
SetDParam(4, _network_player_info[_selected_company_item].num_station[4]); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
790 |
DrawString(x, y, STR_NETWORK_STATIONS, 2); // stations |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
791 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
792 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
793 |
str = AllocateName(_network_player_info[_selected_company_item].players, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
794 |
SetDParam(0, str); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
795 |
xm = DrawString(x, y, STR_NETWORK_PLAYERS, 2); // players |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
796 |
DeleteName(str); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
797 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
798 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
799 |
} break; |
0 | 800 |
|
801 |
case WE_CLICK: |
|
802 |
switch(e->click.widget) { |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
803 |
case 0: case 11: /* Close 'X' | Cancel button */ |
0 | 804 |
ShowNetworkGameWindow(); |
805 |
break; |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
806 |
case 3: /* Company list */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
807 |
_selected_company_item = (e->click.pt.y - NET_PRC__OFFSET_TOP_WIDGET_COMPANY) / NET_PRC__SIZE_OF_ROW_COMPANY; |
0 | 808 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
809 |
if (_selected_company_item >= w->vscroll.cap) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
810 |
// click out of bounds |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
811 |
_selected_company_item = -1; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
812 |
SetWindowDirty(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
813 |
return; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
814 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
815 |
_selected_company_item += w->vscroll.pos; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
816 |
if (_selected_company_item >= _network_lobby_company_count) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
817 |
_selected_company_item = -1; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
818 |
SetWindowDirty(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
819 |
return; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
820 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
821 |
|
734
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
822 |
_selected_company_item = NetworkLobbyFindCompanyIndex(_selected_company_item); |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
823 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
824 |
SetWindowDirty(w); |
0 | 825 |
break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
826 |
case 7: /* Join company */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
827 |
if (_selected_company_item != -1) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
828 |
_network_playas = _selected_company_item + 1; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
829 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
830 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
831 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
832 |
case 8: /* New company */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
833 |
_network_playas = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
834 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
835 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
836 |
case 9: /* Spectate game */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
837 |
_network_playas = OWNER_SPECTATOR; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
838 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
839 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
840 |
case 10: /* Refresh */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
841 |
NetworkQueryServer(_network_last_host, _network_last_port, false); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
842 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
843 |
} break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
844 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
845 |
case WE_CREATE: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
846 |
_selected_company_item = -1; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
847 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
848 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
849 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
850 |
static const Widget _network_lobby_window_widgets[] = { |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
851 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 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:
853
diff
changeset
|
852 |
{ WWT_CAPTION, RESIZE_NONE, BGC, 11, 419, 0, 13, STR_NETWORK_GAME_LOBBY, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
853 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 0, 419, 14, 209, 0x0, STR_NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
854 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
855 |
// company list |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
856 |
{ WWT_6, RESIZE_NONE, BGC, 10, 167, 40, 166, 0x0, STR_NETWORK_COMPANY_LIST_TIP}, |
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
857 |
{ WWT_SCROLLBAR, RESIZE_NONE, BGC, 155, 166, 41, 165, 0x1, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
858 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
859 |
// company/player info |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
860 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 173, 404, 38, 166, 0x0, STR_NULL}, |
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
861 |
{ WWT_6, RESIZE_NONE, BGC, 174, 403, 39, 165, 0x0, STR_NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
862 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
863 |
// buttons |
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:
867
diff
changeset
|
864 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 10, 151, 175, 186, STR_NETWORK_JOIN_COMPANY, STR_NETWORK_JOIN_COMPANY_TIP}, |
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:
867
diff
changeset
|
865 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 10, 151, 190, 201, STR_NETWORK_NEW_COMPANY, STR_NETWORK_NEW_COMPANY_TIP}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
866 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 158, 268, 175, 186, STR_NETWORK_SPECTATE_GAME, STR_NETWORK_SPECTATE_GAME_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
867 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 158, 268, 190, 201, STR_NETWORK_REFRESH, STR_NETWORK_REFRESH_TIP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
868 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 278, 388, 175, 186, STR_012E_CANCEL, STR_NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
869 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
870 |
{ WIDGETS_END}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
871 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
872 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
873 |
static const WindowDesc _network_lobby_window_desc = { |
749
64499422315d
(svn r1205) Fix: Made the network window a bit wider, so that other languages don't have overlapping strings
dominik
parents:
741
diff
changeset
|
874 |
WDP_CENTER, WDP_CENTER, 420, 210, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
875 |
WC_NETWORK_WINDOW,0, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
876 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
877 |
_network_lobby_window_widgets, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
878 |
NetworkLobbyWindowWndProc, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
879 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
880 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
881 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
882 |
static void ShowNetworkLobbyWindow(void) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
883 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
884 |
Window *w; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
885 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
886 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
887 |
_network_lobby_company_count = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
888 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
889 |
NetworkQueryServer(_network_last_host, _network_last_port, false); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
890 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
891 |
w = AllocateWindowDesc(&_network_lobby_window_desc); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
892 |
strcpy(_edit_str_buf, ""); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
893 |
w->vscroll.pos = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
894 |
w->vscroll.cap = 8; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
895 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
896 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
897 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
898 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
899 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
900 |
// The window below gives information about the connected clients |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
901 |
// and also makes able to give money to them, kick them (if server) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
902 |
// and stuff like that. |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
903 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
904 |
extern void DrawPlayerIcon(int p, int x, int y); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
905 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
906 |
// Every action must be of this form |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
907 |
typedef void ClientList_Action_Proc(byte client_no); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
908 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
909 |
// Max 10 actions per client |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
910 |
#define MAX_CLIENTLIST_ACTION 10 |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
911 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
912 |
// Some standard bullshit.. defines variables ;) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
913 |
static void ClientListWndProc(Window *w, WindowEvent *e); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
914 |
static void ClientListPopupWndProc(Window *w, WindowEvent *e); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
915 |
static byte _selected_clientlist_item = 255; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
916 |
static byte _selected_clientlist_y = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
917 |
static char _clientlist_action[MAX_CLIENTLIST_ACTION][50]; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
918 |
static ClientList_Action_Proc *_clientlist_proc[MAX_CLIENTLIST_ACTION]; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
919 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
920 |
enum { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
921 |
CLNWND_OFFSET = 16, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
922 |
CLNWND_ROWSIZE = 10 |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
923 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
924 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
925 |
static const Widget _client_list_widgets[] = { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
926 |
{ 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:
853
diff
changeset
|
927 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 249, 0, 13, STR_NETWORK_CLIENT_LIST, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
928 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
929 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 249, 14, 14 + CLNWND_ROWSIZE + 1, 0x0, STR_NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
930 |
{ WIDGETS_END}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
931 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
932 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
933 |
static const Widget _client_list_popup_widgets[] = { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
934 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 99, 0, 0, 0, STR_NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
935 |
{ WIDGETS_END}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
936 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
937 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
938 |
static WindowDesc _client_list_desc = { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
939 |
-1, -1, 250, 1, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
940 |
WC_CLIENT_LIST,0, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
941 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
942 |
_client_list_widgets, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
943 |
ClientListWndProc |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
944 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
945 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
946 |
// Finds the Xth client-info that is active |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
947 |
static NetworkClientInfo *NetworkFindClientInfo(byte client_no) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
948 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
949 |
NetworkClientInfo *ci; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
950 |
for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
951 |
// Skip non-active items |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
952 |
if (ci->client_index == NETWORK_EMPTY_INDEX) continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
953 |
if (client_no == 0) return ci; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
954 |
client_no--; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
955 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
956 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
957 |
return NULL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
958 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
959 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
960 |
// Here we start to define the options out of the menu |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
961 |
static void ClientList_Kick(byte client_no) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
962 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
963 |
if (client_no < MAX_PLAYERS) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
964 |
SEND_COMMAND(PACKET_SERVER_ERROR)(&_clients[client_no], NETWORK_ERROR_KICKED); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
965 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
966 |
|
841
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
967 |
static void ClientList_Ban(byte client_no) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
968 |
{ |
841
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
969 |
uint i; |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
970 |
uint32 ip = NetworkFindClientInfo(client_no)->client_ip; |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
971 |
|
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
972 |
for (i = 0; i < lengthof(_network_ban_list); i++) { |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
973 |
if (_network_ban_list[i] == NULL || _network_ban_list[i][0] == '\0') { |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
974 |
_network_ban_list[i] = strdup(inet_ntoa(*(struct in_addr *)&ip)); |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
975 |
break; |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
976 |
} |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
977 |
} |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
978 |
|
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
979 |
if (client_no < MAX_PLAYERS) |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
980 |
SEND_COMMAND(PACKET_SERVER_ERROR)(&_clients[client_no], NETWORK_ERROR_KICKED); |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
981 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
982 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
983 |
static void ClientList_GiveMoney(byte client_no) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
984 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
985 |
if (NetworkFindClientInfo(client_no) != NULL) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
986 |
ShowNetworkGiveMoneyWindow(NetworkFindClientInfo(client_no)->client_playas - 1); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
987 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
988 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
989 |
static void ClientList_SpeakToClient(byte client_no) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
990 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
991 |
if (NetworkFindClientInfo(client_no) != NULL) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
992 |
ShowNetworkChatQueryWindow(DESTTYPE_CLIENT, NetworkFindClientInfo(client_no)->client_index); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
993 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
994 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
995 |
static void ClientList_SpeakToPlayer(byte client_no) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
996 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
997 |
if (NetworkFindClientInfo(client_no) != NULL) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
998 |
ShowNetworkChatQueryWindow(DESTTYPE_PLAYER, NetworkFindClientInfo(client_no)->client_playas); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
999 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1000 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1001 |
static void ClientList_SpeakToAll(byte client_no) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1002 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1003 |
ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1004 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1005 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1006 |
static void ClientList_None(byte client_no) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1007 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1008 |
// No action ;) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1009 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1010 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1011 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1012 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1013 |
// Help, a action is clicked! What do we do? |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1014 |
static void HandleClientListPopupClick(byte index, byte clientno) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1015 |
// A click on the Popup of the ClientList.. handle the command |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1016 |
if (index < MAX_CLIENTLIST_ACTION && _clientlist_proc[index] != NULL) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1017 |
_clientlist_proc[index](clientno); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1018 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1019 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1020 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1021 |
// Finds the amount of clients and set the height correct |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1022 |
static bool CheckClientListHeight(Window *w) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1023 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1024 |
int num = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1025 |
NetworkClientInfo *ci; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1026 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1027 |
// Should be replaced with a loop through all clients |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1028 |
for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1029 |
// Skip non-active items |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1030 |
if (ci->client_index == NETWORK_EMPTY_INDEX) continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1031 |
num++; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1032 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1033 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1034 |
num *= CLNWND_ROWSIZE; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1035 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1036 |
// If height is changed |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1037 |
if (w->height != CLNWND_OFFSET + num + 1) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1038 |
// XXX - magic unfortunately; (num + 2) has to be one bigger than heigh (num + 1) |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1039 |
SetWindowDirty(w); |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1040 |
w->widget[2].bottom = w->widget[2].top + num + 2; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1041 |
w->height = CLNWND_OFFSET + num + 1; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1042 |
SetWindowDirty(w); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1043 |
return false; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1044 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1045 |
return true; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1046 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1047 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1048 |
// Finds the amount of actions in the popup and set the height correct |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1049 |
static uint ClientListPopupHeigth(void) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1050 |
int i, num = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1051 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1052 |
// Find the amount of actions |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1053 |
for (i = 0; i < MAX_CLIENTLIST_ACTION; i++) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1054 |
if (_clientlist_action[i][0] == '\0') continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1055 |
if (_clientlist_proc[i] == NULL) continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1056 |
num++; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1057 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1058 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1059 |
num *= CLNWND_ROWSIZE; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1060 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1061 |
return num + 1; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1062 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1063 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1064 |
// Show the popup (action list) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1065 |
static Window *PopupClientList(Window *w, int client_no, int x, int y) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1066 |
{ |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1067 |
int i, h; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1068 |
NetworkClientInfo *ci; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1069 |
DeleteWindowById(WC_TOOLBAR_MENU, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1070 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1071 |
// Clean the current actions |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1072 |
for (i = 0; i < MAX_CLIENTLIST_ACTION; i++) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1073 |
_clientlist_action[i][0] = '\0'; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1074 |
_clientlist_proc[i] = NULL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1075 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1076 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1077 |
// Fill the actions this client has |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1078 |
// Watch is, max 50 chars long! |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1079 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1080 |
ci = NetworkFindClientInfo(client_no); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1081 |
if (ci == NULL) return NULL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1082 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1083 |
i = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1084 |
if (_network_own_client_index != ci->client_index) { |
722
f420fa9bd521
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
716
diff
changeset
|
1085 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_CLIENT); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1086 |
_clientlist_proc[i++] = &ClientList_SpeakToClient; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1087 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1088 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1089 |
if (ci->client_playas >= 1 && ci->client_playas <= MAX_PLAYERS) { |
722
f420fa9bd521
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
716
diff
changeset
|
1090 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1091 |
_clientlist_proc[i++] = &ClientList_SpeakToPlayer; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1092 |
} |
722
f420fa9bd521
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
716
diff
changeset
|
1093 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_ALL); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1094 |
_clientlist_proc[i++] = &ClientList_SpeakToAll; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1095 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1096 |
if (_network_own_client_index != ci->client_index) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1097 |
if (_network_playas >= 1 && _network_playas <= MAX_PLAYERS) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1098 |
// We are no spectator |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1099 |
if (ci->client_playas >= 1 && ci->client_playas <= MAX_PLAYERS) { |
722
f420fa9bd521
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
716
diff
changeset
|
1100 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_GIVE_MONEY); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1101 |
_clientlist_proc[i++] = &ClientList_GiveMoney; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1102 |
} |
0 | 1103 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1104 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1105 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1106 |
// A server can kick clients (but not hisself) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1107 |
if (_network_server && _network_own_client_index != ci->client_index) { |
722
f420fa9bd521
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
716
diff
changeset
|
1108 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_KICK); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1109 |
_clientlist_proc[i++] = &ClientList_Kick; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1110 |
|
841
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1111 |
sprintf(_clientlist_action[i],"Ban"); |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1112 |
_clientlist_proc[i++] = &ClientList_Ban; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1113 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1114 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1115 |
if (i == 0) { |
722
f420fa9bd521
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
716
diff
changeset
|
1116 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_NONE); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1117 |
_clientlist_proc[i++] = &ClientList_None; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1118 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1119 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1120 |
/* Calculate the height */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1121 |
h = ClientListPopupHeigth(); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1122 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1123 |
// Allocate the popup |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1124 |
w = AllocateWindow(x, y, 100, h + 1, ClientListPopupWndProc, WC_TOOLBAR_MENU, _client_list_popup_widgets); |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1125 |
w->widget[0].bottom = w->widget[0].top + h; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1126 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1127 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1128 |
WP(w,menu_d).item_count = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1129 |
// Save our client |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1130 |
WP(w,menu_d).main_button = client_no; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1131 |
WP(w,menu_d).sel_index = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1132 |
// We are a popup |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1133 |
_popup_menu_active = true; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1134 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1135 |
return w; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1136 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1137 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1138 |
// Main handle for the popup |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1139 |
static void ClientListPopupWndProc(Window *w, WindowEvent *e) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1140 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1141 |
switch(e->event) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1142 |
case WE_PAINT: { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1143 |
int i, y, sel; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1144 |
byte colour; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1145 |
DrawWindowWidgets(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1146 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1147 |
// Draw the actions |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1148 |
sel = WP(w,menu_d).sel_index; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1149 |
y = 1; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1150 |
for (i = 0; i < MAX_CLIENTLIST_ACTION; i++, y += CLNWND_ROWSIZE) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1151 |
if (_clientlist_action[i][0] == '\0') continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1152 |
if (_clientlist_proc[i] == NULL) continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1153 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1154 |
if (sel-- == 0) { // Selected item, highlight it |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1155 |
GfxFillRect(1, y, 98, y + CLNWND_ROWSIZE - 1, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1156 |
colour = 0xC; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1157 |
} else colour = 0x10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1158 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1159 |
DoDrawString(_clientlist_action[i], 4, y, colour); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1160 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1161 |
} break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1162 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1163 |
case WE_POPUPMENU_SELECT: { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1164 |
// We selected an action |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1165 |
int index = (e->popupmenu.pt.y - w->top) / CLNWND_ROWSIZE; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1166 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1167 |
if (index >= 0 && e->popupmenu.pt.y >= w->top) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1168 |
HandleClientListPopupClick(index, WP(w,menu_d).main_button); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1169 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1170 |
// Sometimes, because of the bad DeleteWindow-proc, the 'w' pointer is |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1171 |
// invalid after the last functions (mostly because it kills a window |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1172 |
// that is in front of 'w', and because of a silly memmove, the address |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1173 |
// 'w' was pointing to becomes invalid), so we need to refetch |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1174 |
// the right address... |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1175 |
DeleteWindowById(WC_TOOLBAR_MENU, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1176 |
} break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1177 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1178 |
case WE_POPUPMENU_OVER: { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1179 |
// Our mouse hoovers over an action? Select it! |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1180 |
int index = (e->popupmenu.pt.y - w->top) / CLNWND_ROWSIZE; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1181 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1182 |
if (index == -1 || index == WP(w,menu_d).sel_index) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1183 |
return; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1184 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1185 |
WP(w,menu_d).sel_index = index; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1186 |
SetWindowDirty(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1187 |
} break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1188 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1189 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1190 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1191 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1192 |
// Main handle for clientlist |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1193 |
static void ClientListWndProc(Window *w, WindowEvent *e) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1194 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1195 |
switch(e->event) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1196 |
case WE_PAINT: { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1197 |
NetworkClientInfo *ci; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1198 |
int y, i = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1199 |
byte colour; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1200 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1201 |
// Check if we need to reset the height |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1202 |
if (!CheckClientListHeight(w)) break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1203 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1204 |
DrawWindowWidgets(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1205 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1206 |
y = CLNWND_OFFSET; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1207 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1208 |
for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1209 |
// Skip non-active items |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1210 |
if (ci->client_index == NETWORK_EMPTY_INDEX) continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1211 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1212 |
if (_selected_clientlist_item == i++) { // Selected item, highlight it |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1213 |
GfxFillRect(1, y, 248, y + CLNWND_ROWSIZE - 1, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1214 |
colour = 0xC; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1215 |
} else |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1216 |
colour = 0x10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1217 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1218 |
if (ci->client_index == NETWORK_SERVER_INDEX) { |
722
f420fa9bd521
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
716
diff
changeset
|
1219 |
DrawString(4, y, STR_NETWORK_SERVER, colour); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1220 |
} else |
722
f420fa9bd521
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
716
diff
changeset
|
1221 |
DrawString(4, y, STR_NETWORK_CLIENT, colour); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1222 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1223 |
// Filter out spectators |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1224 |
if (ci->client_playas > 0 && ci->client_playas <= MAX_PLAYERS) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1225 |
DrawPlayerIcon(ci->client_playas - 1, 44, y + 1); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1226 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1227 |
DoDrawString(ci->client_name, 61, y, colour); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1228 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1229 |
y += CLNWND_ROWSIZE; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1230 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1231 |
} break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1232 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1233 |
case WE_CLICK: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1234 |
// Show the popup with option |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1235 |
if (_selected_clientlist_item != 255) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1236 |
PopupClientList(w, _selected_clientlist_item, e->click.pt.x + w->left, e->click.pt.y + w->top); |
0 | 1237 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1238 |
|
0 | 1239 |
break; |
1240 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1241 |
case WE_MOUSEOVER: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1242 |
// -1 means we left the current window |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1243 |
if (e->mouseover.pt.y == -1) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1244 |
_selected_clientlist_y = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1245 |
_selected_clientlist_item = 255; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1246 |
SetWindowDirty(w); |
0 | 1247 |
break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1248 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1249 |
// It did not change.. no update! |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1250 |
if (e->mouseover.pt.y == _selected_clientlist_y) break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1251 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1252 |
// Find the new selected item (if any) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1253 |
_selected_clientlist_y = e->mouseover.pt.y; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1254 |
if (e->mouseover.pt.y > CLNWND_OFFSET) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1255 |
_selected_clientlist_item = (e->mouseover.pt.y - CLNWND_OFFSET) / CLNWND_ROWSIZE; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1256 |
} else |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1257 |
_selected_clientlist_item = 255; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1258 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1259 |
// Repaint |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1260 |
SetWindowDirty(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1261 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1262 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1263 |
case WE_DESTROY: case WE_CREATE: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1264 |
// When created or destroyed, data is reset |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1265 |
_selected_clientlist_item = 255; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1266 |
_selected_clientlist_y = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1267 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1268 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1269 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1270 |
|
1003
5a1516385ad5
(svn r1502) -Fix: [1101889] Crash under windows... stupid typo in player_gui.c ^ should've been &
darkvater
parents:
982
diff
changeset
|
1271 |
void ShowClientList(void) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1272 |
{ |
1003
5a1516385ad5
(svn r1502) -Fix: [1101889] Crash under windows... stupid typo in player_gui.c ^ should've been &
darkvater
parents:
982
diff
changeset
|
1273 |
Window *w = AllocateWindowDescFront(&_client_list_desc, 0); |
5a1516385ad5
(svn r1502) -Fix: [1101889] Crash under windows... stupid typo in player_gui.c ^ should've been &
darkvater
parents:
982
diff
changeset
|
1274 |
if (w) |
5a1516385ad5
(svn r1502) -Fix: [1101889] Crash under windows... stupid typo in player_gui.c ^ should've been &
darkvater
parents:
982
diff
changeset
|
1275 |
w->window_number = 0; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1276 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1277 |
|
685
c52bdb4cac92
(svn r1126) -Fix: [Network] Pressing Disconnect on the GUI puts you back to the
truelight
parents:
675
diff
changeset
|
1278 |
extern void SwitchMode(int new_mode); |
c52bdb4cac92
(svn r1126) -Fix: [Network] Pressing Disconnect on the GUI puts you back to the
truelight
parents:
675
diff
changeset
|
1279 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1280 |
static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1281 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1282 |
switch(e->event) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1283 |
case WE_PAINT: { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1284 |
uint8 progress; // used for progress bar |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1285 |
DrawWindowWidgets(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1286 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1287 |
DrawStringCentered(125, 35, STR_NETWORK_CONNECTING_1 + _network_join_status, 14); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1288 |
switch (_network_join_status) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1289 |
case NETWORK_JOIN_STATUS_CONNECTING: case NETWORK_JOIN_STATUS_AUTHORIZING: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1290 |
case NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1291 |
progress = 10; // first two stages 10% |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1292 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1293 |
case NETWORK_JOIN_STATUS_WAITING: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1294 |
SetDParam(0, _network_join_waiting); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1295 |
DrawStringCentered(125, 46, STR_NETWORK_CONNECTING_WAITING, 14); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1296 |
progress = 15; // third stage is 15% |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1297 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1298 |
case NETWORK_JOIN_STATUS_DOWNLOADING: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1299 |
SetDParam(0, _network_join_kbytes); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1300 |
SetDParam(1, _network_join_kbytes_total); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1301 |
DrawStringCentered(125, 46, STR_NETWORK_CONNECTING_DOWNLOADING, 14); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1302 |
/* Fallthrough */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1303 |
default: /* Waiting is 15%, so the resting receivement of map is maximum 70% */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1304 |
progress = 15 + _network_join_kbytes * (100 - 15) / _network_join_kbytes_total; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1305 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1306 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1307 |
/* Draw nice progress bar :) */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1308 |
DrawFrameRect(20, 18, (int)((w->width - 20) * progress / 100), 28, 10, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1309 |
} break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1310 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1311 |
case WE_CLICK: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1312 |
switch(e->click.widget) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1313 |
case 0: case 3: /* Close 'X' | Disconnect button */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1314 |
NetworkDisconnect(); |
685
c52bdb4cac92
(svn r1126) -Fix: [Network] Pressing Disconnect on the GUI puts you back to the
truelight
parents:
675
diff
changeset
|
1315 |
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); |
c52bdb4cac92
(svn r1126) -Fix: [Network] Pressing Disconnect on the GUI puts you back to the
truelight
parents:
675
diff
changeset
|
1316 |
SwitchMode(SM_MENU); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1317 |
ShowNetworkGameWindow(); |
0 | 1318 |
break; |
1319 |
} |
|
1320 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1321 |
|
0 | 1322 |
} |
1323 |
} |
|
1324 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1325 |
static const Widget _network_join_status_window_widget[] = { |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1326 |
{ 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:
853
diff
changeset
|
1327 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 249, 0, 13, STR_NETWORK_CONNECTING, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1328 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 249, 14, 84, 0x0,STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1329 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 75, 175, 69, 80, STR_NETWORK_DISCONNECT, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
175
diff
changeset
|
1330 |
{ WIDGETS_END}, |
0 | 1331 |
}; |
1332 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1333 |
static const WindowDesc _network_join_status_window_desc = { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1334 |
WDP_CENTER, WDP_CENTER, 250, 85, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1335 |
WC_NETWORK_STATUS_WINDOW, 0, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1336 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1337 |
_network_join_status_window_widget, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1338 |
NetworkJoinStatusWindowWndProc, |
0 | 1339 |
}; |
1340 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1025
diff
changeset
|
1341 |
void ShowJoinStatusWindow(void) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1342 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1343 |
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1344 |
_network_join_status = NETWORK_JOIN_STATUS_CONNECTING; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1345 |
AllocateWindowDesc(&_network_join_status_window_desc); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1346 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1347 |
|
774
bb9ec520a1b1
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
764
diff
changeset
|
1348 |
void ShowJoinStatusWindowAfterJoin(void) |
670
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1349 |
{ |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1350 |
/* This is a special instant of ShowJoinStatusWindow, because |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1351 |
it is opened after the map is loaded, but the client maybe is not |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1352 |
done registering itself to the server */ |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1353 |
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1354 |
_network_join_status = NETWORK_JOIN_STATUS_REGISTERING; |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1355 |
AllocateWindowDesc(&_network_join_status_window_desc); |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1356 |
} |
0 | 1357 |
|
649 | 1358 |
|
1359 |
||
1360 |
#define MAX_QUERYSTR_LEN 64 |
|
1361 |
||
1362 |
static void ChatWindowWndProc(Window *w, WindowEvent *e) |
|
1363 |
{ |
|
1364 |
static bool closed = false; |
|
1365 |
switch(e->event) { |
|
1366 |
case WE_PAINT: { |
|
1367 |
||
1368 |
DrawWindowWidgets(w); |
|
1369 |
||
1370 |
DrawEditBox(w, 1); |
|
1371 |
} break; |
|
1372 |
||
1373 |
case WE_CLICK: |
|
1374 |
switch(e->click.widget) { |
|
1375 |
case 3: DeleteWindow(w); break; // Cancel |
|
1376 |
case 2: // Send |
|
1377 |
press_ok:; |
|
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1378 |
if (strcmp(WP(w, querystr_d).text.buf, WP(w, querystr_d).text.buf + MAX_QUERYSTR_LEN) == 0) { |
649 | 1379 |
DeleteWindow(w); |
1380 |
} else { |
|
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1381 |
char *buf = WP(w, querystr_d).text.buf; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1382 |
WindowClass wnd_class = WP(w, querystr_d).wnd_class; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1383 |
WindowNumber wnd_num = WP(w, querystr_d).wnd_num; |
649 | 1384 |
Window *parent; |
1385 |
||
1386 |
// Mask the edit-box as closed, so we don't send out a CANCEL |
|
1387 |
closed = true; |
|
1388 |
||
1389 |
DeleteWindow(w); |
|
1390 |
||
1391 |
parent = FindWindowById(wnd_class, wnd_num); |
|
1392 |
if (parent != NULL) { |
|
1393 |
WindowEvent e; |
|
1394 |
e.event = WE_ON_EDIT_TEXT; |
|
1395 |
e.edittext.str = buf; |
|
1396 |
parent->wndproc(parent, &e); |
|
1397 |
} |
|
1398 |
} |
|
1399 |
break; |
|
1400 |
} |
|
1401 |
break; |
|
1402 |
||
1403 |
case WE_MOUSELOOP: { |
|
1404 |
if (!FindWindowById(WP(w,querystr_d).wnd_class, WP(w,querystr_d).wnd_num)) { |
|
1405 |
DeleteWindow(w); |
|
1406 |
return; |
|
1407 |
} |
|
1408 |
HandleEditBox(w, 1); |
|
1409 |
} break; |
|
1410 |
||
1411 |
case WE_KEYPRESS: { |
|
1412 |
switch(HandleEditBoxKey(w, 1, e)) { |
|
1413 |
case 1: // Return |
|
1414 |
goto press_ok; |
|
1415 |
case 2: // Escape |
|
1416 |
DeleteWindow(w); |
|
1417 |
break; |
|
1418 |
} |
|
1419 |
} break; |
|
1420 |
||
1421 |
case WE_CREATE: |
|
1422 |
closed = false; |
|
1423 |
break; |
|
1424 |
||
1425 |
case WE_DESTROY: |
|
1426 |
// If the window is not closed yet, it means it still needs to send a CANCEL |
|
1427 |
if (!closed) { |
|
1428 |
Window *parent = FindWindowById(WP(w,querystr_d).wnd_class, WP(w,querystr_d).wnd_num); |
|
1429 |
if (parent != NULL) { |
|
1430 |
WindowEvent e; |
|
1431 |
e.event = WE_ON_EDIT_TEXT_CANCEL; |
|
1432 |
parent->wndproc(parent, &e); |
|
1433 |
} |
|
1434 |
} |
|
1435 |
break; |
|
1436 |
} |
|
1437 |
} |
|
1438 |
||
1439 |
static const Widget _chat_window_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1440 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 639, 0, 13, 0x0, STR_NULL}, // background |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1441 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 399, 1, 12, 0x0, STR_NULL}, // text box |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1442 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 400, 519, 1, 12, STR_NETWORK_SEND,STR_NULL}, // send button |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1443 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 520, 639, 1, 12, STR_012E_CANCEL, STR_NULL}, // cancel button |
649 | 1444 |
{ WIDGETS_END}, |
1445 |
}; |
|
1446 |
||
1447 |
static const WindowDesc _chat_window_desc = { |
|
1448 |
WDP_CENTER, -26, 640, 14, // x, y, width, height |
|
1449 |
WC_SEND_NETWORK_MSG,0, |
|
1450 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1451 |
_chat_window_widgets, |
|
1452 |
ChatWindowWndProc |
|
1453 |
}; |
|
1454 |
||
1455 |
void ShowChatWindow(StringID str, StringID caption, int maxlen, int maxwidth, byte window_class, uint16 window_number) |
|
1456 |
{ |
|
1457 |
Window *w; |
|
1458 |
||
1459 |
#define _orig_edit_str_buf (_edit_str_buf+MAX_QUERYSTR_LEN) |
|
1460 |
||
1461 |
DeleteWindowById(WC_SEND_NETWORK_MSG, 0); |
|
1462 |
||
1344
9797051fb173
(svn r1848) Remove the obscure feature of initialising the edit box with the contents of str_buffr - it was unused anyway.
tron
parents:
1328
diff
changeset
|
1463 |
GetString(_orig_edit_str_buf, str); |
649 | 1464 |
|
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1465 |
_orig_edit_str_buf[maxlen] = '\0'; |
649 | 1466 |
|
1467 |
memcpy(_edit_str_buf, _orig_edit_str_buf, MAX_QUERYSTR_LEN); |
|
1468 |
||
1469 |
w = AllocateWindowDesc(&_chat_window_desc); |
|
1470 |
||
1471 |
w->click_state = 1 << 1; |
|
1472 |
WP(w,querystr_d).caption = caption; |
|
1473 |
WP(w,querystr_d).wnd_class = window_class; |
|
1474 |
WP(w,querystr_d).wnd_num = window_number; |
|
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1475 |
WP(w,querystr_d).text.caret = false; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1476 |
WP(w,querystr_d).text.maxlength = maxlen - 1; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1477 |
WP(w,querystr_d).text.maxwidth = maxwidth; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1478 |
WP(w,querystr_d).text.buf = _edit_str_buf; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1479 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
649 | 1480 |
} |
1481 |
||
774
bb9ec520a1b1
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
764
diff
changeset
|
1482 |
#else |
bb9ec520a1b1
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
764
diff
changeset
|
1483 |
void ShowJoinStatusWindowAfterJoin(void) {} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1484 |
#endif /* ENABLE_NETWORK */ |