author | Darkvater |
Tue, 17 Oct 2006 23:34:12 +0000 | |
changeset 4880 | aac84a9dcd03 |
parent 4878 | 4d4f76a898fd |
child 4883 | c9c7d15c0b0b |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
4826
6a545d194528
(svn r6750) -Codechange: Juggle around some header includes as they're only used when
Darkvater
parents:
4774
diff
changeset
|
3 |
#ifdef ENABLE_NETWORK |
0 | 4 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1881
diff
changeset
|
5 |
#include "openttd.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
|
6 |
#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
|
7 |
#include "strings.h" |
1363
775a7ee52369
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1344
diff
changeset
|
8 |
#include "table/sprites.h" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
9 |
#include "network.h" |
4261
28670f743746
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4223
diff
changeset
|
10 |
#include "date.h" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
11 |
|
4223
d4c9ef555f43
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4195
diff
changeset
|
12 |
#include "fios.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
228
diff
changeset
|
13 |
#include "table/strings.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2114
diff
changeset
|
14 |
#include "functions.h" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
15 |
#include "network_data.h" |
4013
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
16 |
#include "network_client.h" |
4826
6a545d194528
(svn r6750) -Codechange: Juggle around some header includes as they're only used when
Darkvater
parents:
4774
diff
changeset
|
17 |
#include "network_gui.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
|
18 |
#include "network_gamelist.h" |
0 | 19 |
#include "window.h" |
20 |
#include "gui.h" |
|
21 |
#include "gfx.h" |
|
22 |
#include "command.h" |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
23 |
#include "variables.h" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
24 |
#include "network_server.h" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
25 |
#include "network_udp.h" |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
26 |
#include "settings.h" |
4299
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4286
diff
changeset
|
27 |
#include "string.h" |
4315
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
28 |
#include "town.h" |
0 | 29 |
|
30 |
#define BGC 5 |
|
31 |
#define BTC 15 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
32 |
|
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
33 |
typedef struct network_d { |
3692 | 34 |
PlayerID company; // select company in network lobby |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
35 |
byte field; // select text-field in start-server and game-listing |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
36 |
NetworkGameList *server; // selected server in lobby and game-listing |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
37 |
FiosItem *map; // selected map in start-server |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
38 |
} network_d; |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
39 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(network_d)); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
40 |
|
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
41 |
typedef struct network_ql_d { |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
42 |
network_d n; // see above; general stuff |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
43 |
querystr_d q; // text-input in start-server and game-listing |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
44 |
NetworkGameList **sort_list; // list of games (sorted) |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
45 |
list_d l; // accompanying list-administration |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
46 |
} network_ql_d; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
47 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(network_ql_d)); |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
48 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
49 |
/* Global to remember sorting after window has been closed */ |
4542
f42ecc669275
(svn r6372) -Codechange: static, unneeded decleration in headers, superfluous header includes
Darkvater
parents:
4512
diff
changeset
|
50 |
static Listing _ng_sorting; |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
51 |
|
3470
cd704e52732f
(svn r4315) Remove MAX_QUERYSTR_LEN, rather use lengthof() the real thing
tron
parents:
3469
diff
changeset
|
52 |
static char _edit_str_buf[64]; |
4315
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
53 |
static bool _chat_tab_completion_active; |
3470
cd704e52732f
(svn r4315) Remove MAX_QUERYSTR_LEN, rather use lengthof() the real thing
tron
parents:
3469
diff
changeset
|
54 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
55 |
static void ShowNetworkStartServerWindow(void); |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
56 |
static void ShowNetworkLobbyWindow(NetworkGameList *ngl); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
57 |
extern void SwitchMode(int new_mode); |
0 | 58 |
|
59 |
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
|
60 |
STR_NETWORK_LAN_INTERNET, |
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
61 |
STR_NETWORK_INTERNET_ADVERTISE, |
0 | 62 |
INVALID_STRING_ID |
63 |
}; |
|
64 |
||
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
65 |
static const StringID _lan_internet_types_dropdown[] = { |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
66 |
STR_NETWORK_LAN, |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
67 |
STR_NETWORK_INTERNET, |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
68 |
INVALID_STRING_ID |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
69 |
}; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
70 |
|
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
71 |
static const StringID _players_dropdown[] = { |
2938
3682679a6059
(svn r3494) - Update several languages. Thanks all translators online atm (Bjarni, glx, MeusH, Tron, me, my sister)
Darkvater
parents:
2922
diff
changeset
|
72 |
STR_NETWORK_0_PLAYERS, |
3682679a6059
(svn r3494) - Update several languages. Thanks all translators online atm (Bjarni, glx, MeusH, Tron, me, my sister)
Darkvater
parents:
2922
diff
changeset
|
73 |
STR_NETWORK_1_PLAYERS, |
3682679a6059
(svn r3494) - Update several languages. Thanks all translators online atm (Bjarni, glx, MeusH, Tron, me, my sister)
Darkvater
parents:
2922
diff
changeset
|
74 |
STR_NETWORK_2_PLAYERS, |
3682679a6059
(svn r3494) - Update several languages. Thanks all translators online atm (Bjarni, glx, MeusH, Tron, me, my sister)
Darkvater
parents:
2922
diff
changeset
|
75 |
STR_NETWORK_3_PLAYERS, |
3682679a6059
(svn r3494) - Update several languages. Thanks all translators online atm (Bjarni, glx, MeusH, Tron, me, my sister)
Darkvater
parents:
2922
diff
changeset
|
76 |
STR_NETWORK_4_PLAYERS, |
3682679a6059
(svn r3494) - Update several languages. Thanks all translators online atm (Bjarni, glx, MeusH, Tron, me, my sister)
Darkvater
parents:
2922
diff
changeset
|
77 |
STR_NETWORK_5_PLAYERS, |
3682679a6059
(svn r3494) - Update several languages. Thanks all translators online atm (Bjarni, glx, MeusH, Tron, me, my sister)
Darkvater
parents:
2922
diff
changeset
|
78 |
STR_NETWORK_6_PLAYERS, |
3682679a6059
(svn r3494) - Update several languages. Thanks all translators online atm (Bjarni, glx, MeusH, Tron, me, my sister)
Darkvater
parents:
2922
diff
changeset
|
79 |
STR_NETWORK_7_PLAYERS, |
3682679a6059
(svn r3494) - Update several languages. Thanks all translators online atm (Bjarni, glx, MeusH, Tron, me, my sister)
Darkvater
parents:
2922
diff
changeset
|
80 |
STR_NETWORK_8_PLAYERS, |
3682679a6059
(svn r3494) - Update several languages. Thanks all translators online atm (Bjarni, glx, MeusH, Tron, me, my sister)
Darkvater
parents:
2922
diff
changeset
|
81 |
STR_NETWORK_9_PLAYERS, |
3682679a6059
(svn r3494) - Update several languages. Thanks all translators online atm (Bjarni, glx, MeusH, Tron, me, my sister)
Darkvater
parents:
2922
diff
changeset
|
82 |
STR_NETWORK_10_PLAYERS, |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
83 |
INVALID_STRING_ID |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
84 |
}; |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
85 |
|
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
86 |
static const StringID _language_dropdown[] = { |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
87 |
STR_NETWORK_LANG_ANY, |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
88 |
STR_NETWORK_LANG_ENGLISH, |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
89 |
STR_NETWORK_LANG_GERMAN, |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
90 |
STR_NETWORK_LANG_FRENCH, |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
91 |
INVALID_STRING_ID |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
92 |
}; |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
93 |
|
211 | 94 |
enum { |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
95 |
NET_PRC__OFFSET_TOP_WIDGET = 54, |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
96 |
NET_PRC__OFFSET_TOP_WIDGET_COMPANY = 52, |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
97 |
NET_PRC__SIZE_OF_ROW = 14, |
211 | 98 |
}; |
99 |
||
897
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
100 |
// 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
|
101 |
void UpdateNetworkGameWindow(bool unselect) |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
102 |
{ |
4880
aac84a9dcd03
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
103 |
Window *w = FindWindowById(WC_NETWORK_WINDOW, 0); |
2639 | 104 |
|
897
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
105 |
if (w != NULL) { |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
106 |
if (unselect) WP(w, network_ql_d).n.server = NULL; |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
107 |
SendWindowMessage(WC_NETWORK_WINDOW, 0, true, 0, 0); |
897
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
108 |
} |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
109 |
} |
076a21cc614a
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
110 |
|
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
111 |
static bool _internal_sort_order; // Used for Qsort order-flipping |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
112 |
typedef int CDECL NGameNameSortFunction(const void*, const void*); |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
113 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
114 |
/** Qsort function to sort by name. */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
115 |
static int CDECL NGameNameSorter(const void *a, const void *b) |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
116 |
{ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
117 |
const NetworkGameList *cmp1 = *(const NetworkGameList**)a; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
118 |
const NetworkGameList *cmp2 = *(const NetworkGameList**)b; |
2889
461c25e6cc1b
(svn r3442) - Fix: Only windows has stricmp. So define strcasecmp to stricmp when using MSVC
Darkvater
parents:
2888
diff
changeset
|
119 |
int r = strcasecmp(cmp1->info.server_name, cmp2->info.server_name); |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
120 |
|
4880
aac84a9dcd03
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
121 |
return _internal_sort_order ? -r : r; |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
122 |
} |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
123 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
124 |
/** Qsort function to sort by the amount of clients online on a |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
125 |
* server. If the two servers have the same amount, the one with the |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
126 |
* higher maximum is preferred. */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
127 |
static int CDECL NGameClientSorter(const void *a, const void *b) |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
128 |
{ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
129 |
const NetworkGameList *cmp1 = *(const NetworkGameList**)a; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
130 |
const NetworkGameList *cmp2 = *(const NetworkGameList**)b; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
131 |
/* Reverse as per default we are interested in most-clients first */ |
4195
600bd419c335
(svn r5655) -Fix [SF 1424115]: Reversed arrow-sign in the multiplayer list column headers on sort by name
Darkvater
parents:
4171
diff
changeset
|
132 |
int r = cmp1->info.clients_on - cmp2->info.clients_on; |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
133 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
134 |
if (r == 0) r = cmp1->info.clients_max - cmp2->info.clients_max; |
2922
9eb5d9c8f78f
(svn r3478) - Fix: In the network game list do the default sorting on connectivity (so servers which you can join are on top) and sort on names as a second criteria on clients and connectivity.
Darkvater
parents:
2914
diff
changeset
|
135 |
if (r == 0) r = strcasecmp(cmp1->info.server_name, cmp2->info.server_name); |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
136 |
|
4880
aac84a9dcd03
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
137 |
return _internal_sort_order ? -r : r; |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
138 |
} |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
139 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
140 |
/** Qsort function to sort by joinability. If both servers are the |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
141 |
* same, prefer the non-passworded server first. */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
142 |
static int CDECL NGameAllowedSorter(const void *a, const void *b) |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
143 |
{ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
144 |
const NetworkGameList *cmp1 = *(const NetworkGameList**)a; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
145 |
const NetworkGameList *cmp2 = *(const NetworkGameList**)b; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
146 |
/* Reverse default as we are interested in compatible clients first */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
147 |
int r = cmp2->info.compatible - cmp1->info.compatible; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
148 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
149 |
if (r == 0) r = cmp1->info.use_password - cmp2->info.use_password; |
2922
9eb5d9c8f78f
(svn r3478) - Fix: In the network game list do the default sorting on connectivity (so servers which you can join are on top) and sort on names as a second criteria on clients and connectivity.
Darkvater
parents:
2914
diff
changeset
|
150 |
if (r == 0) r = strcasecmp(cmp1->info.server_name, cmp2->info.server_name); |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
151 |
|
4880
aac84a9dcd03
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
152 |
return _internal_sort_order ? -r : r; |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
153 |
} |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
154 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
155 |
/** (Re)build the network game list as its amount has changed because |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
156 |
* an item has been added or deleted for example |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
157 |
* @param ngl list_d struct that contains all necessary information for sorting */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
158 |
static void BuildNetworkGameList(network_ql_d *nqld) |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
159 |
{ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
160 |
NetworkGameList *ngl_temp; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
161 |
uint n = 0; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
162 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
163 |
if (!(nqld->l.flags & VL_REBUILD)) return; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
164 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
165 |
/* Count the number of games in the list */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
166 |
for (ngl_temp = _network_game_list; ngl_temp != NULL; ngl_temp = ngl_temp->next) n++; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
167 |
if (n == 0) return; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
168 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
169 |
/* Create temporary array of games to use for listing */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
170 |
free(nqld->sort_list); |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
171 |
nqld->sort_list = malloc(n * sizeof(nqld->sort_list[0])); |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
172 |
if (nqld->sort_list == NULL) error("Could not allocate memory for the network-game-sorting-list"); |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
173 |
nqld->l.list_length = n; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
174 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
175 |
for (n = 0, ngl_temp = _network_game_list; ngl_temp != NULL; ngl_temp = ngl_temp->next) { |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
176 |
nqld->sort_list[n++] = ngl_temp; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
177 |
} |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
178 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
179 |
/* Force resort */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
180 |
nqld->l.flags &= ~VL_REBUILD; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
181 |
nqld->l.flags |= VL_RESORT; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
182 |
} |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
183 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
184 |
static void SortNetworkGameList(network_ql_d *nqld) |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
185 |
{ |
4171 | 186 |
static NGameNameSortFunction * const ngame_sorter[] = { |
3860
af1e59c127ac
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
187 |
&NGameNameSorter, |
af1e59c127ac
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
188 |
&NGameClientSorter, |
af1e59c127ac
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
189 |
&NGameAllowedSorter |
af1e59c127ac
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
190 |
}; |
af1e59c127ac
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
191 |
|
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
192 |
NetworkGameList *item; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
193 |
uint i; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
194 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
195 |
if (!(nqld->l.flags & VL_RESORT)) return; |
3860
af1e59c127ac
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
196 |
if (nqld->l.list_length == 0) return; |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
197 |
|
4880
aac84a9dcd03
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
198 |
_internal_sort_order = !!(nqld->l.flags & VL_DESC); |
3860
af1e59c127ac
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
199 |
qsort(nqld->sort_list, nqld->l.list_length, sizeof(nqld->sort_list[0]), ngame_sorter[nqld->l.sort_type]); |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
200 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
201 |
/* After sorting ngl->sort_list contains the sorted items. Put these back |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
202 |
* into the original list. Basically nothing has changed, we are only |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
203 |
* shuffling the ->next pointers */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
204 |
_network_game_list = nqld->sort_list[0]; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
205 |
for (item = _network_game_list, i = 1; i != nqld->l.list_length; i++) { |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
206 |
item->next = nqld->sort_list[i]; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
207 |
item = item->next; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
208 |
} |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
209 |
item->next = NULL; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
210 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
211 |
nqld->l.flags &= ~VL_RESORT; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
212 |
} |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
213 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
214 |
/* Uses network_ql_d (network_d, querystr_d and list_d) WP macro */ |
0 | 215 |
static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) |
216 |
{ |
|
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
217 |
network_d *nd = &WP(w, network_ql_d).n; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
218 |
list_d *ld = &WP(w, network_ql_d).l; |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
219 |
|
1653
d2db1ba2abde
(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
Darkvater
parents:
1648
diff
changeset
|
220 |
switch (e->event) { |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
221 |
case WE_CREATE: /* Focus input box */ |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
222 |
nd->field = 3; |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
223 |
nd->server = NULL; |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
224 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
225 |
WP(w, network_ql_d).sort_list = NULL; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
226 |
ld->flags = VL_REBUILD | (_ng_sorting.order << (VL_DESC - 1)); |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
227 |
ld->sort_type = _ng_sorting.criteria; |
1653
d2db1ba2abde
(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
Darkvater
parents:
1648
diff
changeset
|
228 |
break; |
2630 | 229 |
|
0 | 230 |
case WE_PAINT: { |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
231 |
const NetworkGameList *sel = nd->server; |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
232 |
const char *arrow = (ld->flags & VL_DESC) ? DOWNARROW : UPARROW; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
233 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
234 |
if (ld->flags & VL_REBUILD) { |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
235 |
BuildNetworkGameList(&WP(w, network_ql_d)); |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
236 |
SetVScrollCount(w, ld->list_length); |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
237 |
} |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
238 |
if (ld->flags & VL_RESORT) SortNetworkGameList(&WP(w, network_ql_d)); |
2071
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
239 |
|
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
240 |
SetWindowWidgetDisabledState(w, 17, sel == NULL); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
241 |
/* Join Button disabling conditions */ |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
242 |
SetWindowWidgetDisabledState(w, 16, sel == NULL || // no Selected Server |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
243 |
!sel->online || // Server offline |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
244 |
sel->info.clients_on >= sel->info.clients_max || // Server full |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
245 |
!sel->info.compatible); // Revision mismatch |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
246 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
247 |
SetDParam(0, 0x00); |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
248 |
SetDParam(7, _lan_internet_types_dropdown[_network_lan_internet]); |
0 | 249 |
DrawWindowWidgets(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
250 |
|
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
251 |
DrawEditBox(w, &WP(w, network_ql_d).q, 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
252 |
|
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
253 |
DrawString(9, 23, STR_NETWORK_CONNECTION, 2); |
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
254 |
DrawString(210, 23, STR_NETWORK_PLAYER_NAME, 2); |
0 | 255 |
|
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
256 |
/* Sort based on widgets: name, clients, compatibility */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
257 |
switch (ld->sort_type) { |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
258 |
case 6 - 6: DoDrawString(arrow, w->widget[6].right - 10, 42, 0x10); break; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
259 |
case 7 - 6: DoDrawString(arrow, w->widget[7].right - 10, 42, 0x10); break; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
260 |
case 8 - 6: DoDrawString(arrow, w->widget[8].right - 10, 42, 0x10); break; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
261 |
} |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
262 |
|
211 | 263 |
{ // draw list of games |
264 |
uint16 y = NET_PRC__OFFSET_TOP_WIDGET + 3; |
|
265 |
int32 n = 0; |
|
809
e275914bfd14
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
266 |
int32 pos = w->vscroll.pos; |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
267 |
uint max_name_width = w->widget[6].right - w->widget[6].left - 5; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
268 |
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
|
269 |
|
e275914bfd14
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
270 |
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
|
271 |
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
|
272 |
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
|
273 |
} |
809
e275914bfd14
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
274 |
|
211 | 275 |
while (cur_item != NULL) { |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
276 |
// show highlighted item with a different colour |
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
277 |
if (cur_item == sel) GfxFillRect(w->widget[6].left + 1, y - 2, w->widget[8].right - 1, y + 9, 10); |
211 | 278 |
|
2100
217ea6fdfd18
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2071
diff
changeset
|
279 |
SetDParamStr(0, cur_item->info.server_name); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
280 |
DrawStringTruncated(w->widget[6].left + 5, y, STR_02BD, 16, max_name_width); |
211 | 281 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
282 |
SetDParam(0, cur_item->info.clients_on); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
283 |
SetDParam(1, cur_item->info.clients_max); |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
284 |
SetDParam(2, cur_item->info.companies_on); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
285 |
SetDParam(3, cur_item->info.companies_max); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
286 |
DrawStringCentered(210, y, STR_NETWORK_GENERAL_ONLINE, 2); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
287 |
|
579
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
288 |
// 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
|
289 |
if (cur_item->online) { |
579
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
290 |
// draw a lock if the server is password protected. |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
291 |
if (cur_item->info.use_password) DrawSprite(SPR_LOCK, w->widget[8].left + 5, y - 1); |
591
b4c4386318e5
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
292 |
|
579
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
293 |
// draw red or green icon, depending on compatibility with server. |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
294 |
DrawSprite(SPR_BLOT | (cur_item->info.compatible ? PALETTE_TO_GREEN : PALETTE_TO_RED), w->widget[8].left + 15, y); |
591
b4c4386318e5
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
295 |
|
579
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
296 |
// draw flag according to server language |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
297 |
DrawSprite(SPR_FLAGS_BASE + cur_item->info.server_lang, w->widget[8].left + 25, y); |
579
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
298 |
} |
591
b4c4386318e5
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
299 |
|
b4c4386318e5
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
300 |
cur_item = cur_item->next; |
b4c4386318e5
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
301 |
y += NET_PRC__SIZE_OF_ROW; |
2549 | 302 |
if (++n == w->vscroll.cap) break; // max number of games in the window |
211 | 303 |
} |
304 |
} |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
305 |
|
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
306 |
/* Draw the right menu */ |
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
307 |
GfxFillRect(311, 43, 539, 92, 157); |
2071
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
308 |
if (sel == NULL) { |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
309 |
DrawStringMultiCenter(425, 58, STR_NETWORK_GAME_INFO, 0); |
2071
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
310 |
} else if (!sel->online) { |
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
311 |
SetDParamStr(0, sel->info.server_name); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
312 |
DrawStringMultiCenter(425, 68, STR_ORANGE, 2); // game name |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
313 |
|
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
314 |
DrawStringMultiCenter(425, 132, STR_NETWORK_SERVER_OFFLINE, 2); // server offline |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
315 |
} else { // show game info |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
316 |
uint16 y = 100; |
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
317 |
const uint16 x = w->widget[15].left + 5; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
318 |
|
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
319 |
DrawStringMultiCenter(425, 48, STR_NETWORK_GAME_INFO, 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
320 |
|
2055
4926ed1a7562
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
1916
diff
changeset
|
321 |
|
2071
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
322 |
SetDParamStr(0, sel->info.server_name); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
323 |
DrawStringCenteredTruncated(w->widget[15].left, w->widget[15].right, 62, STR_ORANGE, 16); // game name |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
324 |
|
2071
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
325 |
SetDParamStr(0, sel->info.map_name); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
326 |
DrawStringCenteredTruncated(w->widget[15].left, w->widget[15].right, 74, STR_02BD, 16); // map name |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
327 |
|
2071
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
328 |
SetDParam(0, sel->info.clients_on); |
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
329 |
SetDParam(1, sel->info.clients_max); |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
330 |
SetDParam(2, sel->info.companies_on); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
331 |
SetDParam(3, sel->info.companies_max); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
332 |
DrawString(x, y, STR_NETWORK_CLIENTS, 2); |
2639 | 333 |
y += 10; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
334 |
|
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
335 |
SetDParam(0, _language_dropdown[sel->info.server_lang]); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
336 |
DrawString(x, y, STR_NETWORK_LANGUAGE, 2); // server language |
2639 | 337 |
y += 10; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
338 |
|
2775
a18db0ab5e51
(svn r3322) - Fix: Network window crash when it receives invalid information for example from the integrated nightly, so validate the network-input when it is received
Darkvater
parents:
2753
diff
changeset
|
339 |
SetDParam(0, STR_TEMPERATE_LANDSCAPE + sel->info.map_set); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
340 |
DrawString(x, y, STR_NETWORK_TILESET, 2); // tileset |
2639 | 341 |
y += 10; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
342 |
|
2071
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
343 |
SetDParam(0, sel->info.map_width); |
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
344 |
SetDParam(1, sel->info.map_height); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
345 |
DrawString(x, y, STR_NETWORK_MAP_SIZE, 2); // map size |
2639 | 346 |
y += 10; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
347 |
|
2071
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
348 |
SetDParamStr(0, sel->info.server_revision); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
349 |
DrawString(x, y, STR_NETWORK_SERVER_VERSION, 2); // server version |
2639 | 350 |
y += 10; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
351 |
|
2071
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
352 |
SetDParamStr(0, sel->info.hostname); |
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
353 |
SetDParam(1, sel->port); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
354 |
DrawString(x, y, STR_NETWORK_SERVER_ADDRESS, 2); // server address |
2639 | 355 |
y += 10; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
356 |
|
2071
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
357 |
SetDParam(0, sel->info.start_date); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
358 |
DrawString(x, y, STR_NETWORK_START_DATE, 2); // start date |
2639 | 359 |
y += 10; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
360 |
|
2071
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
361 |
SetDParam(0, sel->info.game_date); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
362 |
DrawString(x, y, STR_NETWORK_CURRENT_DATE, 2); // current date |
2639 | 363 |
y += 10; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
364 |
|
2639 | 365 |
y += 2; |
622
19e529637d18
(svn r1052) -Fix: [Network] You can't join a server when revision mismatches.
truelight
parents:
621
diff
changeset
|
366 |
|
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
367 |
if (!sel->info.compatible) { |
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
368 |
DrawStringMultiCenter(425, y, STR_NETWORK_VERSION_MISMATCH, 2); // server mismatch |
2071
3083c580f4dc
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
369 |
} else if (sel->info.clients_on == sel->info.clients_max) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
370 |
// Show: server full, when clients_on == clients_max |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
371 |
DrawStringMultiCenter(425, y, STR_NETWORK_SERVER_FULL, 2); // server full |
2639 | 372 |
} else if (sel->info.use_password) { |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
373 |
DrawStringMultiCenter(425, y, STR_NETWORK_PASSWORD, 2); // password warning |
2639 | 374 |
} |
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
|
375 |
|
2639 | 376 |
y += 10; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
377 |
} |
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
|
378 |
} break; |
0 | 379 |
|
380 |
case WE_CLICK: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
381 |
nd->field = e->we.click.widget; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
382 |
switch (e->we.click.widget) { |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
383 |
case 0: case 14: /* Close 'X' | Cancel button */ |
0 | 384 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
385 |
break; |
|
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
386 |
case 4: case 5: |
842 | 387 |
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
|
388 |
break; |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
389 |
case 6: /* Sort by name */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
390 |
case 7: /* Sort by connected clients */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
391 |
case 8: /* Connectivity (green dot) */ |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
392 |
if (ld->sort_type == e->we.click.widget - 6) ld->flags ^= VL_DESC; |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
393 |
ld->flags |= VL_RESORT; |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
394 |
ld->sort_type = e->we.click.widget - 6; |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
395 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
396 |
_ng_sorting.order = !!(ld->flags & VL_DESC); |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
397 |
_ng_sorting.criteria = ld->sort_type; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
398 |
SetWindowDirty(w); |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
399 |
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
|
400 |
case 9: { /* Matrix to show networkgames */ |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
401 |
NetworkGameList *cur_item; |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
402 |
uint32 id_v = (e->we.click.pt.y - NET_PRC__OFFSET_TOP_WIDGET) / NET_PRC__SIZE_OF_ROW; |
211 | 403 |
|
2549 | 404 |
if (id_v >= w->vscroll.cap) return; // click out of bounds |
211 | 405 |
id_v += w->vscroll.pos; |
406 |
||
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
407 |
cur_item = _network_game_list; |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
408 |
for (; id_v > 0 && cur_item != NULL; id_v--) cur_item = cur_item->next; |
211 | 409 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
410 |
nd->server = cur_item; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
411 |
SetWindowDirty(w); |
211 | 412 |
} break; |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
413 |
case 11: /* Find server automatically */ |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
414 |
switch (_network_lan_internet) { |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
415 |
case 0: NetworkUDPSearchGame(); break; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
416 |
case 1: NetworkUDPQueryMasterServer(); break; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
417 |
} |
211 | 418 |
break; |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
419 |
case 12: { // Add a server |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
420 |
ShowQueryString( |
2055
4926ed1a7562
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
1916
diff
changeset
|
421 |
BindCString(_network_default_ip), |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
422 |
STR_NETWORK_ENTER_IP, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
423 |
31 | 0x1000, // maximum number of characters OR |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
424 |
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
|
425 |
w->window_class, |
4299
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4286
diff
changeset
|
426 |
w->window_number, CS_ALPHANUMERAL); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
427 |
} break; |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
428 |
case 13: /* Start server */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
429 |
ShowNetworkStartServerWindow(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
430 |
break; |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
431 |
case 16: /* Join Game */ |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
432 |
if (nd->server != NULL) { |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
433 |
snprintf(_network_last_host, sizeof(_network_last_host), "%s", inet_ntoa(*(struct in_addr *)&nd->server->ip)); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
434 |
_network_last_port = nd->server->port; |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
435 |
ShowNetworkLobbyWindow(nd->server); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
436 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
437 |
break; |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
438 |
case 17: // Refresh |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
439 |
if (nd->server != NULL) |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
440 |
NetworkQueryServer(nd->server->info.hostname, nd->server->port, true); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
441 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
442 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
443 |
} 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
|
444 |
|
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
445 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
446 |
switch (e->we.dropdown.button) { |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
447 |
case 5: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
448 |
_network_lan_internet = e->we.dropdown.index; |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
449 |
break; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
450 |
} |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
451 |
|
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
452 |
SetWindowDirty(w); |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
453 |
break; |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
454 |
|
0 | 455 |
case WE_MOUSELOOP: |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
456 |
if (nd->field == 3) HandleEditBox(w, &WP(w, network_ql_d).q, 3); |
0 | 457 |
break; |
458 |
||
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
459 |
case WE_MESSAGE: |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
460 |
ld->flags |= VL_REBUILD; |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
461 |
SetWindowDirty(w); |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
462 |
break; |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
463 |
|
0 | 464 |
case WE_KEYPRESS: |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
465 |
if (nd->field != 3) { |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
466 |
if (nd->server != NULL) { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
467 |
if (e->we.keypress.keycode == WKC_DELETE) { /* Press 'delete' to remove servers */ |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
468 |
NetworkGameListRemoveItem(nd->server); |
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
|
469 |
NetworkRebuildHostList(); |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
470 |
nd->server = 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
|
471 |
} |
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
|
472 |
} |
741
422ce499322b
(svn r1197) -Fix: [GUI] in r1194 someone deleted too much code from WE_KEYPRESS. Now
truelight
parents:
738
diff
changeset
|
473 |
break; |
422ce499322b
(svn r1197) -Fix: [GUI] in r1194 someone deleted too much code from WE_KEYPRESS. Now
truelight
parents:
738
diff
changeset
|
474 |
} |
422ce499322b
(svn r1197) -Fix: [GUI] in r1194 someone deleted too much code from WE_KEYPRESS. Now
truelight
parents:
738
diff
changeset
|
475 |
|
4299
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4286
diff
changeset
|
476 |
if (HandleEditBoxKey(w, &WP(w, network_ql_d).q, 3, e, CS_ALPHANUMERAL) == 1) break; // enter pressed |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
477 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
478 |
// The name is only allowed when it starts with a letter! |
2639 | 479 |
if (_edit_str_buf[0] != '\0' && _edit_str_buf[0] != ' ') { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
480 |
ttd_strlcpy(_network_player_name, _edit_str_buf, lengthof(_network_player_name)); |
2639 | 481 |
} else { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
482 |
ttd_strlcpy(_network_player_name, "Player", lengthof(_network_player_name)); |
2639 | 483 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
484 |
|
0 | 485 |
break; |
486 |
||
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
487 |
case WE_ON_EDIT_TEXT: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
488 |
NetworkAddServer(e->we.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
|
489 |
NetworkRebuildHostList(); |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
490 |
break; |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
491 |
|
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
492 |
case WE_DESTROY: /* Nicely clean up the sort-list */ |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
493 |
free(WP(w, network_ql_d).sort_list); |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
494 |
break; |
0 | 495 |
} |
496 |
} |
|
497 |
||
498 |
static const Widget _network_game_window_widgets[] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
499 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
500 |
{ WWT_CAPTION, RESIZE_NONE, BGC, 11, 549, 0, 13, STR_NETWORK_MULTIPLAYER, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
501 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 0, 549, 14, 249, STR_NULL, STR_NULL}, |
0 | 502 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
503 |
/* LEFT SIDE */ |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
504 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 310, 461, 22, 33, STR_NULL, STR_NETWORK_ENTER_NAME_TIP}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
505 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
506 |
{ WWT_6, RESIZE_NONE, BGC, 90, 181, 22, 33, STR_NETWORK_COMBO1, STR_NETWORK_CONNECTION_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
507 |
{ WWT_TEXTBTN, RESIZE_NONE, BGC, 170, 180, 23, 32, STR_0225, STR_NETWORK_CONNECTION_TIP}, |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
508 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
509 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 10, 170, 42, 53, STR_NETWORK_GAME_NAME, STR_NETWORK_GAME_NAME_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
510 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 171, 250, 42, 53, STR_NETWORK_CLIENTS_CAPTION, STR_NETWORK_CLIENTS_CAPTION_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
511 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 251, 290, 42, 53, STR_EMPTY, STR_NETWORK_INFO_ICONS_TIP}, |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
512 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
513 |
{ WWT_MATRIX, RESIZE_NONE, BGC, 10, 290, 54, 222, (12 << 8) + 1, STR_NETWORK_CLICK_GAME_TO_SELECT}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
514 |
{ WWT_SCROLLBAR, RESIZE_NONE, BGC, 291, 302, 42, 222, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
515 |
|
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
516 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 30, 130, 232, 243, STR_NETWORK_FIND_SERVER, STR_NETWORK_FIND_SERVER_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
517 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 180, 280, 232, 243, STR_NETWORK_ADD_SERVER, STR_NETWORK_ADD_SERVER_TIP}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
518 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
519 |
/* RIGHT SIDE */ |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
520 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 315, 415, 232, 243, STR_NETWORK_START_SERVER, STR_NETWORK_START_SERVER_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
521 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 430, 535, 232, 243, STR_012E_CANCEL, STR_NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
522 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
523 |
{ WWT_PANEL, RESIZE_NONE, BGC, 310, 540, 42, 222, STR_NULL, STR_NULL}, |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
524 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
525 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 315, 415, 201, 212, STR_NETWORK_JOIN_GAME, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
526 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 430, 535, 201, 212, STR_NETWORK_REFRESH, STR_NETWORK_REFRESH_TIP}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
527 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
175
diff
changeset
|
528 |
{ WIDGETS_END}, |
0 | 529 |
}; |
530 |
||
531 |
static const WindowDesc _network_game_window_desc = { |
|
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
532 |
WDP_CENTER, WDP_CENTER, 550, 250, |
0 | 533 |
WC_NETWORK_WINDOW,0, |
2064
e6a2b42d0b15
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2055
diff
changeset
|
534 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
0 | 535 |
_network_game_window_widgets, |
536 |
NetworkGameWindowWndProc, |
|
537 |
}; |
|
538 |
||
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
|
539 |
void ShowNetworkGameWindow(void) |
0 | 540 |
{ |
2922
9eb5d9c8f78f
(svn r3478) - Fix: In the network game list do the default sorting on connectivity (so servers which you can join are on top) and sort on names as a second criteria on clients and connectivity.
Darkvater
parents:
2914
diff
changeset
|
541 |
static bool first = true; |
0 | 542 |
Window *w; |
543 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
|
105 | 544 |
|
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
545 |
/* Only show once */ |
2922
9eb5d9c8f78f
(svn r3478) - Fix: In the network game list do the default sorting on connectivity (so servers which you can join are on top) and sort on names as a second criteria on clients and connectivity.
Darkvater
parents:
2914
diff
changeset
|
546 |
if (first) { |
2885
fc5297214b36
(svn r3435) - Fix a warning, removed unused extern and some comments in network_gamelist.c
Darkvater
parents:
2884
diff
changeset
|
547 |
char* const *srv; |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
548 |
|
2922
9eb5d9c8f78f
(svn r3478) - Fix: In the network game list do the default sorting on connectivity (so servers which you can join are on top) and sort on names as a second criteria on clients and connectivity.
Darkvater
parents:
2914
diff
changeset
|
549 |
first = false; |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
550 |
// add all servers from the config file to our list |
2885
fc5297214b36
(svn r3435) - Fix a warning, removed unused extern and some comments in network_gamelist.c
Darkvater
parents:
2884
diff
changeset
|
551 |
for (srv = &_network_host_list[0]; srv != endof(_network_host_list) && *srv != NULL; srv++) { |
2881
ade9a553be53
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
552 |
NetworkAddServer(*srv); |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
553 |
} |
2922
9eb5d9c8f78f
(svn r3478) - Fix: In the network game list do the default sorting on connectivity (so servers which you can join are on top) and sort on names as a second criteria on clients and connectivity.
Darkvater
parents:
2914
diff
changeset
|
554 |
|
9eb5d9c8f78f
(svn r3478) - Fix: In the network game list do the default sorting on connectivity (so servers which you can join are on top) and sort on names as a second criteria on clients and connectivity.
Darkvater
parents:
2914
diff
changeset
|
555 |
_ng_sorting.criteria = 2; // sort default by collectivity (green-dots on top) |
9eb5d9c8f78f
(svn r3478) - Fix: In the network game list do the default sorting on connectivity (so servers which you can join are on top) and sort on names as a second criteria on clients and connectivity.
Darkvater
parents:
2914
diff
changeset
|
556 |
_ng_sorting.order = 0; // sort ascending by default |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
557 |
} |
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
558 |
|
0 | 559 |
w = AllocateWindowDesc(&_network_game_window_desc); |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
560 |
if (w != NULL) { |
4171 | 561 |
querystr_d *querystr = &WP(w, network_ql_d).q; |
3470
cd704e52732f
(svn r4315) Remove MAX_QUERYSTR_LEN, rather use lengthof() the real thing
tron
parents:
3469
diff
changeset
|
562 |
|
cd704e52732f
(svn r4315) Remove MAX_QUERYSTR_LEN, rather use lengthof() the real thing
tron
parents:
3469
diff
changeset
|
563 |
ttd_strlcpy(_edit_str_buf, _network_player_name, lengthof(_edit_str_buf)); |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
564 |
w->vscroll.cap = 12; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
565 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
566 |
querystr->text.caret = true; |
3470
cd704e52732f
(svn r4315) Remove MAX_QUERYSTR_LEN, rather use lengthof() the real thing
tron
parents:
3469
diff
changeset
|
567 |
querystr->text.maxlength = lengthof(_edit_str_buf); |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
568 |
querystr->text.maxwidth = 120; |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
569 |
querystr->text.buf = _edit_str_buf; |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
570 |
UpdateTextBufferSize(&querystr->text); |
0 | 571 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
572 |
UpdateNetworkGameWindow(true); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
573 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
574 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
575 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
576 |
enum { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
577 |
NSSWND_START = 64, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
578 |
NSSWND_ROWSIZE = 12 |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
579 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
580 |
|
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
581 |
/* Uses network_ql_d (network_d, querystr_d and list_d) WP macro */ |
0 | 582 |
static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e) |
583 |
{ |
|
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
584 |
network_d *nd = &WP(w, network_ql_d).n; |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
585 |
|
1653
d2db1ba2abde
(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
Darkvater
parents:
1648
diff
changeset
|
586 |
switch (e->event) { |
d2db1ba2abde
(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
Darkvater
parents:
1648
diff
changeset
|
587 |
case WE_CREATE: /* focus input box */ |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
588 |
nd->field = 3; |
1899
81214598ab45
(svn r2405) Simplify a few '? true : false' and '? false : true', especially the latter is confusing
tron
parents:
1891
diff
changeset
|
589 |
_network_game_info.use_password = (_network_server_password[0] != '\0'); |
1653
d2db1ba2abde
(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
Darkvater
parents:
1648
diff
changeset
|
590 |
break; |
d2db1ba2abde
(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
Darkvater
parents:
1648
diff
changeset
|
591 |
|
0 | 592 |
case WE_PAINT: { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
593 |
int y = NSSWND_START, pos; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
594 |
const FiosItem *item; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
595 |
|
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
596 |
SetDParam( 7, _connection_types_dropdown[_network_advertise]); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
597 |
SetDParam( 9, _players_dropdown[_network_game_info.clients_max]); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
598 |
SetDParam(11, _players_dropdown[_network_game_info.companies_max]); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
599 |
SetDParam(13, _players_dropdown[_network_game_info.spectators_max]); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
600 |
SetDParam(15, _language_dropdown[_network_game_info.server_lang]); |
0 | 601 |
DrawWindowWidgets(w); |
602 |
||
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
603 |
GfxFillRect(11, 63, 258, 215, 0xD7); |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
604 |
DrawEditBox(w, &WP(w, network_ql_d).q, 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
605 |
|
0 | 606 |
DrawString(10, 22, STR_NETWORK_NEW_GAME_NAME, 2); |
607 |
||
608 |
DrawString(10, 43, STR_NETWORK_SELECT_MAP, 2); |
|
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
609 |
|
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
610 |
DrawString(280, 63, STR_NETWORK_CONNECTION, 2); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
611 |
DrawString(280, 95, STR_NETWORK_NUMBER_OF_CLIENTS, 2); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
612 |
DrawString(280, 127, STR_NETWORK_NUMBER_OF_COMPANIES, 2); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
613 |
DrawString(280, 159, STR_NETWORK_NUMBER_OF_SPECTATORS, 2); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
614 |
DrawString(280, 191, STR_NETWORK_LANGUAGE_SPOKEN, 2); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
615 |
|
1653
d2db1ba2abde
(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
Darkvater
parents:
1648
diff
changeset
|
616 |
if (_network_game_info.use_password) DoDrawString("*", 408, 23, 3); |
d2db1ba2abde
(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
Darkvater
parents:
1648
diff
changeset
|
617 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
618 |
// draw list of maps |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
619 |
pos = w->vscroll.pos; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
620 |
while (pos < _fios_num + 1) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
621 |
item = _fios_list + pos - 1; |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
622 |
if (item == nd->map || (pos == 0 && nd->map == NULL)) |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
623 |
GfxFillRect(11, y - 1, 258, 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
|
624 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
625 |
if (pos == 0) { |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
626 |
DrawString(14, y, STR_4010_GENERATE_RANDOM_NEW_GAME, 9); |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
627 |
} else { |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
628 |
DoDrawString(item->title, 14, y, _fios_colors[item->type] ); |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
629 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
630 |
pos++; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
631 |
y += NSSWND_ROWSIZE; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
632 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
633 |
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
|
634 |
} |
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
|
635 |
} break; |
0 | 636 |
|
637 |
case WE_CLICK: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
638 |
nd->field = e->we.click.widget; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
639 |
switch (e->we.click.widget) { |
2639 | 640 |
case 0: /* Close 'X' */ |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
641 |
case 19: /* Cancel button */ |
0 | 642 |
ShowNetworkGameWindow(); |
643 |
break; |
|
2639 | 644 |
|
645 |
case 4: /* Set password button */ |
|
2055
4926ed1a7562
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
1916
diff
changeset
|
646 |
ShowQueryString(BindCString(_network_server_password), |
4299
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4286
diff
changeset
|
647 |
STR_NETWORK_SET_PASSWORD, 20, 250, w->window_class, w->window_number, CS_ALPHANUMERAL); |
2639 | 648 |
break; |
649 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
650 |
case 5: { /* Select map */ |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
651 |
int y = (e->we.click.pt.y - NSSWND_START) / NSSWND_ROWSIZE; |
2639 | 652 |
|
653 |
y += w->vscroll.pos; |
|
654 |
if (y >= w->vscroll.count) return; |
|
2100
217ea6fdfd18
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2071
diff
changeset
|
655 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
656 |
nd->map = (y == 0) ? NULL : _fios_list + y - 1; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
657 |
SetWindowDirty(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
658 |
} break; |
675
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
659 |
case 7: case 8: /* Connection type */ |
842 | 660 |
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
|
661 |
break; |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
662 |
case 9: case 10: /* Number of Players (hide 0 and 1 players) */ |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
663 |
ShowDropDownMenu(w, _players_dropdown, _network_game_info.clients_max, 10, 0, 3); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
664 |
break; |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
665 |
case 11: case 12: /* Number of Companies (hide 0, 9 and 10 companies; max is 8) */ |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
666 |
ShowDropDownMenu(w, _players_dropdown, _network_game_info.companies_max, 12, 0, 1537); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
667 |
break; |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
668 |
case 13: case 14: /* Number of Spectators */ |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
669 |
ShowDropDownMenu(w, _players_dropdown, _network_game_info.spectators_max, 14, 0, 0); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
670 |
break; |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
671 |
case 15: case 16: /* Language */ |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
672 |
ShowDropDownMenu(w, _language_dropdown, _network_game_info.server_lang, 16, 0, 0); |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
673 |
break; |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
674 |
case 17: /* Start game */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
675 |
_is_network_server = true; |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
676 |
|
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
677 |
if (nd->map == NULL) { // start random new game |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
678 |
ShowGenerateLandscape(); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
679 |
} else { // load a scenario |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
680 |
char *name = FiosBrowseTo(nd->map); |
2100
217ea6fdfd18
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2071
diff
changeset
|
681 |
if (name != NULL) { |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
682 |
SetFiosType(nd->map->type); |
2100
217ea6fdfd18
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2071
diff
changeset
|
683 |
ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name)); |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
684 |
ttd_strlcpy(_file_to_saveload.title, nd->map->title, sizeof(_file_to_saveload.title)); |
2100
217ea6fdfd18
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2071
diff
changeset
|
685 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
686 |
DeleteWindow(w); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
687 |
SwitchMode(SM_START_SCENARIO); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
688 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
689 |
} |
0 | 690 |
break; |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
691 |
case 18: /* Load game */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
692 |
_is_network_server = true; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
693 |
/* 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
|
694 |
* 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
|
695 |
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
|
696 |
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
|
697 |
break; |
0 | 698 |
} |
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
|
699 |
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
|
700 |
|
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
|
701 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
702 |
switch (e->we.dropdown.button) { |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
703 |
case 8: _network_advertise = (e->we.dropdown.index != 0); break; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
704 |
case 10: _network_game_info.clients_max = e->we.dropdown.index; break; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
705 |
case 12: _network_game_info.companies_max = e->we.dropdown.index; break; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
706 |
case 14: _network_game_info.spectators_max = e->we.dropdown.index; break; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
707 |
case 16: _network_game_info.server_lang = e->we.dropdown.index; break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
708 |
} |
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
|
709 |
|
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
|
710 |
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
|
711 |
break; |
0 | 712 |
|
713 |
case WE_MOUSELOOP: |
|
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
714 |
if (nd->field == 3) HandleEditBox(w, &WP(w, network_ql_d).q, 3); |
0 | 715 |
break; |
716 |
||
717 |
case WE_KEYPRESS: |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
718 |
if (nd->field == 3) { |
4299
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4286
diff
changeset
|
719 |
if (HandleEditBoxKey(w, &WP(w, network_ql_d).q, 3, e, CS_ALPHANUMERAL) == 1) break; // enter pressed |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
720 |
|
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
721 |
ttd_strlcpy(_network_server_name, WP(w, network_ql_d).q.text.buf, sizeof(_network_server_name)); |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
722 |
UpdateTextBufferSize(&WP(w, network_ql_d).q.text); |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
723 |
} |
0 | 724 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
725 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
726 |
case WE_ON_EDIT_TEXT: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
727 |
ttd_strlcpy(_network_server_password, e->we.edittext.str, lengthof(_network_server_password)); |
1899
81214598ab45
(svn r2405) Simplify a few '? true : false' and '? false : true', especially the latter is confusing
tron
parents:
1891
diff
changeset
|
728 |
_network_game_info.use_password = (_network_server_password[0] != '\0'); |
1653
d2db1ba2abde
(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
Darkvater
parents:
1648
diff
changeset
|
729 |
SetWindowDirty(w); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
730 |
} break; |
0 | 731 |
} |
732 |
} |
|
733 |
||
734 |
static const Widget _network_start_server_window_widgets[] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
735 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
736 |
{ WWT_CAPTION, RESIZE_NONE, BGC, 11, 419, 0, 13, STR_NETWORK_START_GAME_WINDOW, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
737 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 0, 419, 14, 243, 0x0, STR_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
|
738 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
739 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 100, 272, 22, 33, 0x0, STR_NETWORK_NEW_GAME_NAME_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
740 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 285, 405, 22, 33, STR_NETWORK_SET_PASSWORD, STR_NETWORK_PASSWORD_TIP}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
741 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
742 |
{ WWT_6, RESIZE_NONE, BGC, 10, 271, 62, 216, 0x0, STR_NETWORK_SELECT_MAP_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
743 |
{ WWT_SCROLLBAR, RESIZE_NONE, BGC, 259, 270, 63, 215, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
744 |
/* Combo boxes to control Connection Type / Max Clients / Max Companies / Max Observers / Language */ |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
745 |
{ WWT_6, RESIZE_NONE, BGC, 280, 410, 77, 88, STR_NETWORK_COMBO1, STR_NETWORK_CONNECTION_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
746 |
{ WWT_TEXTBTN, RESIZE_NONE, BGC, 399, 409, 78, 87, STR_0225, STR_NETWORK_CONNECTION_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
747 |
{ WWT_6, RESIZE_NONE, BGC, 280, 410, 109, 120, STR_NETWORK_COMBO2, STR_NETWORK_NUMBER_OF_CLIENTS_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
748 |
{ WWT_TEXTBTN, RESIZE_NONE, BGC, 399, 409, 110, 119, STR_0225, STR_NETWORK_NUMBER_OF_CLIENTS_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
749 |
{ WWT_6, RESIZE_NONE, BGC, 280, 410, 141, 152, STR_NETWORK_COMBO3, STR_NETWORK_NUMBER_OF_COMPANIES_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
750 |
{ WWT_TEXTBTN, RESIZE_NONE, BGC, 399, 409, 142, 151, STR_0225, STR_NETWORK_NUMBER_OF_COMPANIES_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
751 |
{ WWT_6, RESIZE_NONE, BGC, 280, 410, 173, 184, STR_NETWORK_COMBO4, STR_NETWORK_NUMBER_OF_SPECTATORS_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
752 |
{ WWT_TEXTBTN, RESIZE_NONE, BGC, 399, 409, 174, 183, STR_0225, STR_NETWORK_NUMBER_OF_SPECTATORS_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
753 |
{ WWT_6, RESIZE_NONE, BGC, 280, 410, 205, 216, STR_NETWORK_COMBO5, STR_NETWORK_LANGUAGE_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
754 |
{ WWT_TEXTBTN, RESIZE_NONE, BGC, 399, 409, 206, 215, STR_0225, STR_NETWORK_LANGUAGE_TIP}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
755 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
756 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 40, 140, 224, 235, STR_NETWORK_START_GAME, STR_NETWORK_START_GAME_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
757 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 150, 250, 224, 235, STR_NETWORK_LOAD_GAME, STR_NETWORK_LOAD_GAME_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
758 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 260, 360, 224, 235, 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
|
759 |
{ WIDGETS_END}, |
0 | 760 |
}; |
761 |
||
762 |
static const WindowDesc _network_start_server_window_desc = { |
|
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
763 |
WDP_CENTER, WDP_CENTER, 420, 244, |
0 | 764 |
WC_NETWORK_WINDOW,0, |
2064
e6a2b42d0b15
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2055
diff
changeset
|
765 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
0 | 766 |
_network_start_server_window_widgets, |
767 |
NetworkStartServerWindowWndProc, |
|
768 |
}; |
|
769 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
770 |
static void ShowNetworkStartServerWindow(void) |
0 | 771 |
{ |
772 |
Window *w; |
|
773 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
774 |
|
0 | 775 |
w = AllocateWindowDesc(&_network_start_server_window_desc); |
3470
cd704e52732f
(svn r4315) Remove MAX_QUERYSTR_LEN, rather use lengthof() the real thing
tron
parents:
3469
diff
changeset
|
776 |
ttd_strlcpy(_edit_str_buf, _network_server_name, lengthof(_edit_str_buf)); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
777 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
778 |
_saveload_mode = SLD_NEW_GAME; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
779 |
BuildFileList(); |
2943
2e24a1c0a0cd
(svn r3499) - Fix: a few gui glitches in the network window:
Darkvater
parents:
2938
diff
changeset
|
780 |
w->vscroll.cap = 12; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
781 |
w->vscroll.count = _fios_num+1; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
782 |
|
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
783 |
WP(w, network_ql_d).q.text.caret = true; |
3470
cd704e52732f
(svn r4315) Remove MAX_QUERYSTR_LEN, rather use lengthof() the real thing
tron
parents:
3469
diff
changeset
|
784 |
WP(w, network_ql_d).q.text.maxlength = lengthof(_edit_str_buf); |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
785 |
WP(w, network_ql_d).q.text.maxwidth = 160; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
786 |
WP(w, network_ql_d).q.text.buf = _edit_str_buf; |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
787 |
UpdateTextBufferSize(&WP(w, network_ql_d).q.text); |
0 | 788 |
} |
789 |
||
734
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
790 |
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
|
791 |
{ |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
792 |
byte i; |
2639 | 793 |
|
734
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
794 |
/* 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
|
795 |
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
|
796 |
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
|
797 |
if (_network_player_info[i].company_name[0] != '\0') { |
2639 | 798 |
if (pos-- == 0) return i; |
734
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
799 |
} |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
800 |
} |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
801 |
|
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
802 |
return 0; |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
803 |
} |
f4ad2f5805fd
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
804 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
805 |
/* uses network_d WP macro */ |
0 | 806 |
static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) |
807 |
{ |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
808 |
network_d *nd = &WP(w, network_d); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
809 |
|
2639 | 810 |
switch (e->event) { |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
811 |
case WE_CREATE: |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
812 |
nd->company = (byte)-1; |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
813 |
break; |
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
814 |
|
0 | 815 |
case WE_PAINT: { |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
816 |
const NetworkGameInfo *gi = &nd->server->info; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
817 |
int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
818 |
|
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
819 |
SetWindowWidgetDisabledState(w, 7, nd->company == (byte)-1); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
820 |
SetWindowWidgetDisabledState(w, 8, gi->companies_on >= gi->companies_max); |
735
995f97df3bd7
(svn r1187) -Fix: [Network] You can no longer join as spectator a game with no
truelight
parents:
734
diff
changeset
|
821 |
/* You can not join a server as spectator when it has no companies active.. |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
822 |
* it causes some nasty crashes */ |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
823 |
SetWindowWidgetDisabledState(w, 9, gi->spectators_on >= gi->spectators_max || |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
824 |
gi->companies_on == 0); |
621
31b12c30b54c
(svn r1051) -Fix: [Network] New Company button is disabled when there is no more
truelight
parents:
618
diff
changeset
|
825 |
|
0 | 826 |
DrawWindowWidgets(w); |
827 |
||
2884
8f00f4e86bf6
(svn r3434) - Correctly update all network information when pressing refresh in the lobby. Also always allow the join button to a server unless all clients are used up (otherwise you can always join an existing company
Darkvater
parents:
2881
diff
changeset
|
828 |
SetDParamStr(0, gi->server_name); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
829 |
DrawString(10, 22, STR_NETWORK_PREPARE_TO_JOIN, 2); |
0 | 830 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
831 |
/* Draw company list */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
832 |
pos = w->vscroll.pos; |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
833 |
while (pos < gi->companies_on) { |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
834 |
byte company = NetworkLobbyFindCompanyIndex(pos); |
1011
933efc472c62
(svn r1510) -Add: Improved Network Lobby GUI: (bociusz)
truelight
parents:
1009
diff
changeset
|
835 |
bool income = false; |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
836 |
if (nd->company == company) |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
837 |
GfxFillRect(11, y - 1, 154, y + 10, 10); // 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
|
838 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
839 |
DoDrawStringTruncated(_network_player_info[company].company_name, 13, y, 16, 135 - 13); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
840 |
if (_network_player_info[company].use_password != 0) DrawSprite(SPR_LOCK, 135, y); |
1011
933efc472c62
(svn r1510) -Add: Improved Network Lobby GUI: (bociusz)
truelight
parents:
1009
diff
changeset
|
841 |
|
933efc472c62
(svn r1510) -Add: Improved Network Lobby GUI: (bociusz)
truelight
parents:
1009
diff
changeset
|
842 |
/* If the company's income was positive puts a green dot else a red dot */ |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
843 |
if (_network_player_info[company].income >= 0) income = true; |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
844 |
DrawSprite(SPR_BLOT | (income ? PALETTE_TO_GREEN : PALETTE_TO_RED), 145, y); |
0 | 845 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
846 |
pos++; |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
847 |
y += NET_PRC__SIZE_OF_ROW; |
2639 | 848 |
if (pos >= w->vscroll.cap) break; |
543
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 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
851 |
/* Draw info about selected company when it is selected in the left window */ |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
852 |
GfxFillRect(174, 39, 403, 75, 157); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
853 |
DrawStringMultiCenter(290, 50, STR_NETWORK_COMPANY_INFO, 0); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
854 |
if (nd->company != (byte)-1) { |
1025
f10da46b66f0
(svn r1526) -Fix: [1103027] Minor changes for the lobby GUI (widen window) (bociusz)
darkvater
parents:
1019
diff
changeset
|
855 |
const uint x = 183; |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
856 |
const uint trunc_width = w->widget[6].right - x; |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
857 |
y = 80; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
858 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
859 |
SetDParam(0, nd->server->info.clients_on); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
860 |
SetDParam(1, nd->server->info.clients_max); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
861 |
SetDParam(2, nd->server->info.companies_on); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
862 |
SetDParam(3, nd->server->info.companies_max); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
863 |
DrawString(x, y, STR_NETWORK_CLIENTS, 2); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
864 |
y += 10; |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
865 |
|
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
866 |
SetDParamStr(0, _network_player_info[nd->company].company_name); |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
867 |
DrawStringTruncated(x, y, STR_NETWORK_COMPANY_NAME, 2, trunc_width); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
868 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
869 |
|
4329
0e6e689f66e7
(svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents:
4319
diff
changeset
|
870 |
SetDParam(0, _network_player_info[nd->company].inaugurated_year); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
871 |
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
|
872 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
873 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
874 |
SetDParam64(0, _network_player_info[nd->company].company_value); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
875 |
DrawString(x, y, STR_NETWORK_VALUE, 2); // company value |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
876 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
877 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
878 |
SetDParam64(0, _network_player_info[nd->company].money); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
879 |
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
|
880 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
881 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
882 |
SetDParam64(0, _network_player_info[nd->company].income); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
883 |
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
|
884 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
885 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
886 |
SetDParam(0, _network_player_info[nd->company].performance); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
887 |
DrawString(x, y, STR_NETWORK_PERFORMANCE, 2); // performance |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
888 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
889 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
890 |
SetDParam(0, _network_player_info[nd->company].num_vehicle[0]); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
891 |
SetDParam(1, _network_player_info[nd->company].num_vehicle[1]); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
892 |
SetDParam(2, _network_player_info[nd->company].num_vehicle[2]); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
893 |
SetDParam(3, _network_player_info[nd->company].num_vehicle[3]); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
894 |
SetDParam(4, _network_player_info[nd->company].num_vehicle[4]); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
895 |
DrawString(x, y, STR_NETWORK_VEHICLES, 2); // vehicles |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
896 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
897 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
898 |
SetDParam(0, _network_player_info[nd->company].num_station[0]); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
899 |
SetDParam(1, _network_player_info[nd->company].num_station[1]); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
900 |
SetDParam(2, _network_player_info[nd->company].num_station[2]); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
901 |
SetDParam(3, _network_player_info[nd->company].num_station[3]); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
902 |
SetDParam(4, _network_player_info[nd->company].num_station[4]); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
903 |
DrawString(x, y, STR_NETWORK_STATIONS, 2); // stations |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
904 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
905 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
906 |
SetDParamStr(0, _network_player_info[nd->company].players); |
2879
365ecd52f2db
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Darkvater
parents:
2788
diff
changeset
|
907 |
DrawStringTruncated(x, y, STR_NETWORK_PLAYERS, 2, trunc_width); // players |
543
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 |
} break; |
0 | 910 |
|
911 |
case WE_CLICK: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
912 |
switch (e->we.click.widget) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
913 |
case 0: case 11: /* Close 'X' | Cancel button */ |
0 | 914 |
ShowNetworkGameWindow(); |
915 |
break; |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
916 |
case 4: { /* Company list */ |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
917 |
uint32 id_v = (e->we.click.pt.y - NET_PRC__OFFSET_TOP_WIDGET_COMPANY) / NET_PRC__SIZE_OF_ROW; |
0 | 918 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
919 |
if (id_v >= w->vscroll.cap) return; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
920 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
921 |
id_v += w->vscroll.pos; |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
922 |
nd->company = (id_v >= nd->server->info.companies_on) ? (byte)-1 : NetworkLobbyFindCompanyIndex(id_v); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
923 |
SetWindowDirty(w); |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
924 |
} break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
925 |
case 7: /* Join company */ |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
926 |
if (nd->company != (byte)-1) { |
4878
4d4f76a898fd
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
927 |
_network_playas = nd->company; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
928 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
929 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
930 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
931 |
case 8: /* New company */ |
4861
2119f5d46e41
(svn r6787) -Codechange: Use PLAYER_NEW_COMPANY as a player identifier wishing to become a
Darkvater
parents:
4848
diff
changeset
|
932 |
_network_playas = PLAYER_NEW_COMPANY; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
933 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
934 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
935 |
case 9: /* Spectate game */ |
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4830
diff
changeset
|
936 |
_network_playas = PLAYER_SPECTATOR; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
937 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
938 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
939 |
case 10: /* Refresh */ |
2886
6a1f13220989
(svn r3438) - Fix: first request company data, then general. Yes, it should be the other way around, but with the current network code this doesn't work. So workaround (have some nice promise from TrueLight for fixing ;))
Darkvater
parents:
2885
diff
changeset
|
940 |
NetworkQueryServer(_network_last_host, _network_last_port, false); // company info |
2884
8f00f4e86bf6
(svn r3434) - Correctly update all network information when pressing refresh in the lobby. Also always allow the join button to a server unless all clients are used up (otherwise you can always join an existing company
Darkvater
parents:
2881
diff
changeset
|
941 |
NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
942 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
943 |
} break; |
2884
8f00f4e86bf6
(svn r3434) - Correctly update all network information when pressing refresh in the lobby. Also always allow the join button to a server unless all clients are used up (otherwise you can always join an existing company
Darkvater
parents:
2881
diff
changeset
|
944 |
|
8f00f4e86bf6
(svn r3434) - Correctly update all network information when pressing refresh in the lobby. Also always allow the join button to a server unless all clients are used up (otherwise you can always join an existing company
Darkvater
parents:
2881
diff
changeset
|
945 |
case WE_MESSAGE: |
8f00f4e86bf6
(svn r3434) - Correctly update all network information when pressing refresh in the lobby. Also always allow the join button to a server unless all clients are used up (otherwise you can always join an existing company
Darkvater
parents:
2881
diff
changeset
|
946 |
SetWindowDirty(w); |
8f00f4e86bf6
(svn r3434) - Correctly update all network information when pressing refresh in the lobby. Also always allow the join button to a server unless all clients are used up (otherwise you can always join an existing company
Darkvater
parents:
2881
diff
changeset
|
947 |
break; |
543
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 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
950 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
951 |
static const Widget _network_lobby_window_widgets[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
952 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
953 |
{ WWT_CAPTION, RESIZE_NONE, BGC, 11, 419, 0, 13, STR_NETWORK_GAME_LOBBY, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
954 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 0, 419, 14, 234, STR_NULL, STR_NULL}, |
543
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 |
// company list |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
957 |
{ WWT_PANEL, RESIZE_NONE, BTC, 10, 155, 38, 49, STR_NULL, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
958 |
{ WWT_MATRIX, RESIZE_NONE, BGC, 10, 155, 50, 190, (10 << 8) + 1, STR_NETWORK_COMPANY_LIST_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
959 |
{ WWT_SCROLLBAR, RESIZE_NONE, BGC, 156, 167, 38, 190, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
960 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
961 |
// company/player info |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
962 |
{ WWT_PANEL, RESIZE_NONE, BGC, 173, 404, 38, 190, STR_NULL, STR_NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
963 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
964 |
// buttons |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
965 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 10, 151, 200, 211, STR_NETWORK_JOIN_COMPANY, STR_NETWORK_JOIN_COMPANY_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
966 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 10, 151, 215, 226, STR_NETWORK_NEW_COMPANY, STR_NETWORK_NEW_COMPANY_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
967 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 158, 268, 200, 211, STR_NETWORK_SPECTATE_GAME, STR_NETWORK_SPECTATE_GAME_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
968 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 158, 268, 215, 226, STR_NETWORK_REFRESH, STR_NETWORK_REFRESH_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
969 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 278, 388, 200, 211, STR_012E_CANCEL, STR_NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
970 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
971 |
{ WIDGETS_END}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
972 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
973 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
974 |
static const WindowDesc _network_lobby_window_desc = { |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
975 |
WDP_CENTER, WDP_CENTER, 420, 235, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
976 |
WC_NETWORK_WINDOW,0, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
977 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
978 |
_network_lobby_window_widgets, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
979 |
NetworkLobbyWindowWndProc, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
980 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
981 |
|
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
982 |
/* Show the networklobbywindow with the selected server |
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
983 |
* @param ngl Selected game pointer which is passed to the new window */ |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
984 |
static void ShowNetworkLobbyWindow(NetworkGameList *ngl) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
985 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
986 |
Window *w; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
987 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
988 |
|
2945
0da4f6002701
(svn r3501) - Load the lobby-window with up-to-date data upon opening
Darkvater
parents:
2943
diff
changeset
|
989 |
NetworkQueryServer(_network_last_host, _network_last_port, false); // company info |
0da4f6002701
(svn r3501) - Load the lobby-window with up-to-date data upon opening
Darkvater
parents:
2943
diff
changeset
|
990 |
NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
991 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
992 |
w = AllocateWindowDesc(&_network_lobby_window_desc); |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
993 |
if (w != NULL) { |
2888
79da960a5372
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
994 |
WP(w, network_ql_d).n.server = ngl; |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
995 |
strcpy(_edit_str_buf, ""); |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
996 |
w->vscroll.cap = 10; |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
997 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
998 |
} |
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 |
// The window below gives information about the connected clients |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1001 |
// 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
|
1002 |
// and stuff like that. |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1003 |
|
3692 | 1004 |
extern void DrawPlayerIcon(PlayerID pid, int x, int y); |
543
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 |
// Every action must be of this form |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1007 |
typedef void ClientList_Action_Proc(byte client_no); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1008 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1009 |
// Max 10 actions per client |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1010 |
#define MAX_CLIENTLIST_ACTION 10 |
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 |
// Some standard bullshit.. defines variables ;) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1013 |
static void ClientListWndProc(Window *w, WindowEvent *e); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1014 |
static void ClientListPopupWndProc(Window *w, WindowEvent *e); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1015 |
static byte _selected_clientlist_item = 255; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1016 |
static byte _selected_clientlist_y = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1017 |
static char _clientlist_action[MAX_CLIENTLIST_ACTION][50]; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1018 |
static ClientList_Action_Proc *_clientlist_proc[MAX_CLIENTLIST_ACTION]; |
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 |
enum { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1021 |
CLNWND_OFFSET = 16, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1022 |
CLNWND_ROWSIZE = 10 |
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 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1025 |
static const Widget _client_list_widgets[] = { |
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2669
diff
changeset
|
1026 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1027 |
{ 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
|
1028 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1029 |
{ 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
|
1030 |
{ WIDGETS_END}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1031 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1032 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1033 |
static const Widget _client_list_popup_widgets[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
1034 |
{ 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
|
1035 |
{ WIDGETS_END}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1036 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1037 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1038 |
static WindowDesc _client_list_desc = { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1039 |
-1, -1, 250, 1, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1040 |
WC_CLIENT_LIST,0, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1041 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1042 |
_client_list_widgets, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1043 |
ClientListWndProc |
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 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1046 |
// Finds the Xth client-info that is active |
4171 | 1047 |
static const NetworkClientInfo *NetworkFindClientInfo(byte client_no) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1048 |
{ |
4171 | 1049 |
const NetworkClientInfo *ci; |
2630 | 1050 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1051 |
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
|
1052 |
// Skip non-active items |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1053 |
if (ci->client_index == NETWORK_EMPTY_INDEX) continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1054 |
if (client_no == 0) return ci; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1055 |
client_no--; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1056 |
} |
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 |
return NULL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1059 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1060 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1061 |
// 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
|
1062 |
static void ClientList_Kick(byte client_no) |
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 |
if (client_no < MAX_PLAYERS) |
4880
aac84a9dcd03
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
1065 |
SEND_COMMAND(PACKET_SERVER_ERROR)(DEREF_CLIENT(client_no), NETWORK_ERROR_KICKED); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1066 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1067 |
|
841
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1068 |
static void ClientList_Ban(byte client_no) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1069 |
{ |
841
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1070 |
uint i; |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1071 |
uint32 ip = NetworkFindClientInfo(client_no)->client_ip; |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1072 |
|
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1073 |
for (i = 0; i < lengthof(_network_ban_list); i++) { |
2914
ccfa238c6645
(svn r3469) - Fix: plug a possible memleak with subsequential strdup's without freeing the previous value and make it possible to ban offline clients
Darkvater
parents:
2889
diff
changeset
|
1074 |
if (_network_ban_list[i] == NULL) { |
841
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1075 |
_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
|
1076 |
break; |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1077 |
} |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1078 |
} |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1079 |
|
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1080 |
if (client_no < MAX_PLAYERS) |
4880
aac84a9dcd03
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
1081 |
SEND_COMMAND(PACKET_SERVER_ERROR)(DEREF_CLIENT(client_no), NETWORK_ERROR_KICKED); |
841
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1082 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1083 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1084 |
static void ClientList_GiveMoney(byte client_no) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1085 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1086 |
if (NetworkFindClientInfo(client_no) != NULL) |
4878
4d4f76a898fd
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
1087 |
ShowNetworkGiveMoneyWindow(NetworkFindClientInfo(client_no)->client_playas); |
543
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 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1090 |
static void ClientList_SpeakToClient(byte client_no) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1091 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1092 |
if (NetworkFindClientInfo(client_no) != NULL) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1093 |
ShowNetworkChatQueryWindow(DESTTYPE_CLIENT, NetworkFindClientInfo(client_no)->client_index); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1094 |
} |
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 |
static void ClientList_SpeakToPlayer(byte client_no) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1097 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1098 |
if (NetworkFindClientInfo(client_no) != NULL) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1099 |
ShowNetworkChatQueryWindow(DESTTYPE_PLAYER, NetworkFindClientInfo(client_no)->client_playas); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1100 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1101 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1102 |
static void ClientList_SpeakToAll(byte client_no) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1103 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1104 |
ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0); |
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 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1107 |
static void ClientList_None(byte client_no) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1108 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1109 |
// No action ;) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1110 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1111 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1112 |
|
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 |
// Help, a action is clicked! What do we do? |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1115 |
static void HandleClientListPopupClick(byte index, byte clientno) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1116 |
// 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
|
1117 |
if (index < MAX_CLIENTLIST_ACTION && _clientlist_proc[index] != NULL) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1118 |
_clientlist_proc[index](clientno); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1119 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1120 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1121 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1122 |
// 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
|
1123 |
static bool CheckClientListHeight(Window *w) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1124 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1125 |
int num = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1126 |
NetworkClientInfo *ci; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1127 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1128 |
// Should be replaced with a loop through all clients |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1129 |
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
|
1130 |
// Skip non-active items |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1131 |
if (ci->client_index == NETWORK_EMPTY_INDEX) continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1132 |
num++; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1133 |
} |
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 |
num *= CLNWND_ROWSIZE; |
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 |
// 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
|
1138 |
if (w->height != CLNWND_OFFSET + num + 1) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1139 |
// 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
|
1140 |
SetWindowDirty(w); |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1141 |
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
|
1142 |
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
|
1143 |
SetWindowDirty(w); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1144 |
return false; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1145 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1146 |
return true; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1147 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1148 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1149 |
// 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
|
1150 |
static uint ClientListPopupHeigth(void) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1151 |
int i, num = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1152 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1153 |
// Find the amount of actions |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1154 |
for (i = 0; i < MAX_CLIENTLIST_ACTION; i++) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1155 |
if (_clientlist_action[i][0] == '\0') continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1156 |
if (_clientlist_proc[i] == NULL) continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1157 |
num++; |
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 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1160 |
num *= CLNWND_ROWSIZE; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1161 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1162 |
return num + 1; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1163 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1164 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1165 |
// Show the popup (action list) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1166 |
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
|
1167 |
{ |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1168 |
int i, h; |
4171 | 1169 |
const NetworkClientInfo *ci; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1170 |
DeleteWindowById(WC_TOOLBAR_MENU, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1171 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1172 |
// Clean the current actions |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1173 |
for (i = 0; i < MAX_CLIENTLIST_ACTION; i++) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1174 |
_clientlist_action[i][0] = '\0'; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1175 |
_clientlist_proc[i] = NULL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1176 |
} |
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 |
// Fill the actions this client has |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1179 |
// Watch is, max 50 chars long! |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1180 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1181 |
ci = NetworkFindClientInfo(client_no); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1182 |
if (ci == NULL) return NULL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1183 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1184 |
i = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1185 |
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
|
1186 |
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
|
1187 |
_clientlist_proc[i++] = &ClientList_SpeakToClient; |
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 |
|
4878
4d4f76a898fd
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
1190 |
if (IsValidPlayer(ci->client_playas)) { |
722
f420fa9bd521
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
716
diff
changeset
|
1191 |
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
|
1192 |
_clientlist_proc[i++] = &ClientList_SpeakToPlayer; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1193 |
} |
722
f420fa9bd521
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
716
diff
changeset
|
1194 |
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
|
1195 |
_clientlist_proc[i++] = &ClientList_SpeakToAll; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1196 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1197 |
if (_network_own_client_index != ci->client_index) { |
4878
4d4f76a898fd
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
1198 |
/* We are no spectator and the player we want to give money to is no spectator */ |
4d4f76a898fd
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
1199 |
if (IsValidPlayer(_network_playas) && IsValidPlayer(ci->client_playas)) { |
4d4f76a898fd
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
1200 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_GIVE_MONEY); |
4d4f76a898fd
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
1201 |
_clientlist_proc[i++] = &ClientList_GiveMoney; |
0 | 1202 |
} |
543
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 |
|
4880
aac84a9dcd03
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
1205 |
// A server can kick clients (but not himself) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1206 |
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
|
1207 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_KICK); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1208 |
_clientlist_proc[i++] = &ClientList_Kick; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1209 |
|
841
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1210 |
sprintf(_clientlist_action[i],"Ban"); |
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1211 |
_clientlist_proc[i++] = &ClientList_Ban; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1212 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1213 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1214 |
if (i == 0) { |
722
f420fa9bd521
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
716
diff
changeset
|
1215 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_NONE); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1216 |
_clientlist_proc[i++] = &ClientList_None; |
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 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1219 |
/* Calculate the height */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1220 |
h = ClientListPopupHeigth(); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1221 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1222 |
// Allocate the popup |
3250
4d19bcd78d22
(svn r3933) - [ 1439907 ] Increase client list window width so at least most languages fit (wikipedian).
Darkvater
parents:
2952
diff
changeset
|
1223 |
w = AllocateWindow(x, y, 150, h + 1, ClientListPopupWndProc, WC_TOOLBAR_MENU, _client_list_popup_widgets); |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1224 |
w->widget[0].bottom = w->widget[0].top + h; |
3250
4d19bcd78d22
(svn r3933) - [ 1439907 ] Increase client list window width so at least most languages fit (wikipedian).
Darkvater
parents:
2952
diff
changeset
|
1225 |
w->widget[0].right = w->widget[0].left + 150; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1226 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1227 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1228 |
WP(w,menu_d).item_count = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1229 |
// Save our client |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1230 |
WP(w,menu_d).main_button = client_no; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1231 |
WP(w,menu_d).sel_index = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1232 |
// We are a popup |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1233 |
_popup_menu_active = true; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1234 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1235 |
return w; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1236 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1237 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
1238 |
/** Main handle for the client popup list |
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
1239 |
* uses menu_d WP macro */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1240 |
static void ClientListPopupWndProc(Window *w, WindowEvent *e) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1241 |
{ |
2639 | 1242 |
switch (e->event) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1243 |
case WE_PAINT: { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1244 |
int i, y, sel; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1245 |
byte colour; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1246 |
DrawWindowWidgets(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1247 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1248 |
// Draw the actions |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1249 |
sel = WP(w,menu_d).sel_index; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1250 |
y = 1; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1251 |
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
|
1252 |
if (_clientlist_action[i][0] == '\0') continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1253 |
if (_clientlist_proc[i] == NULL) continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1254 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1255 |
if (sel-- == 0) { // Selected item, highlight it |
3250
4d19bcd78d22
(svn r3933) - [ 1439907 ] Increase client list window width so at least most languages fit (wikipedian).
Darkvater
parents:
2952
diff
changeset
|
1256 |
GfxFillRect(1, y, 150 - 2, y + CLNWND_ROWSIZE - 1, 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1257 |
colour = 0xC; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
1258 |
} else { |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
1259 |
colour = 0x10; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
1260 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1261 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1262 |
DoDrawString(_clientlist_action[i], 4, y, colour); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1263 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1264 |
} break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1265 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1266 |
case WE_POPUPMENU_SELECT: { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1267 |
// We selected an action |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1268 |
int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1269 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1270 |
if (index >= 0 && e->we.popupmenu.pt.y >= w->top) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1271 |
HandleClientListPopupClick(index, WP(w,menu_d).main_button); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1272 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1273 |
// 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
|
1274 |
// 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
|
1275 |
// 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
|
1276 |
// '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
|
1277 |
// the right address... |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1278 |
DeleteWindowById(WC_TOOLBAR_MENU, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1279 |
} break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1280 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1281 |
case WE_POPUPMENU_OVER: { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1282 |
// Our mouse hoovers over an action? Select it! |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1283 |
int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1284 |
|
4880
aac84a9dcd03
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
1285 |
if (index == -1 || index == WP(w,menu_d).sel_index) return; |
543
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 |
WP(w,menu_d).sel_index = index; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1288 |
SetWindowDirty(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1289 |
} break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1290 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1291 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1292 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1293 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1294 |
// Main handle for clientlist |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1295 |
static void ClientListWndProc(Window *w, WindowEvent *e) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1296 |
{ |
2639 | 1297 |
switch (e->event) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1298 |
case WE_PAINT: { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1299 |
NetworkClientInfo *ci; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1300 |
int y, i = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1301 |
byte colour; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1302 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1303 |
// Check if we need to reset the height |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1304 |
if (!CheckClientListHeight(w)) break; |
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 |
DrawWindowWidgets(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1307 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1308 |
y = CLNWND_OFFSET; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1309 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1310 |
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
|
1311 |
// Skip non-active items |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1312 |
if (ci->client_index == NETWORK_EMPTY_INDEX) continue; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1313 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1314 |
if (_selected_clientlist_item == i++) { // Selected item, highlight it |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1315 |
GfxFillRect(1, y, 248, y + CLNWND_ROWSIZE - 1, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1316 |
colour = 0xC; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
1317 |
} else { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1318 |
colour = 0x10; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
1319 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1320 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1321 |
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
|
1322 |
DrawString(4, y, STR_NETWORK_SERVER, colour); |
2639 | 1323 |
} else { |
722
f420fa9bd521
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
716
diff
changeset
|
1324 |
DrawString(4, y, STR_NETWORK_CLIENT, colour); |
2639 | 1325 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1326 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1327 |
// Filter out spectators |
4878
4d4f76a898fd
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
1328 |
if (IsValidPlayer(ci->client_playas)) DrawPlayerIcon(ci->client_playas, 64, y + 1); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1329 |
|
3250
4d19bcd78d22
(svn r3933) - [ 1439907 ] Increase client list window width so at least most languages fit (wikipedian).
Darkvater
parents:
2952
diff
changeset
|
1330 |
DoDrawString(ci->client_name, 81, y, colour); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1331 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1332 |
y += CLNWND_ROWSIZE; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1333 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1334 |
} break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1335 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1336 |
case WE_CLICK: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1337 |
// Show the popup with option |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1338 |
if (_selected_clientlist_item != 255) { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1339 |
PopupClientList(w, _selected_clientlist_item, e->we.click.pt.x + w->left, e->we.click.pt.y + w->top); |
0 | 1340 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1341 |
|
0 | 1342 |
break; |
1343 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1344 |
case WE_MOUSEOVER: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1345 |
// -1 means we left the current window |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1346 |
if (e->we.mouseover.pt.y == -1) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1347 |
_selected_clientlist_y = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1348 |
_selected_clientlist_item = 255; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1349 |
SetWindowDirty(w); |
0 | 1350 |
break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1351 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1352 |
// It did not change.. no update! |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1353 |
if (e->we.mouseover.pt.y == _selected_clientlist_y) break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1354 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1355 |
// Find the new selected item (if any) |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1356 |
_selected_clientlist_y = e->we.mouseover.pt.y; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1357 |
if (e->we.mouseover.pt.y > CLNWND_OFFSET) { |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1358 |
_selected_clientlist_item = (e->we.mouseover.pt.y - CLNWND_OFFSET) / CLNWND_ROWSIZE; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
1359 |
} else { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1360 |
_selected_clientlist_item = 255; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
1361 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1362 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1363 |
// Repaint |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1364 |
SetWindowDirty(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1365 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1366 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1367 |
case WE_DESTROY: case WE_CREATE: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1368 |
// When created or destroyed, data is reset |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1369 |
_selected_clientlist_item = 255; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1370 |
_selected_clientlist_y = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1371 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1372 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1373 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1374 |
|
1003
5a1516385ad5
(svn r1502) -Fix: [1101889] Crash under windows... stupid typo in player_gui.c ^ should've been &
darkvater
parents:
982
diff
changeset
|
1375 |
void ShowClientList(void) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1376 |
{ |
4491 | 1377 |
AllocateWindowDescFront(&_client_list_desc, 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1378 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1379 |
|
4512
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1380 |
|
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1381 |
static NetworkPasswordType pw_type; |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1382 |
|
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1383 |
|
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1384 |
void ShowNetworkNeedPassword(NetworkPasswordType npt) |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1385 |
{ |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1386 |
StringID caption; |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1387 |
|
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1388 |
pw_type = npt; |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1389 |
switch (npt) { |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1390 |
default: NOT_REACHED(); |
4774
f93b1f0a9cf3
(svn r6688) -Fix (r6297): Wrong caption for server password query window (eg put 'break' after switch statements)
Darkvater
parents:
4719
diff
changeset
|
1391 |
case NETWORK_GAME_PASSWORD: caption = STR_NETWORK_NEED_GAME_PASSWORD_CAPTION; break; |
f93b1f0a9cf3
(svn r6688) -Fix (r6297): Wrong caption for server password query window (eg put 'break' after switch statements)
Darkvater
parents:
4719
diff
changeset
|
1392 |
case NETWORK_COMPANY_PASSWORD: caption = STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION; break; |
4512
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1393 |
} |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1394 |
ShowQueryString(STR_EMPTY, caption, 20, 180, WC_NETWORK_STATUS_WINDOW, 0, CS_ALPHANUMERAL); |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1395 |
} |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1396 |
|
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1397 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1398 |
static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1399 |
{ |
2639 | 1400 |
switch (e->event) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1401 |
case WE_PAINT: { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1402 |
uint8 progress; // used for progress bar |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1403 |
DrawWindowWidgets(w); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1404 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1405 |
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
|
1406 |
switch (_network_join_status) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1407 |
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
|
1408 |
case NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1409 |
progress = 10; // first two stages 10% |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1410 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1411 |
case NETWORK_JOIN_STATUS_WAITING: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1412 |
SetDParam(0, _network_join_waiting); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1413 |
DrawStringCentered(125, 46, STR_NETWORK_CONNECTING_WAITING, 14); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1414 |
progress = 15; // third stage is 15% |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1415 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1416 |
case NETWORK_JOIN_STATUS_DOWNLOADING: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1417 |
SetDParam(0, _network_join_kbytes); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1418 |
SetDParam(1, _network_join_kbytes_total); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1419 |
DrawStringCentered(125, 46, STR_NETWORK_CONNECTING_DOWNLOADING, 14); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1420 |
/* Fallthrough */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1421 |
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
|
1422 |
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
|
1423 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1424 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1425 |
/* Draw nice progress bar :) */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1426 |
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
|
1427 |
} break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1428 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1429 |
case WE_CLICK: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1430 |
switch (e->we.click.widget) { |
2639 | 1431 |
case 0: /* Close 'X' */ |
1432 |
case 3: /* Disconnect button */ |
|
1433 |
NetworkDisconnect(); |
|
1434 |
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); |
|
1435 |
SwitchMode(SM_MENU); |
|
1436 |
ShowNetworkGameWindow(); |
|
1437 |
break; |
|
0 | 1438 |
} |
1439 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1440 |
|
4512
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1441 |
case WE_ON_EDIT_TEXT_CANCEL: |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1442 |
NetworkDisconnect(); |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1443 |
ShowNetworkGameWindow(); |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1444 |
break; |
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1445 |
|
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1446 |
case WE_ON_EDIT_TEXT: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1447 |
SEND_COMMAND(PACKET_CLIENT_PASSWORD)(pw_type, e->we.edittext.str); |
4512
823dfd4aa413
(svn r6297) -Codechange: Disentangle the query window mess a bit: Move the network game password handling somewhere were it belongs to
tron
parents:
4491
diff
changeset
|
1448 |
break; |
0 | 1449 |
} |
1450 |
} |
|
1451 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1452 |
static const Widget _network_join_status_window_widget[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
1453 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1454 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 249, 0, 13, STR_NETWORK_CONNECTING, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
1455 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 249, 14, 84, 0x0, STR_NULL}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1456 |
{ 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
|
1457 |
{ WIDGETS_END}, |
0 | 1458 |
}; |
1459 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1460 |
static const WindowDesc _network_join_status_window_desc = { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1461 |
WDP_CENTER, WDP_CENTER, 250, 85, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1462 |
WC_NETWORK_STATUS_WINDOW, 0, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1463 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1464 |
_network_join_status_window_widget, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1465 |
NetworkJoinStatusWindowWndProc, |
0 | 1466 |
}; |
1467 |
||
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
|
1468 |
void ShowJoinStatusWindow(void) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1469 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1470 |
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1471 |
_network_join_status = NETWORK_JOIN_STATUS_CONNECTING; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1472 |
AllocateWindowDesc(&_network_join_status_window_desc); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1473 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1474 |
|
774
bb9ec520a1b1
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
764
diff
changeset
|
1475 |
void ShowJoinStatusWindowAfterJoin(void) |
670
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1476 |
{ |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1477 |
/* This is a special instant of ShowJoinStatusWindow, because |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1478 |
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
|
1479 |
done registering itself to the server */ |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1480 |
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1481 |
_network_join_status = NETWORK_JOIN_STATUS_REGISTERING; |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1482 |
AllocateWindowDesc(&_network_join_status_window_desc); |
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1483 |
} |
0 | 1484 |
|
649 | 1485 |
|
4013
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1486 |
static byte _chat_type; |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1487 |
static byte _chat_dest; |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1488 |
|
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1489 |
|
4171 | 1490 |
static void SendChat(const char *buf) |
4013
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1491 |
{ |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1492 |
if (buf[0] == '\0') return; |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1493 |
if (!_network_server) { |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1494 |
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT + _chat_type, _chat_type, _chat_dest, buf); |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1495 |
} else { |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1496 |
NetworkServer_HandleChat(NETWORK_ACTION_CHAT + _chat_type, _chat_type, _chat_dest, buf, NETWORK_SERVER_INDEX); |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1497 |
} |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1498 |
} |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1499 |
|
4315
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1500 |
/** |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1501 |
* Find the next item of the list of things that can be auto-completed. |
4319
b4c237cf69c1
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1502 |
* @param item The current indexed item to return. This function can, and most |
b4c237cf69c1
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1503 |
* likely will, alter item, to skip empty items in the arrays. |
b4c237cf69c1
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1504 |
* @return Returns the char that matched to the index. |
4315
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1505 |
*/ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1506 |
static const char *ChatTabCompletionNextItem(uint *item) |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1507 |
{ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1508 |
static char chat_tab_temp_buffer[64]; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1509 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1510 |
/* First, try clients */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1511 |
if (*item < MAX_CLIENT_INFO) { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1512 |
/* Skip inactive clients */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1513 |
while (_network_client_info[*item].client_index == NETWORK_EMPTY_INDEX && *item < MAX_CLIENT_INFO) (*item)++; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1514 |
if (*item < MAX_CLIENT_INFO) return _network_client_info[*item].client_name; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1515 |
} |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1516 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1517 |
/* Then, try townnames */ |
4354
10f4ce894eb1
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4346
diff
changeset
|
1518 |
if (*item < (uint)MAX_CLIENT_INFO + GetTownArraySize()) { |
4319
b4c237cf69c1
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1519 |
const Town *t; |
4315
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1520 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1521 |
FOR_ALL_TOWNS_FROM(t, *item - MAX_CLIENT_INFO) { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1522 |
/* Get the town-name via the string-system */ |
4416
442b18840569
(svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents:
4354
diff
changeset
|
1523 |
SetDParam(0, t->townnameparts); |
442b18840569
(svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents:
4354
diff
changeset
|
1524 |
GetString(chat_tab_temp_buffer, t->townnametype); |
4315
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1525 |
return &chat_tab_temp_buffer[0]; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1526 |
} |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1527 |
} |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1528 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1529 |
return NULL; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1530 |
} |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1531 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1532 |
/** |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1533 |
* Find what text to complete. It scans for a space from the left and marks |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1534 |
* the word right from that as to complete. It also writes a \0 at the |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1535 |
* position of the space (if any). If nothing found, buf is returned. |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1536 |
*/ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1537 |
static char *ChatTabCompletionFindText(char *buf) |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1538 |
{ |
4880
aac84a9dcd03
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
1539 |
char *p = strrchr(buf, ' '); |
4319
b4c237cf69c1
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1540 |
if (p == NULL) return buf; |
4315
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1541 |
|
4319
b4c237cf69c1
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1542 |
*p = '\0'; |
b4c237cf69c1
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1543 |
return p + 1; |
4315
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1544 |
} |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1545 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1546 |
/** |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1547 |
* See if we can auto-complete the current text of the user. |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1548 |
*/ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1549 |
static void ChatTabCompletion(Window *w) |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1550 |
{ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1551 |
static char _chat_tab_completion_buf[lengthof(_edit_str_buf)]; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1552 |
Textbuf *tb = &WP(w, querystr_d).text; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1553 |
uint len, tb_len; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1554 |
uint item; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1555 |
char *tb_buf, *pre_buf; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1556 |
const char *cur_name; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1557 |
bool second_scan = false; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1558 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1559 |
item = 0; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1560 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1561 |
/* Copy the buffer so we can modify it without damaging the real data */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1562 |
pre_buf = (_chat_tab_completion_active) ? strdup(_chat_tab_completion_buf) : strdup(tb->buf); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1563 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1564 |
tb_buf = ChatTabCompletionFindText(pre_buf); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1565 |
tb_len = strlen(tb_buf); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1566 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1567 |
while ((cur_name = ChatTabCompletionNextItem(&item)) != NULL) { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1568 |
item++; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1569 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1570 |
if (_chat_tab_completion_active) { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1571 |
/* We are pressing TAB again on the same name, is there an other name |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1572 |
* that starts with this? */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1573 |
if (!second_scan) { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1574 |
uint offset; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1575 |
uint length; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1576 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1577 |
/* If we are completing at the begin of the line, skip the ': ' we added */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1578 |
if (tb_buf == pre_buf) { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1579 |
offset = 0; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1580 |
length = tb->length - 2; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1581 |
} else { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1582 |
/* Else, find the place we are completing at */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1583 |
offset = strlen(pre_buf) + 1; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1584 |
length = tb->length - offset; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1585 |
} |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1586 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1587 |
/* Compare if we have a match */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1588 |
if (strlen(cur_name) == length && strncmp(cur_name, tb->buf + offset, length) == 0) second_scan = true; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1589 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1590 |
continue; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1591 |
} |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1592 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1593 |
/* Now any match we make on _chat_tab_completion_buf after this, is perfect */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1594 |
} |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1595 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1596 |
len = strlen(cur_name); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1597 |
if (tb_len < len && strncasecmp(cur_name, tb_buf, tb_len) == 0) { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1598 |
/* Save the data it was before completion */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1599 |
if (!second_scan) snprintf(_chat_tab_completion_buf, lengthof(_chat_tab_completion_buf), "%s", tb->buf); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1600 |
_chat_tab_completion_active = true; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1601 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1602 |
/* Change to the found name. Add ': ' if we are at the start of the line (pretty) */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1603 |
if (pre_buf == tb_buf) { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1604 |
snprintf(tb->buf, lengthof(_edit_str_buf), "%s: ", cur_name); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1605 |
} else { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1606 |
snprintf(tb->buf, lengthof(_edit_str_buf), "%s %s", pre_buf, cur_name); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1607 |
} |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1608 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1609 |
/* Update the textbuffer */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1610 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1611 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1612 |
SetWindowDirty(w); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1613 |
free(pre_buf); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1614 |
return; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1615 |
} |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1616 |
} |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1617 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1618 |
if (second_scan) { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1619 |
/* We walked all posibilities, and the user presses tab again.. revert to original text */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1620 |
strcpy(tb->buf, _chat_tab_completion_buf); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1621 |
_chat_tab_completion_active = false; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1622 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1623 |
/* Update the textbuffer */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1624 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1625 |
|
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1626 |
SetWindowDirty(w); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1627 |
} |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1628 |
free(pre_buf); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1629 |
} |
4013
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1630 |
|
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
1631 |
/* uses querystr_d WP macro */ |
649 | 1632 |
static void ChatWindowWndProc(Window *w, WindowEvent *e) |
1633 |
{ |
|
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
1634 |
switch (e->event) { |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
1635 |
case WE_CREATE: |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
1636 |
SendWindowMessage(WC_NEWS_WINDOW, 0, WE_CREATE, w->height, 0); |
1843
8e2628948b01
(svn r2348) - Fix: Do not scroll the game with the arrow keys when the chatbox is open
Darkvater
parents:
1796
diff
changeset
|
1637 |
SETBIT(_no_scroll, SCROLL_CHAT); // do not scroll the game with the arrow-keys |
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
1638 |
break; |
649 | 1639 |
|
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
1640 |
case WE_PAINT: |
649 | 1641 |
DrawWindowWidgets(w); |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
1642 |
DrawEditBox(w, &WP(w, querystr_d), 1); |
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
1643 |
break; |
649 | 1644 |
|
1645 |
case WE_CLICK: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1646 |
switch (e->we.click.widget) { |
4013
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1647 |
case 2: /* Send */ SendChat(WP(w, querystr_d).text.buf); /* FALLTHROUGH */ |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1648 |
case 3: /* Cancel */ DeleteWindow(w); break; |
649 | 1649 |
} |
1650 |
break; |
|
1651 |
||
4013
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1652 |
case WE_MOUSELOOP: |
2887
810e555d5249
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2886
diff
changeset
|
1653 |
HandleEditBox(w, &WP(w, querystr_d), 1); |
4013
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1654 |
break; |
649 | 1655 |
|
4013
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1656 |
case WE_KEYPRESS: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4542
diff
changeset
|
1657 |
if (e->we.keypress.keycode == WKC_TAB) { |
4315
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1658 |
ChatTabCompletion(w); |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1659 |
} else { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1660 |
_chat_tab_completion_active = false; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1661 |
switch (HandleEditBoxKey(w, &WP(w, querystr_d), 1, e, CS_ALPHANUMERAL)) { |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1662 |
case 1: /* Return */ SendChat(WP(w, querystr_d).text.buf); /* FALLTHROUGH */ |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1663 |
case 2: /* Escape */ DeleteWindow(w); break; |
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1664 |
} |
649 | 1665 |
} |
4013
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1666 |
break; |
649 | 1667 |
|
1668 |
case WE_DESTROY: |
|
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
1669 |
SendWindowMessage(WC_NEWS_WINDOW, 0, WE_DESTROY, 0, 0); |
1843
8e2628948b01
(svn r2348) - Fix: Do not scroll the game with the arrow keys when the chatbox is open
Darkvater
parents:
1796
diff
changeset
|
1670 |
CLRBIT(_no_scroll, SCROLL_CHAT); |
649 | 1671 |
break; |
1672 |
} |
|
1673 |
} |
|
1674 |
||
1675 |
static const Widget _chat_window_widgets[] = { |
|
1747
a6810868a816
(svn r2251) - Fix: [ 1193945 ] Clicking on the chat text box causes an assertion failure
Darkvater
parents:
1653
diff
changeset
|
1676 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 639, 0, 13, STR_NULL, STR_NULL}, // background |
a6810868a816
(svn r2251) - Fix: [ 1193945 ] Clicking on the chat text box causes an assertion failure
Darkvater
parents:
1653
diff
changeset
|
1677 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 399, 1, 12, STR_NULL, STR_NULL}, // text box |
a6810868a816
(svn r2251) - Fix: [ 1193945 ] Clicking on the chat text box causes an assertion failure
Darkvater
parents:
1653
diff
changeset
|
1678 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 400, 519, 1, 12, STR_NETWORK_SEND, STR_NULL}, // send button |
a6810868a816
(svn r2251) - Fix: [ 1193945 ] Clicking on the chat text box causes an assertion failure
Darkvater
parents:
1653
diff
changeset
|
1679 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 520, 639, 1, 12, STR_012E_CANCEL, STR_NULL}, // cancel button |
649 | 1680 |
{ WIDGETS_END}, |
1681 |
}; |
|
1682 |
||
1683 |
static const WindowDesc _chat_window_desc = { |
|
1684 |
WDP_CENTER, -26, 640, 14, // x, y, width, height |
|
1685 |
WC_SEND_NETWORK_MSG,0, |
|
1748
037f7957cbe9
(svn r2252) - ReFix: Redo r2251. Just remove the 'default widget handler', WDF_STD_BTN, instead of doing the "workaround" of the previous commit
Darkvater
parents:
1747
diff
changeset
|
1686 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET, |
649 | 1687 |
_chat_window_widgets, |
1688 |
ChatWindowWndProc |
|
1689 |
}; |
|
1690 |
||
4013
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1691 |
|
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1692 |
void ShowNetworkChatQueryWindow(byte desttype, byte dest) |
649 | 1693 |
{ |
1694 |
Window *w; |
|
1695 |
||
4013
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1696 |
_chat_type = desttype; |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1697 |
_chat_dest = dest; |
53a7dd9a1fbf
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1698 |
|
649 | 1699 |
DeleteWindowById(WC_SEND_NETWORK_MSG, 0); |
1700 |
||
3464
6e01708de019
(svn r4309) The initial string of the chat box is always the empty string, so don't jump through hoops to check if nothing was entered and simplify the code
tron
parents:
3460
diff
changeset
|
1701 |
_edit_str_buf[0] = '\0'; |
4315
2e634e3ecd02
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1702 |
_chat_tab_completion_active = false; |
649 | 1703 |
|
1704 |
w = AllocateWindowDesc(&_chat_window_desc); |
|
1705 |
||
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1706 |
LowerWindowWidget(w, 1); |
3465
a7ee131a9114
(svn r4310) The chat box has no visible window title, therefore remove the string
tron
parents:
3464
diff
changeset
|
1707 |
WP(w,querystr_d).caption = STR_NULL; |
3468
ec6463161999
(svn r4313) The parent window of the chat box is always the main toolbar (?!), therefore don't pass this information as parameter
tron
parents:
3467
diff
changeset
|
1708 |
WP(w,querystr_d).wnd_class = WC_MAIN_TOOLBAR; |
ec6463161999
(svn r4313) The parent window of the chat box is always the main toolbar (?!), therefore don't pass this information as parameter
tron
parents:
3467
diff
changeset
|
1709 |
WP(w,querystr_d).wnd_num = 0; |
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
|
1710 |
WP(w,querystr_d).text.caret = false; |
3469
3ea3d6e1e611
(svn r4314) -Fix: a buffer overflow of the chat box introduced in r1263. Don't tell the Textbuf an arbitrary number as size of the string buffer, but the real lengthof() it
tron
parents:
3468
diff
changeset
|
1711 |
WP(w,querystr_d).text.maxlength = lengthof(_edit_str_buf); |
3467
4ddbab0eb586
(svn r4312) Calculate the maximum pixel width of the entered text in the chat box from the "text box"-widget instead of hardcoding an arbitrary - and wrong - number
tron
parents:
3465
diff
changeset
|
1712 |
WP(w,querystr_d).text.maxwidth = w->widget[1].right - w->widget[1].left - 2; // widget[1] is the "text box" |
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
|
1713 |
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
|
1714 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
649 | 1715 |
} |
1716 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1717 |
#endif /* ENABLE_NETWORK */ |