author | convert-repo |
Mon, 07 Apr 2008 16:21:55 +0000 | |
changeset 10076 | dfd70e42c4ae |
parent 9234 | 8123d1c8e796 |
child 10170 | 39c950e2ab9d |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
4826
63b1eb7c966b
(svn r6750) -Codechange: Juggle around some header includes as they're only used when
Darkvater
parents:
4774
diff
changeset
|
3 |
#ifdef ENABLE_NETWORK |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5683
diff
changeset
|
4 |
#include "../stdafx.h" |
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5683
diff
changeset
|
5 |
#include "../openttd.h" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8603
diff
changeset
|
6 |
#include "../strings_func.h" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
7 |
#include "network.h" |
8636
2b158acb649c
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8627
diff
changeset
|
8 |
#include "../date_func.h" |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5683
diff
changeset
|
9 |
#include "../fios.h" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
10 |
#include "network_data.h" |
4013
a11adcc2a852
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
11 |
#include "network_client.h" |
4826
63b1eb7c966b
(svn r6750) -Codechange: Juggle around some header includes as they're only used when
Darkvater
parents:
4774
diff
changeset
|
12 |
#include "network_gui.h" |
738
0b2fb79e64fc
(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
|
13 |
#include "network_gamelist.h" |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5683
diff
changeset
|
14 |
#include "../gui.h" |
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
15 |
#include "../window_gui.h" |
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
16 |
#include "../textbuf_gui.h" |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5683
diff
changeset
|
17 |
#include "../variables.h" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
18 |
#include "network_server.h" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
19 |
#include "network_udp.h" |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5683
diff
changeset
|
20 |
#include "../town.h" |
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5683
diff
changeset
|
21 |
#include "../newgrf.h" |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
22 |
#include "../functions.h" |
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
23 |
#include "../window_func.h" |
8709
4187ad809fe7
(svn r11776) -Codechange: more header splittings to reduce the dependencies.
rubidium
parents:
8704
diff
changeset
|
24 |
#include "../core/alloc_func.hpp" |
8710
52015340050c
(svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents:
8709
diff
changeset
|
25 |
#include "../string_func.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8710
diff
changeset
|
26 |
#include "../gfx_func.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8720
diff
changeset
|
27 |
#include "../player_func.h" |
8766
c86cfa3a7580
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8760
diff
changeset
|
28 |
#include "../settings_type.h" |
8780
6f3f3ec6c69a
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
8766
diff
changeset
|
29 |
#include "../widgets/dropdown_func.h" |
0 | 30 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
31 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
32 |
#include "../table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
33 |
|
0 | 34 |
#define BGC 5 |
35 |
#define BTC 15 |
|
2887
d5967e472eee
(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
|
36 |
|
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
37 |
struct chatquerystr_d : public querystr_d { |
9223
3512b3d48703
(svn r12403) -Codechange: unmisuse a variable in the chat window and make the code a little cleaner.
rubidium
parents:
9193
diff
changeset
|
38 |
DestType dtype; |
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
39 |
int dest; |
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
40 |
}; |
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
41 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(chatquerystr_d)); |
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
42 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
43 |
struct network_d { |
3692 | 44 |
PlayerID company; // select company in network lobby |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
45 |
byte field; // select text-field in start-server and game-listing |
7937
a65b8906ba7f
(svn r10888) -Fix (r10886): 64 bits alignment made a struct too big.
rubidium
parents:
7935
diff
changeset
|
46 |
byte widget_id; ///< The widget that has the pop-up input menu |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
47 |
NetworkGameList *server; // selected server in lobby and game-listing |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
48 |
FiosItem *map; // selected map in start-server |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
49 |
}; |
2887
d5967e472eee
(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
|
50 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(network_d)); |
d5967e472eee
(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 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
52 |
struct network_ql_d { |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
53 |
network_d n; // see above; general stuff |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
54 |
querystr_d q; // text-input in start-server and game-listing |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
55 |
NetworkGameList **sort_list; // list of games (sorted) |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
56 |
list_d l; // accompanying list-administration |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
57 |
}; |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
58 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(network_ql_d)); |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
59 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
60 |
/* Global to remember sorting after window has been closed */ |
4542
24f60077489a
(svn r6372) -Codechange: static, unneeded decleration in headers, superfluous header includes
Darkvater
parents:
4512
diff
changeset
|
61 |
static Listing _ng_sorting; |
2887
d5967e472eee
(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
|
62 |
|
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
63 |
static char _edit_str_net_buf[150]; |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
64 |
static bool _chat_tab_completion_active; |
3470
9dc3e8d2fde1
(svn r4315) Remove MAX_QUERYSTR_LEN, rather use lengthof() the real thing
tron
parents:
3469
diff
changeset
|
65 |
|
6573 | 66 |
static void ShowNetworkStartServerWindow(); |
2887
d5967e472eee
(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
|
67 |
static void ShowNetworkLobbyWindow(NetworkGameList *ngl); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
68 |
extern void SwitchMode(int new_mode); |
0 | 69 |
|
70 |
static const StringID _connection_types_dropdown[] = { |
|
675
b120ec0b3e39
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
71 |
STR_NETWORK_LAN_INTERNET, |
b120ec0b3e39
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
72 |
STR_NETWORK_INTERNET_ADVERTISE, |
0 | 73 |
INVALID_STRING_ID |
74 |
}; |
|
75 |
||
764
68b398e2b780
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
76 |
static const StringID _lan_internet_types_dropdown[] = { |
68b398e2b780
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
77 |
STR_NETWORK_LAN, |
68b398e2b780
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
78 |
STR_NETWORK_INTERNET, |
68b398e2b780
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
79 |
INVALID_STRING_ID |
68b398e2b780
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
80 |
}; |
68b398e2b780
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
81 |
|
7292
d4cf2baf26ae
(svn r10035) -Change: simplified network language string sorting
glx
parents:
7289
diff
changeset
|
82 |
static StringID _language_dropdown[NETLANG_COUNT + 1] = {STR_NULL}; |
7289
d6a004877931
(svn r10032) -Add: sort the strings in server language dropdown
glx
parents:
7276
diff
changeset
|
83 |
|
7817
f24498d934ac
(svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents:
7717
diff
changeset
|
84 |
void SortNetworkLanguages() |
f24498d934ac
(svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents:
7717
diff
changeset
|
85 |
{ |
7292
d4cf2baf26ae
(svn r10035) -Change: simplified network language string sorting
glx
parents:
7289
diff
changeset
|
86 |
/* Init the strings */ |
d4cf2baf26ae
(svn r10035) -Change: simplified network language string sorting
glx
parents:
7289
diff
changeset
|
87 |
if (_language_dropdown[0] == STR_NULL) { |
d4cf2baf26ae
(svn r10035) -Change: simplified network language string sorting
glx
parents:
7289
diff
changeset
|
88 |
for (int i = 0; i < NETLANG_COUNT; i++) _language_dropdown[i] = STR_NETWORK_LANG_ANY + i; |
d4cf2baf26ae
(svn r10035) -Change: simplified network language string sorting
glx
parents:
7289
diff
changeset
|
89 |
_language_dropdown[NETLANG_COUNT] = INVALID_STRING_ID; |
d4cf2baf26ae
(svn r10035) -Change: simplified network language string sorting
glx
parents:
7289
diff
changeset
|
90 |
} |
7289
d6a004877931
(svn r10032) -Add: sort the strings in server language dropdown
glx
parents:
7276
diff
changeset
|
91 |
|
7292
d4cf2baf26ae
(svn r10035) -Change: simplified network language string sorting
glx
parents:
7289
diff
changeset
|
92 |
/* Sort the strings (we don't move 'any' and the 'invalid' one) */ |
d4cf2baf26ae
(svn r10035) -Change: simplified network language string sorting
glx
parents:
7289
diff
changeset
|
93 |
qsort(&_language_dropdown[1], NETLANG_COUNT - 1, sizeof(StringID), &StringIDSorter); |
7289
d6a004877931
(svn r10032) -Add: sort the strings in server language dropdown
glx
parents:
7276
diff
changeset
|
94 |
} |
7276
fdb2191fac67
(svn r10017) -Add (FS#790): more languages flags for servers
glx
parents:
7027
diff
changeset
|
95 |
|
211 | 96 |
enum { |
2881
1ffbbdbf1685
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
97 |
NET_PRC__OFFSET_TOP_WIDGET = 54, |
2887
d5967e472eee
(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
|
98 |
NET_PRC__OFFSET_TOP_WIDGET_COMPANY = 52, |
2881
1ffbbdbf1685
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
99 |
NET_PRC__SIZE_OF_ROW = 14, |
211 | 100 |
}; |
101 |
||
5035
e5680cce4e67
(svn r7077) -Codechange: Send proper message to network window, and handle selection control in
Darkvater
parents:
4957
diff
changeset
|
102 |
/** Update the network new window because a new server is |
e5680cce4e67
(svn r7077) -Codechange: Send proper message to network window, and handle selection control in
Darkvater
parents:
4957
diff
changeset
|
103 |
* found on the network. |
e5680cce4e67
(svn r7077) -Codechange: Send proper message to network window, and handle selection control in
Darkvater
parents:
4957
diff
changeset
|
104 |
* @param unselect unselect the currently selected item */ |
897
42412d5ecc64
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
105 |
void UpdateNetworkGameWindow(bool unselect) |
42412d5ecc64
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
106 |
{ |
5035
e5680cce4e67
(svn r7077) -Codechange: Send proper message to network window, and handle selection control in
Darkvater
parents:
4957
diff
changeset
|
107 |
SendWindowMessage(WC_NETWORK_WINDOW, 0, unselect, 0, 0); |
897
42412d5ecc64
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
108 |
} |
42412d5ecc64
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
dominik
parents:
893
diff
changeset
|
109 |
|
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
110 |
static bool _internal_sort_order; // Used for Qsort order-flipping |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
111 |
typedef int CDECL NGameNameSortFunction(const void*, const void*); |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
112 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
113 |
/** Qsort function to sort by name. */ |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
114 |
static int CDECL NGameNameSorter(const void *a, const void *b) |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
115 |
{ |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
116 |
const NetworkGameList *cmp1 = *(const NetworkGameList**)a; |
0972346d11a8
(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 *cmp2 = *(const NetworkGameList**)b; |
2889
ac841003c51e
(svn r3442) - Fix: Only windows has stricmp. So define strcasecmp to stricmp when using MSVC
Darkvater
parents:
2888
diff
changeset
|
118 |
int r = strcasecmp(cmp1->info.server_name, cmp2->info.server_name); |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
119 |
|
4880
0708f34e3586
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
120 |
return _internal_sort_order ? -r : r; |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
121 |
} |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
122 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
123 |
/** Qsort function to sort by the amount of clients online on a |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
124 |
* server. If the two servers have the same amount, the one with the |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
125 |
* higher maximum is preferred. */ |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
126 |
static int CDECL NGameClientSorter(const void *a, const void *b) |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
127 |
{ |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
128 |
const NetworkGameList *cmp1 = *(const NetworkGameList**)a; |
0972346d11a8
(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 *cmp2 = *(const NetworkGameList**)b; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
130 |
/* Reverse as per default we are interested in most-clients first */ |
4195
65070272012d
(svn r5655) -Fix [SF 1424115]: Reversed arrow-sign in the multiplayer list column headers on sort by name
Darkvater
parents:
4171
diff
changeset
|
131 |
int r = cmp1->info.clients_on - cmp2->info.clients_on; |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
132 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
133 |
if (r == 0) r = cmp1->info.clients_max - cmp2->info.clients_max; |
2922
61cf61d25de9
(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
|
134 |
if (r == 0) r = strcasecmp(cmp1->info.server_name, cmp2->info.server_name); |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
135 |
|
4880
0708f34e3586
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
136 |
return _internal_sort_order ? -r : r; |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
137 |
} |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
138 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
139 |
/** Qsort function to sort by joinability. If both servers are the |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
140 |
* same, prefer the non-passworded server first. */ |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
141 |
static int CDECL NGameAllowedSorter(const void *a, const void *b) |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
142 |
{ |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
143 |
const NetworkGameList *cmp1 = *(const NetworkGameList**)a; |
0972346d11a8
(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 *cmp2 = *(const NetworkGameList**)b; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
145 |
|
5909
edf0f4a1f118
(svn r8118) -Codechange: change the ordering of the network list a little:
rubidium
parents:
5860
diff
changeset
|
146 |
/* The servers we do not know anything about (the ones that did not reply) should be at the bottom) */ |
edf0f4a1f118
(svn r8118) -Codechange: change the ordering of the network list a little:
rubidium
parents:
5860
diff
changeset
|
147 |
int r = StrEmpty(cmp1->info.server_revision) - StrEmpty(cmp2->info.server_revision); |
edf0f4a1f118
(svn r8118) -Codechange: change the ordering of the network list a little:
rubidium
parents:
5860
diff
changeset
|
148 |
|
edf0f4a1f118
(svn r8118) -Codechange: change the ordering of the network list a little:
rubidium
parents:
5860
diff
changeset
|
149 |
/* Reverse default as we are interested in version-compatible clients first */ |
edf0f4a1f118
(svn r8118) -Codechange: change the ordering of the network list a little:
rubidium
parents:
5860
diff
changeset
|
150 |
if (r == 0) r = cmp2->info.version_compatible - cmp1->info.version_compatible; |
edf0f4a1f118
(svn r8118) -Codechange: change the ordering of the network list a little:
rubidium
parents:
5860
diff
changeset
|
151 |
/* The version-compatible ones are then sorted with NewGRF compatible first, incompatible last */ |
edf0f4a1f118
(svn r8118) -Codechange: change the ordering of the network list a little:
rubidium
parents:
5860
diff
changeset
|
152 |
if (r == 0) r = cmp2->info.compatible - cmp1->info.compatible; |
edf0f4a1f118
(svn r8118) -Codechange: change the ordering of the network list a little:
rubidium
parents:
5860
diff
changeset
|
153 |
/* Passworded servers should be below unpassworded servers */ |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
154 |
if (r == 0) r = cmp1->info.use_password - cmp2->info.use_password; |
5909
edf0f4a1f118
(svn r8118) -Codechange: change the ordering of the network list a little:
rubidium
parents:
5860
diff
changeset
|
155 |
/* Finally sort on the name of the server */ |
2922
61cf61d25de9
(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
|
156 |
if (r == 0) r = strcasecmp(cmp1->info.server_name, cmp2->info.server_name); |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
157 |
|
4880
0708f34e3586
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
158 |
return _internal_sort_order ? -r : r; |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
159 |
} |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
160 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
161 |
/** (Re)build the network game list as its amount has changed because |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
162 |
* an item has been added or deleted for example |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
163 |
* @param ngl list_d struct that contains all necessary information for sorting */ |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
164 |
static void BuildNetworkGameList(network_ql_d *nqld) |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
165 |
{ |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
166 |
NetworkGameList *ngl_temp; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
167 |
uint n = 0; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
168 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
169 |
if (!(nqld->l.flags & VL_REBUILD)) return; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
170 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
171 |
/* Count the number of games in the list */ |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
172 |
for (ngl_temp = _network_game_list; ngl_temp != NULL; ngl_temp = ngl_temp->next) n++; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
173 |
if (n == 0) return; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
174 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
175 |
/* Create temporary array of games to use for listing */ |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
176 |
free(nqld->sort_list); |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5838
diff
changeset
|
177 |
nqld->sort_list = MallocT<NetworkGameList*>(n); |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
178 |
nqld->l.list_length = n; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
179 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
180 |
for (n = 0, ngl_temp = _network_game_list; ngl_temp != NULL; ngl_temp = ngl_temp->next) { |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
181 |
nqld->sort_list[n++] = ngl_temp; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
182 |
} |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
183 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
184 |
/* Force resort */ |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
185 |
nqld->l.flags &= ~VL_REBUILD; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
186 |
nqld->l.flags |= VL_RESORT; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
187 |
} |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
188 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
189 |
static void SortNetworkGameList(network_ql_d *nqld) |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
190 |
{ |
4171 | 191 |
static NGameNameSortFunction * const ngame_sorter[] = { |
3860
ca80f6d89fa1
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
192 |
&NGameNameSorter, |
ca80f6d89fa1
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
193 |
&NGameClientSorter, |
ca80f6d89fa1
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
194 |
&NGameAllowedSorter |
ca80f6d89fa1
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
195 |
}; |
ca80f6d89fa1
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
196 |
|
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
197 |
NetworkGameList *item; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
198 |
uint i; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
199 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
200 |
if (!(nqld->l.flags & VL_RESORT)) return; |
3860
ca80f6d89fa1
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
201 |
if (nqld->l.list_length == 0) return; |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
202 |
|
4880
0708f34e3586
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
203 |
_internal_sort_order = !!(nqld->l.flags & VL_DESC); |
3860
ca80f6d89fa1
(svn r4892) - Fix [FS#162]: SEGV when sorting an empty server list. (glx)
Darkvater
parents:
3692
diff
changeset
|
204 |
qsort(nqld->sort_list, nqld->l.list_length, sizeof(nqld->sort_list[0]), ngame_sorter[nqld->l.sort_type]); |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
205 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
206 |
/* After sorting ngl->sort_list contains the sorted items. Put these back |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
207 |
* into the original list. Basically nothing has changed, we are only |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
208 |
* shuffling the ->next pointers */ |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
209 |
_network_game_list = nqld->sort_list[0]; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
210 |
for (item = _network_game_list, i = 1; i != nqld->l.list_length; i++) { |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
211 |
item->next = nqld->sort_list[i]; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
212 |
item = item->next; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
213 |
} |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
214 |
item->next = NULL; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
215 |
|
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
216 |
nqld->l.flags &= ~VL_RESORT; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
217 |
} |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
218 |
|
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
219 |
/** Enum for NetworkGameWindow, referring to _network_game_window_widgets */ |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
220 |
enum NetworkGameWindowWidgets { |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
221 |
NGWW_CLOSE = 0, ///< Close 'X' button |
8839
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
222 |
NGWW_CONN_BTN = 4, ///< 'Connection' droplist button |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
223 |
NGWW_PLAYER = 5, ///< Panel with editbox to set player name |
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
224 |
|
8839
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
225 |
NGWW_NAME = 6, ///< 'Name' button |
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
226 |
NGWW_CLIENTS, ///< 'Clients' button |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
227 |
NGWW_INFO, ///< Third button in the game list panel |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
228 |
|
8839
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
229 |
NGWW_MATRIX = 9, ///< Panel with list of games |
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
230 |
|
8839
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
231 |
NGWW_DETAILS = 11, ///< Panel with game details |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
232 |
NGWW_JOIN = 12, ///< 'Join game' button |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
233 |
NGWW_REFRESH = 13, ///< 'Refresh server' button |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
234 |
NGWW_NEWGRF = 14, ///< 'NewGRF Settings' button |
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
235 |
|
8839
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
236 |
NGWW_FIND = 15, ///< 'Find server' button |
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
237 |
NGWW_ADD, ///< 'Add server' button |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
238 |
NGWW_START, ///< 'Start server' button |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
239 |
NGWW_CANCEL, ///< 'Cancel' button |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
240 |
}; |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
241 |
|
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
242 |
/** |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
243 |
* Handler of actions done in the NetworkStartServer window |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
244 |
* |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
245 |
* @param w pointer to the Window structure |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
246 |
* @param e pointer to window event |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
247 |
* @note Uses network_ql_d (network_d, querystr_d and list_d) WP macro |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
248 |
* @see struct _network_game_window_widgets |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
249 |
* @see enum NetworkGameWindowWidgets |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
250 |
*/ |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
251 |
|
0 | 252 |
static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) |
253 |
{ |
|
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
254 |
network_d *nd = &WP(w, network_ql_d).n; |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
255 |
list_d *ld = &WP(w, network_ql_d).l; |
2887
d5967e472eee
(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
|
256 |
|
1653
3eed36c12b1d
(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
Darkvater
parents:
1648
diff
changeset
|
257 |
switch (e->event) { |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
258 |
case WE_CREATE: // Focus input box |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
259 |
w->vscroll.cap = 13; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
260 |
w->resize.step_height = NET_PRC__SIZE_OF_ROW; |
2071
37c57d697d9b
(svn r2581) Fix: Behave a bit safer if central server sends bogus information about clients.
ludde
parents:
2064
diff
changeset
|
261 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
262 |
nd->field = NGWW_PLAYER; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
263 |
nd->server = NULL; |
5339
7573f179efe8
(svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents:
5247
diff
changeset
|
264 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
265 |
WP(w, network_ql_d).sort_list = NULL; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
266 |
ld->flags = VL_REBUILD | (_ng_sorting.order ? VL_DESC : VL_NONE); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
267 |
ld->sort_type = _ng_sorting.criteria; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
268 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
269 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
270 |
case WE_PAINT: { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
271 |
const NetworkGameList *sel = nd->server; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
272 |
const SortButtonState arrow = (ld->flags & VL_DESC) ? SBS_DOWN : SBS_UP; |
0 | 273 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
274 |
if (ld->flags & VL_REBUILD) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
275 |
BuildNetworkGameList(&WP(w, network_ql_d)); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
276 |
SetVScrollCount(w, ld->list_length); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
277 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
278 |
if (ld->flags & VL_RESORT) SortNetworkGameList(&WP(w, network_ql_d)); |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
279 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
280 |
/* 'Refresh' button invisible if no server selected */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
281 |
w->SetWidgetDisabledState(NGWW_REFRESH, sel == NULL); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
282 |
/* 'Join' button disabling conditions */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
283 |
w->SetWidgetDisabledState(NGWW_JOIN, sel == NULL || // no Selected Server |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
284 |
!sel->online || // Server offline |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
285 |
sel->info.clients_on >= sel->info.clients_max || // Server full |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
286 |
!sel->info.compatible); // Revision mismatch |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
287 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
288 |
/* 'NewGRF Settings' button invisible if no NewGRF is used */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
289 |
w->SetWidgetHiddenState(NGWW_NEWGRF, sel == NULL || |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
290 |
!sel->online || |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
291 |
sel->info.grfconfig == NULL); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
292 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
293 |
SetDParam(0, 0x00); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
294 |
SetDParam(1, _lan_internet_types_dropdown[_network_lan_internet]); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
295 |
DrawWindowWidgets(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
296 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
297 |
/* Edit box to set player name */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
298 |
DrawEditBox(w, &WP(w, network_ql_d).q, NGWW_PLAYER); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
299 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
300 |
DrawString(w->widget[NGWW_PLAYER].left - 100, 23, STR_NETWORK_PLAYER_NAME, TC_GOLD); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
301 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
302 |
/* Sort based on widgets: name, clients, compatibility */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
303 |
switch (ld->sort_type) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
304 |
case NGWW_NAME - NGWW_NAME: DrawSortButtonState(w, NGWW_NAME, arrow); break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
305 |
case NGWW_CLIENTS - NGWW_NAME: DrawSortButtonState(w, NGWW_CLIENTS, arrow); break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
306 |
case NGWW_INFO - NGWW_NAME: DrawSortButtonState(w, NGWW_INFO, arrow); break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
307 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
308 |
|
211 | 309 |
uint16 y = NET_PRC__OFFSET_TOP_WIDGET + 3; |
310 |
int32 n = 0; |
|
809
86cc46f97149
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
311 |
int32 pos = w->vscroll.pos; |
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
312 |
uint max_name_width = w->widget[NGWW_NAME].right - w->widget[NGWW_NAME].left - 5; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
313 |
const NetworkGameList *cur_item = _network_game_list; |
809
86cc46f97149
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
314 |
|
86cc46f97149
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
315 |
while (pos > 0 && cur_item != NULL) { |
86cc46f97149
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
316 |
pos--; |
808
d4b76579b3d0
(svn r1279) Fixed the scrollbar in the network gui(server list). It now updates when scrolling (HackyKid)
bjarni
parents:
793
diff
changeset
|
317 |
cur_item = cur_item->next; |
d4b76579b3d0
(svn r1279) Fixed the scrollbar in the network gui(server list). It now updates when scrolling (HackyKid)
bjarni
parents:
793
diff
changeset
|
318 |
} |
809
86cc46f97149
(svn r1280) -Codechange: made the last patch a bit more... readable (in other words:
truelight
parents:
808
diff
changeset
|
319 |
|
211 | 320 |
while (cur_item != NULL) { |
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
321 |
/* show highlighted item with a different colour */ |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
322 |
if (cur_item == sel) GfxFillRect(w->widget[NGWW_NAME].left + 1, y - 2, w->widget[NGWW_INFO].right - 1, y + 9, 10); |
211 | 323 |
|
2100
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2071
diff
changeset
|
324 |
SetDParamStr(0, cur_item->info.server_name); |
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
325 |
DrawStringTruncated(w->widget[NGWW_NAME].left + 5, y, STR_02BD, TC_BLACK, max_name_width); |
211 | 326 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
327 |
SetDParam(0, cur_item->info.clients_on); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
328 |
SetDParam(1, cur_item->info.clients_max); |
2879
d270cb37c0ec
(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
|
329 |
SetDParam(2, cur_item->info.companies_on); |
d270cb37c0ec
(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(3, cur_item->info.companies_max); |
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
331 |
DrawStringCentered(w->widget[NGWW_CLIENTS].left + 39, y, STR_NETWORK_GENERAL_ONLINE, TC_GOLD); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
332 |
|
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
333 |
/* only draw icons if the server is online */ |
591
dd8f0291652b
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
334 |
if (cur_item->online) { |
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
335 |
/* draw a lock if the server is password protected */ |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
336 |
if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, w->widget[NGWW_INFO].left + 5, y - 1); |
591
dd8f0291652b
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
337 |
|
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
338 |
/* draw red or green icon, depending on compatibility with server */ |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
339 |
DrawSprite(SPR_BLOT, (cur_item->info.compatible ? PALETTE_TO_GREEN : (cur_item->info.version_compatible ? PALETTE_TO_YELLOW : PALETTE_TO_RED)), w->widget[NGWW_INFO].left + 15, y); |
591
dd8f0291652b
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
340 |
|
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
341 |
/* draw flag according to server language */ |
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
342 |
DrawSprite(SPR_FLAGS_BASE + cur_item->info.server_lang, PAL_NONE, w->widget[NGWW_INFO].left + 25, y); |
579
08ce4c50bd32
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
543
diff
changeset
|
343 |
} |
591
dd8f0291652b
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
344 |
|
dd8f0291652b
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
345 |
cur_item = cur_item->next; |
dd8f0291652b
(svn r1012) -Fix: [Network] Endless loop if a server was offline (WizKid)
truelight
parents:
579
diff
changeset
|
346 |
y += NET_PRC__SIZE_OF_ROW; |
2549 | 347 |
if (++n == w->vscroll.cap) break; // max number of games in the window |
211 | 348 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
349 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
350 |
/* Draw the right menu */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
351 |
GfxFillRect(w->widget[NGWW_DETAILS].left + 1, 43, w->widget[NGWW_DETAILS].right - 1, 92, 157); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
352 |
if (sel == NULL) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
353 |
DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, 58, STR_NETWORK_GAME_INFO, TC_FROMSTRING); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
354 |
} else if (!sel->online) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
355 |
SetDParamStr(0, sel->info.server_name); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
356 |
DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, 68, STR_ORANGE, TC_FROMSTRING); // game name |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
357 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
358 |
DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, 132, STR_NETWORK_SERVER_OFFLINE, TC_FROMSTRING); // server offline |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
359 |
} else { // show game info |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
360 |
uint16 y = 100; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
361 |
const uint16 x = w->widget[NGWW_DETAILS].left + 5; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
362 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
363 |
DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, 48, STR_NETWORK_GAME_INFO, TC_FROMSTRING); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
364 |
|
2055
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
1916
diff
changeset
|
365 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
366 |
SetDParamStr(0, sel->info.server_name); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
367 |
DrawStringCenteredTruncated(w->widget[NGWW_DETAILS].left, w->widget[NGWW_DETAILS].right, 62, STR_ORANGE, TC_BLACK); // game name |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
368 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
369 |
SetDParamStr(0, sel->info.map_name); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
370 |
DrawStringCenteredTruncated(w->widget[NGWW_DETAILS].left, w->widget[NGWW_DETAILS].right, 74, STR_02BD, TC_BLACK); // map name |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
371 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
372 |
SetDParam(0, sel->info.clients_on); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
373 |
SetDParam(1, sel->info.clients_max); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
374 |
SetDParam(2, sel->info.companies_on); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
375 |
SetDParam(3, sel->info.companies_max); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
376 |
DrawString(x, y, STR_NETWORK_CLIENTS, TC_GOLD); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
377 |
y += 10; |
622
3da5b736ca84
(svn r1052) -Fix: [Network] You can't join a server when revision mismatches.
truelight
parents:
621
diff
changeset
|
378 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
379 |
SetDParam(0, STR_NETWORK_LANG_ANY + sel->info.server_lang); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
380 |
DrawString(x, y, STR_NETWORK_LANGUAGE, TC_GOLD); // server language |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
381 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
382 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
383 |
SetDParam(0, STR_TEMPERATE_LANDSCAPE + sel->info.map_set); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
384 |
DrawString(x, y, STR_NETWORK_TILESET, TC_GOLD); // tileset |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
385 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
386 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
387 |
SetDParam(0, sel->info.map_width); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
388 |
SetDParam(1, sel->info.map_height); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
389 |
DrawString(x, y, STR_NETWORK_MAP_SIZE, TC_GOLD); // map size |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
390 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
391 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
392 |
SetDParamStr(0, sel->info.server_revision); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
393 |
DrawString(x, y, STR_NETWORK_SERVER_VERSION, TC_GOLD); // server version |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
394 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
395 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
396 |
SetDParamStr(0, sel->info.hostname); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
397 |
SetDParam(1, sel->port); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
398 |
DrawString(x, y, STR_NETWORK_SERVER_ADDRESS, TC_GOLD); // server address |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
399 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
400 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
401 |
SetDParam(0, sel->info.start_date); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
402 |
DrawString(x, y, STR_NETWORK_START_DATE, TC_GOLD); // start date |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
403 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
404 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
405 |
SetDParam(0, sel->info.game_date); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
406 |
DrawString(x, y, STR_NETWORK_CURRENT_DATE, TC_GOLD); // current date |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
407 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
408 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
409 |
y += 2; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
410 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
411 |
if (!sel->info.compatible) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
412 |
DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, y, sel->info.version_compatible ? STR_NETWORK_GRF_MISMATCH : STR_NETWORK_VERSION_MISMATCH, TC_FROMSTRING); // server mismatch |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
413 |
} else if (sel->info.clients_on == sel->info.clients_max) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
414 |
/* Show: server full, when clients_on == clients_max */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
415 |
DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, y, STR_NETWORK_SERVER_FULL, TC_FROMSTRING); // server full |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
416 |
} else if (sel->info.use_password) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
417 |
DrawStringCentered(w->widget[NGWW_DETAILS].left + 115, y, STR_NETWORK_PASSWORD, TC_FROMSTRING); // password warning |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
418 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
419 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
420 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
421 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
422 |
} break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
423 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
424 |
case WE_CLICK: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
425 |
nd->field = e->we.click.widget; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
426 |
switch (e->we.click.widget) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
427 |
case NGWW_PLAYER: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
428 |
ShowOnScreenKeyboard(w, &WP(w, network_ql_d).q, NGWW_PLAYER, 0, 0); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
429 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
430 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
431 |
case NGWW_CANCEL: // Cancel button |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
432 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
433 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
434 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
435 |
case NGWW_CONN_BTN: // 'Connection' droplist |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
436 |
ShowDropDownMenu(w, _lan_internet_types_dropdown, _network_lan_internet, NGWW_CONN_BTN, 0, 0); // do it for widget NSSW_CONN_BTN |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
437 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
438 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
439 |
case NGWW_NAME: // Sort by name |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
440 |
case NGWW_CLIENTS: // Sort by connected clients |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
441 |
case NGWW_INFO: // Connectivity (green dot) |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
442 |
if (ld->sort_type == e->we.click.widget - NGWW_NAME) ld->flags ^= VL_DESC; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
443 |
ld->flags |= VL_RESORT; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
444 |
ld->sort_type = e->we.click.widget - NGWW_NAME; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
445 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
446 |
_ng_sorting.order = !!(ld->flags & VL_DESC); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
447 |
_ng_sorting.criteria = ld->sort_type; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
448 |
SetWindowDirty(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
449 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
450 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
451 |
case NGWW_MATRIX: { // Matrix to show networkgames |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
452 |
NetworkGameList *cur_item; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
453 |
uint32 id_v = (e->we.click.pt.y - NET_PRC__OFFSET_TOP_WIDGET) / NET_PRC__SIZE_OF_ROW; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
454 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
455 |
if (id_v >= w->vscroll.cap) return; // click out of bounds |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
456 |
id_v += w->vscroll.pos; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
457 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
458 |
cur_item = _network_game_list; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
459 |
for (; id_v > 0 && cur_item != NULL; id_v--) cur_item = cur_item->next; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
460 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
461 |
nd->server = cur_item; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
462 |
SetWindowDirty(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
463 |
} break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
464 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
465 |
case NGWW_FIND: // Find server automatically |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
466 |
switch (_network_lan_internet) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
467 |
case 0: NetworkUDPSearchGame(); break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
468 |
case 1: NetworkUDPQueryMasterServer(); break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
469 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
470 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
471 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
472 |
case NGWW_ADD: // Add a server |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
473 |
ShowQueryString( |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
474 |
BindCString(_network_default_ip), |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
475 |
STR_NETWORK_ENTER_IP, |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
476 |
31 | 0x1000, // maximum number of characters OR |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
477 |
250, // characters up to this width pixels, whichever is satisfied first |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
478 |
w, CS_ALPHANUMERAL); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
479 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
480 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
481 |
case NGWW_START: // Start server |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
482 |
ShowNetworkStartServerWindow(); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
483 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
484 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
485 |
case NGWW_JOIN: // Join Game |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
486 |
if (nd->server != NULL) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
487 |
snprintf(_network_last_host, sizeof(_network_last_host), "%s", inet_ntoa(*(struct in_addr *)&nd->server->ip)); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
488 |
_network_last_port = nd->server->port; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
489 |
ShowNetworkLobbyWindow(nd->server); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
490 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
491 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
492 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
493 |
case NGWW_REFRESH: // Refresh |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
494 |
if (nd->server != NULL) NetworkUDPQueryServer(nd->server->info.hostname, nd->server->port); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
495 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
496 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
497 |
case NGWW_NEWGRF: // NewGRF Settings |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
498 |
if (nd->server != NULL) ShowNewGRFSettings(false, false, false, &nd->server->info.grfconfig); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
499 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
500 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
501 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
502 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
503 |
case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
504 |
switch (e->we.dropdown.button) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
505 |
case NGWW_CONN_BTN: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
506 |
_network_lan_internet = e->we.dropdown.index; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
507 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
508 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
509 |
default: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
510 |
NOT_REACHED(); |
2639 | 511 |
} |
659
a98c731921b4
(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
|
512 |
|
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
513 |
SetWindowDirty(w); |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
514 |
break; |
211 | 515 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
516 |
case WE_MOUSELOOP: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
517 |
if (nd->field == NGWW_PLAYER) HandleEditBox(w, &WP(w, network_ql_d).q, NGWW_PLAYER); |
5339
7573f179efe8
(svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents:
5247
diff
changeset
|
518 |
break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
519 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
520 |
case WE_MESSAGE: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
521 |
if (e->we.message.msg != 0) nd->server = NULL; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
522 |
ld->flags |= VL_REBUILD; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
523 |
SetWindowDirty(w); |
741
39a3958887c1
(svn r1197) -Fix: [GUI] in r1194 someone deleted too much code from WE_KEYPRESS. Now
truelight
parents:
738
diff
changeset
|
524 |
break; |
39a3958887c1
(svn r1197) -Fix: [GUI] in r1194 someone deleted too much code from WE_KEYPRESS. Now
truelight
parents:
738
diff
changeset
|
525 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
526 |
case WE_KEYPRESS: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
527 |
if (nd->field != NGWW_PLAYER) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
528 |
if (nd->server != NULL) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
529 |
if (e->we.keypress.keycode == WKC_DELETE) { // Press 'delete' to remove servers |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
530 |
NetworkGameListRemoveItem(nd->server); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
531 |
NetworkRebuildHostList(); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
532 |
nd->server = NULL; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
533 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
534 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
535 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
536 |
} |
7839
5c43edaa9de0
(svn r10706) -Codechange: allow resizing the multiplayer server list window.
rubidium
parents:
7837
diff
changeset
|
537 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
538 |
if (HandleEditBoxKey(w, &WP(w, network_ql_d).q, NGWW_PLAYER, e) == 1) break; // enter pressed |
7839
5c43edaa9de0
(svn r10706) -Codechange: allow resizing the multiplayer server list window.
rubidium
parents:
7837
diff
changeset
|
539 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
540 |
/* The name is only allowed when it starts with a letter! */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
541 |
if (_edit_str_net_buf[0] != '\0' && _edit_str_net_buf[0] != ' ') { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
542 |
ttd_strlcpy(_network_player_name, _edit_str_net_buf, lengthof(_network_player_name)); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
543 |
} else { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
544 |
ttd_strlcpy(_network_player_name, "Player", lengthof(_network_player_name)); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
545 |
} |
7839
5c43edaa9de0
(svn r10706) -Codechange: allow resizing the multiplayer server list window.
rubidium
parents:
7837
diff
changeset
|
546 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
547 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
548 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
549 |
case WE_ON_EDIT_TEXT: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
550 |
NetworkAddServer(e->we.edittext.str); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
551 |
NetworkRebuildHostList(); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
552 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
553 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
554 |
case WE_RESIZE: { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
555 |
w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
556 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
557 |
w->widget[NGWW_MATRIX].data = (w->vscroll.cap << 8) + 1; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
558 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
559 |
SetVScrollCount(w, ld->list_length); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
560 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
561 |
int widget_width = w->widget[NGWW_FIND].right - w->widget[NGWW_FIND].left; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
562 |
int space = (w->width - 4 * widget_width - 25) / 3; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
563 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
564 |
int offset = 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
565 |
for (uint i = 0; i < 4; i++) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
566 |
w->widget[NGWW_FIND + i].left = offset; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
567 |
offset += widget_width; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
568 |
w->widget[NGWW_FIND + i].right = offset; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
569 |
offset += space; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
570 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
571 |
} break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
572 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
573 |
case WE_DESTROY: // Nicely clean up the sort-list |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
574 |
free(WP(w, network_ql_d).sort_list); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
575 |
break; |
0 | 576 |
} |
577 |
} |
|
578 |
||
579 |
static const Widget _network_game_window_widgets[] = { |
|
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
580 |
/* TOP */ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
581 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // NGWW_CLOSE |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
582 |
{ WWT_CAPTION, RESIZE_RIGHT, BGC, 11, 449, 0, 13, STR_NETWORK_MULTIPLAYER, STR_NULL}, |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
583 |
{ WWT_PANEL, RESIZE_RB, BGC, 0, 449, 14, 263, 0x0, STR_NULL}, |
0 | 584 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
585 |
{ WWT_TEXT, RESIZE_NONE, BGC, 9, 85, 23, 35, STR_NETWORK_CONNECTION, STR_NULL}, |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
586 |
{ WWT_DROPDOWNIN, RESIZE_NONE, BGC, 90, 181, 22, 33, STR_NETWORK_LAN_INTERNET_COMBO, STR_NETWORK_CONNECTION_TIP}, // NGWW_CONN_BTN |
2881
1ffbbdbf1685
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
587 |
|
9233
4daa9bb8dbf7
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
9224
diff
changeset
|
588 |
{ WWT_EDITBOX, RESIZE_LR, BGC, 290, 440, 22, 33, STR_NETWORK_PLAYER_NAME_OSKTITLE, STR_NETWORK_ENTER_NAME_TIP}, // NGWW_PLAYER |
4344
5d0e40cd67b9
(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
|
589 |
|
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
590 |
/* LEFT SIDE */ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
591 |
{ WWT_PUSHTXTBTN, RESIZE_RIGHT, BTC, 10, 70, 42, 53, STR_NETWORK_GAME_NAME, STR_NETWORK_GAME_NAME_TIP}, // NGWW_NAME |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
592 |
{ WWT_PUSHTXTBTN, RESIZE_LR, BTC, 71, 150, 42, 53, STR_NETWORK_CLIENTS_CAPTION, STR_NETWORK_CLIENTS_CAPTION_TIP}, // NGWW_CLIENTS |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
593 |
{ WWT_PUSHTXTBTN, RESIZE_LR, BTC, 151, 190, 42, 53, STR_EMPTY, STR_NETWORK_INFO_ICONS_TIP}, // NGWW_INFO |
7935
b5bc2bd79e6b
(svn r10886) -Codechange: modify the "start network server" GUI so it can actually handle more than 10 clients/companies/spectators in a nice way, i.e. without making a combobox with 100 players and add 90 new strings to be able to do so.
rubidium
parents:
7859
diff
changeset
|
594 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
595 |
{ WWT_MATRIX, RESIZE_RB, BGC, 10, 190, 54, 236, (13 << 8) + 1, STR_NETWORK_CLICK_GAME_TO_SELECT}, // NGWW_MATRIX |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
596 |
{ WWT_SCROLLBAR, RESIZE_LRB, BGC, 191, 202, 42, 236, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
597 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
598 |
/* RIGHT SIDE */ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
599 |
{ WWT_PANEL, RESIZE_LRB, BGC, 210, 440, 42, 236, 0x0, STR_NULL}, // NGWW_DETAILS |
2881
1ffbbdbf1685
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
600 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
601 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, BTC, 215, 315, 215, 226, STR_NETWORK_JOIN_GAME, STR_NULL}, // NGWW_JOIN |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
602 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, BTC, 330, 435, 215, 226, STR_NETWORK_REFRESH, STR_NETWORK_REFRESH_TIP}, // NGWW_REFRESH |
5339
7573f179efe8
(svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents:
5247
diff
changeset
|
603 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
604 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, BTC, 330, 435, 197, 208, STR_NEWGRF_SETTINGS_BUTTON, STR_NULL}, // NGWW_NEWGRF |
7839
5c43edaa9de0
(svn r10706) -Codechange: allow resizing the multiplayer server list window.
rubidium
parents:
7837
diff
changeset
|
605 |
|
8456
bec1891e42b5
(svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp
smatz
parents:
8455
diff
changeset
|
606 |
/* BOTTOM */ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
607 |
{ WWT_PUSHTXTBTN, RESIZE_TB, BTC, 10, 110, 246, 257, STR_NETWORK_FIND_SERVER, STR_NETWORK_FIND_SERVER_TIP}, // NGWW_FIND |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
608 |
{ WWT_PUSHTXTBTN, RESIZE_TB, BTC, 118, 218, 246, 257, STR_NETWORK_ADD_SERVER, STR_NETWORK_ADD_SERVER_TIP}, // NGWW_ADD |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
609 |
{ WWT_PUSHTXTBTN, RESIZE_TB, BTC, 226, 326, 246, 257, STR_NETWORK_START_SERVER, STR_NETWORK_START_SERVER_TIP}, // NGWW_START |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
610 |
{ WWT_PUSHTXTBTN, RESIZE_TB, BTC, 334, 434, 246, 257, STR_012E_CANCEL, STR_NULL}, // NGWW_CANCEL |
7935
b5bc2bd79e6b
(svn r10886) -Codechange: modify the "start network server" GUI so it can actually handle more than 10 clients/companies/spectators in a nice way, i.e. without making a combobox with 100 players and add 90 new strings to be able to do so.
rubidium
parents:
7859
diff
changeset
|
611 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
612 |
{ WWT_RESIZEBOX, RESIZE_LRTB, BGC, 438, 449, 252, 263, 0x0, STR_RESIZE_BUTTON }, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
613 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
175
diff
changeset
|
614 |
{ WIDGETS_END}, |
0 | 615 |
}; |
616 |
||
617 |
static const WindowDesc _network_game_window_desc = { |
|
7839
5c43edaa9de0
(svn r10706) -Codechange: allow resizing the multiplayer server list window.
rubidium
parents:
7837
diff
changeset
|
618 |
WDP_CENTER, WDP_CENTER, 450, 264, 550, 264, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5920
diff
changeset
|
619 |
WC_NETWORK_WINDOW, WC_NONE, |
7839
5c43edaa9de0
(svn r10706) -Codechange: allow resizing the multiplayer server list window.
rubidium
parents:
7837
diff
changeset
|
620 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 621 |
_network_game_window_widgets, |
622 |
NetworkGameWindowWndProc, |
|
623 |
}; |
|
624 |
||
6573 | 625 |
void ShowNetworkGameWindow() |
0 | 626 |
{ |
2922
61cf61d25de9
(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
|
627 |
static bool first = true; |
0 | 628 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
105 | 629 |
|
764
68b398e2b780
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
630 |
/* Only show once */ |
2922
61cf61d25de9
(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
|
631 |
if (first) { |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
632 |
char * const *srv; |
2881
1ffbbdbf1685
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
633 |
|
2922
61cf61d25de9
(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
|
634 |
first = false; |
764
68b398e2b780
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
635 |
// add all servers from the config file to our list |
2885
c06f2f3985a0
(svn r3435) - Fix a warning, removed unused extern and some comments in network_gamelist.c
Darkvater
parents:
2884
diff
changeset
|
636 |
for (srv = &_network_host_list[0]; srv != endof(_network_host_list) && *srv != NULL; srv++) { |
2881
1ffbbdbf1685
(svn r3429) - Feature (Followup): Change the gamelist window to accomodate for the new information.
Darkvater
parents:
2879
diff
changeset
|
637 |
NetworkAddServer(*srv); |
764
68b398e2b780
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
638 |
} |
2922
61cf61d25de9
(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
|
639 |
|
61cf61d25de9
(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
|
640 |
_ng_sorting.criteria = 2; // sort default by collectivity (green-dots on top) |
61cf61d25de9
(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
|
641 |
_ng_sorting.order = 0; // sort ascending by default |
764
68b398e2b780
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
642 |
} |
68b398e2b780
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
749
diff
changeset
|
643 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
644 |
Window *w = AllocateWindowDesc(&_network_game_window_desc); |
2887
d5967e472eee
(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
|
645 |
if (w != NULL) { |
4171 | 646 |
querystr_d *querystr = &WP(w, network_ql_d).q; |
3470
9dc3e8d2fde1
(svn r4315) Remove MAX_QUERYSTR_LEN, rather use lengthof() the real thing
tron
parents:
3469
diff
changeset
|
647 |
|
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
648 |
ttd_strlcpy(_edit_str_net_buf, _network_player_name, lengthof(_edit_str_net_buf)); |
4909
ef77bf81545c
(svn r6879) -Codechange: Remove the superflouos argument CharsetFilter parameter from HandleEditBoxKey
Darkvater
parents:
4906
diff
changeset
|
649 |
querystr->afilter = CS_ALPHANUMERAL; |
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
650 |
InitializeTextBuffer(&querystr->text, _edit_str_net_buf, lengthof(_edit_str_net_buf), 120); |
0 | 651 |
|
2887
d5967e472eee
(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
|
652 |
UpdateNetworkGameWindow(true); |
d5967e472eee
(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
|
653 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
654 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
655 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
656 |
enum { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
657 |
NSSWND_START = 64, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
658 |
NSSWND_ROWSIZE = 12 |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
659 |
}; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
660 |
|
8455
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
661 |
/** Enum for NetworkStartServerWindow, referring to _network_start_server_window_widgets */ |
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
662 |
enum NetworkStartServerWidgets { |
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
663 |
NSSW_CLOSE = 0, ///< Close 'X' button |
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
664 |
NSSW_GAMENAME = 4, ///< Background for editbox to set game name |
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
665 |
NSSW_SETPWD = 5, ///< 'Set password' button |
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
666 |
NSSW_SELMAP = 7, ///< 'Select map' list |
8839
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
667 |
NSSW_CONNTYPE_BTN = 10, ///< 'Connection type' droplist button |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
668 |
NSSW_CLIENTS_BTND = 12, ///< 'Max clients' downarrow |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
669 |
NSSW_CLIENTS_TXT = 13, ///< 'Max clients' text |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
670 |
NSSW_CLIENTS_BTNU = 14, ///< 'Max clients' uparrow |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
671 |
NSSW_COMPANIES_BTND = 16, ///< 'Max companies' downarrow |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
672 |
NSSW_COMPANIES_TXT = 17, ///< 'Max companies' text |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
673 |
NSSW_COMPANIES_BTNU = 18, ///< 'Max companies' uparrow |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
674 |
NSSW_SPECTATORS_BTND = 20, ///< 'Max spectators' downarrow |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
675 |
NSSW_SPECTATORS_TXT = 21, ///< 'Max spectators' text |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
676 |
NSSW_SPECTATORS_BTNU = 22, ///< 'Max spectators' uparrow |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
677 |
NSSW_LANGUAGE_BTN = 24, ///< 'Language spoken' droplist button |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
678 |
NSSW_START = 25, ///< 'Start' button |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
679 |
NSSW_LOAD = 26, ///< 'Load' button |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
680 |
NSSW_CANCEL = 27, ///< 'Cancel' button |
8455
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
681 |
}; |
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
682 |
|
8457
6e4071463e64
(svn r11517) -Codechange: better cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8456
diff
changeset
|
683 |
/** |
6e4071463e64
(svn r11517) -Codechange: better cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8456
diff
changeset
|
684 |
* Handler of actions done in the NetworkStartServer window |
6e4071463e64
(svn r11517) -Codechange: better cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8456
diff
changeset
|
685 |
* |
6e4071463e64
(svn r11517) -Codechange: better cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8456
diff
changeset
|
686 |
* @param w pointer to the Window structure |
6e4071463e64
(svn r11517) -Codechange: better cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8456
diff
changeset
|
687 |
* @param e pointer to window event |
6e4071463e64
(svn r11517) -Codechange: better cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8456
diff
changeset
|
688 |
* @note Uses network_ql_d (network_d, querystr_d and list_d) WP macro |
6e4071463e64
(svn r11517) -Codechange: better cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8456
diff
changeset
|
689 |
* @see struct _network_start_server_window_widgets |
6e4071463e64
(svn r11517) -Codechange: better cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8456
diff
changeset
|
690 |
* @see enum NetworkStartServerWidgets |
6e4071463e64
(svn r11517) -Codechange: better cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8456
diff
changeset
|
691 |
*/ |
0 | 692 |
static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e) |
693 |
{ |
|
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
694 |
network_d *nd = &WP(w, network_ql_d).n; |
2887
d5967e472eee
(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
|
695 |
|
1653
3eed36c12b1d
(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
Darkvater
parents:
1648
diff
changeset
|
696 |
switch (e->event) { |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
697 |
case WE_CREATE: // focus input box |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
698 |
nd->field = NSSW_GAMENAME; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
699 |
_network_game_info.use_password = (_network_server_password[0] != '\0'); |
2639 | 700 |
break; |
701 |
||
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
702 |
case WE_PAINT: { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
703 |
int y = NSSWND_START, pos; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
704 |
const FiosItem *item; |
2639 | 705 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
706 |
/* draw basic widgets */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
707 |
SetDParam(1, _connection_types_dropdown[_network_advertise]); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
708 |
SetDParam(2, _network_game_info.clients_max); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
709 |
SetDParam(3, _network_game_info.companies_max); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
710 |
SetDParam(4, _network_game_info.spectators_max); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
711 |
SetDParam(5, STR_NETWORK_LANG_ANY + _network_game_info.server_lang); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
712 |
DrawWindowWidgets(w); |
2100
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2071
diff
changeset
|
713 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
714 |
/* editbox to set game name */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
715 |
DrawEditBox(w, &WP(w, network_ql_d).q, NSSW_GAMENAME); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
716 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
717 |
/* if password is set, draw red '*' next to 'Set password' button */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
718 |
if (_network_game_info.use_password) DoDrawString("*", 408, 23, TC_RED); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
719 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
720 |
/* draw list of maps */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
721 |
GfxFillRect(11, 63, 258, 215, 0xD7); // black background of maps list |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
722 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
723 |
pos = w->vscroll.pos; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
724 |
while (pos < _fios_num + 1) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
725 |
item = _fios_list + pos - 1; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
726 |
if (item == nd->map || (pos == 0 && nd->map == NULL)) |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
727 |
GfxFillRect(11, y - 1, 258, y + 10, 155); // show highlighted item with a different colour |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
728 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
729 |
if (pos == 0) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
730 |
DrawString(14, y, STR_4010_GENERATE_RANDOM_NEW_GAME, TC_DARK_GREEN); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
731 |
} else { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
732 |
DoDrawString(item->title, 14, y, _fios_colors[item->type] ); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
733 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
734 |
pos++; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
735 |
y += NSSWND_ROWSIZE; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
736 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
737 |
if (y >= w->vscroll.cap * NSSWND_ROWSIZE + NSSWND_START) break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
738 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
739 |
} break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
740 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
741 |
case WE_CLICK: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
742 |
if (e->we.click.widget != NSSW_CONNTYPE_BTN && e->we.click.widget != NSSW_LANGUAGE_BTN) HideDropDownMenu(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
743 |
nd->field = e->we.click.widget; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
744 |
switch (e->we.click.widget) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
745 |
case NSSW_CLOSE: // Close 'X' |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
746 |
case NSSW_CANCEL: // Cancel button |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
747 |
ShowNetworkGameWindow(); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
748 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
749 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
750 |
case NSSW_GAMENAME: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
751 |
ShowOnScreenKeyboard(w, &WP(w, network_ql_d).q, NSSW_GAMENAME, 0, 0); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
752 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
753 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
754 |
case NSSW_SETPWD: // Set password button |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
755 |
nd->widget_id = NSSW_SETPWD; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
756 |
ShowQueryString(BindCString(_network_server_password), STR_NETWORK_SET_PASSWORD, 20, 250, w, CS_ALPHANUMERAL); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
757 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
758 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
759 |
case NSSW_SELMAP: { // Select map |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
760 |
int y = (e->we.click.pt.y - NSSWND_START) / NSSWND_ROWSIZE; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
761 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
762 |
y += w->vscroll.pos; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
763 |
if (y >= w->vscroll.count) return; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
764 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
765 |
nd->map = (y == 0) ? NULL : _fios_list + y - 1; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
766 |
SetWindowDirty(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
767 |
} break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
768 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
769 |
case NSSW_CONNTYPE_BTN: // Connection type |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
770 |
ShowDropDownMenu(w, _connection_types_dropdown, _network_advertise, NSSW_CONNTYPE_BTN, 0, 0); // do it for widget NSSW_CONNTYPE_BTN |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
771 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
772 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
773 |
case NSSW_CLIENTS_BTND: case NSSW_CLIENTS_BTNU: // Click on up/down button for number of clients |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
774 |
case NSSW_COMPANIES_BTND: case NSSW_COMPANIES_BTNU: // Click on up/down button for number of companies |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
775 |
case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU: // Click on up/down button for number of spectators |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
776 |
/* Don't allow too fast scrolling */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
777 |
if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
778 |
w->HandleButtonClick(e->we.click.widget); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
779 |
SetWindowDirty(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
780 |
switch (e->we.click.widget) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
781 |
default: NOT_REACHED(); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
782 |
case NSSW_CLIENTS_BTND: case NSSW_CLIENTS_BTNU: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
783 |
_network_game_info.clients_max = Clamp(_network_game_info.clients_max + e->we.click.widget - NSSW_CLIENTS_TXT, 2, MAX_CLIENTS); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
784 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
785 |
case NSSW_COMPANIES_BTND: case NSSW_COMPANIES_BTNU: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
786 |
_network_game_info.companies_max = Clamp(_network_game_info.companies_max + e->we.click.widget - NSSW_COMPANIES_TXT, 1, MAX_PLAYERS); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
787 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
788 |
case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
789 |
_network_game_info.spectators_max = Clamp(_network_game_info.spectators_max + e->we.click.widget - NSSW_SPECTATORS_TXT, 0, MAX_CLIENTS); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
790 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
791 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
792 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
793 |
_left_button_clicked = false; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
794 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
795 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
796 |
case NSSW_CLIENTS_TXT: // Click on number of players |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
797 |
nd->widget_id = NSSW_CLIENTS_TXT; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
798 |
SetDParam(0, _network_game_info.clients_max); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
799 |
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_CLIENTS, 3, 50, w, CS_NUMERAL); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
800 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
801 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
802 |
case NSSW_COMPANIES_TXT: // Click on number of companies |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
803 |
nd->widget_id = NSSW_COMPANIES_TXT; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
804 |
SetDParam(0, _network_game_info.companies_max); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
805 |
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_COMPANIES, 3, 50, w, CS_NUMERAL); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
806 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
807 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
808 |
case NSSW_SPECTATORS_TXT: // Click on number of spectators |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
809 |
nd->widget_id = NSSW_SPECTATORS_TXT; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
810 |
SetDParam(0, _network_game_info.spectators_max); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
811 |
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_SPECTATORS, 3, 50, w, CS_NUMERAL); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
812 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
813 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
814 |
case NSSW_LANGUAGE_BTN: { // Language |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
815 |
uint sel = 0; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
816 |
for (uint i = 0; i < lengthof(_language_dropdown) - 1; i++) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
817 |
if (_language_dropdown[i] == STR_NETWORK_LANG_ANY + _network_game_info.server_lang) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
818 |
sel = i; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
819 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
820 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
821 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
822 |
ShowDropDownMenu(w, _language_dropdown, sel, NSSW_LANGUAGE_BTN, 0, 0); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
823 |
} break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
824 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
825 |
case NSSW_START: // Start game |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
826 |
_is_network_server = true; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
827 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
828 |
if (nd->map == NULL) { // start random new game |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
829 |
ShowGenerateLandscape(); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
830 |
} else { // load a scenario |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
831 |
char *name = FiosBrowseTo(nd->map); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
832 |
if (name != NULL) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
833 |
SetFiosType(nd->map->type); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
834 |
_file_to_saveload.filetype = FT_SCENARIO; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
835 |
ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name)); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
836 |
ttd_strlcpy(_file_to_saveload.title, nd->map->title, sizeof(_file_to_saveload.title)); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
837 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
838 |
DeleteWindow(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
839 |
SwitchMode(SM_START_SCENARIO); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
840 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
841 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
842 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
843 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
844 |
case NSSW_LOAD: // Load game |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
845 |
_is_network_server = true; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
846 |
/* XXX - WC_NETWORK_WINDOW (this window) should stay, but if it stays, it gets |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
847 |
* copied all the elements of 'load game' and upon closing that, it segfaults */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
848 |
DeleteWindow(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
849 |
ShowSaveLoadDialog(SLD_LOAD_GAME); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
850 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
851 |
} |
675
b120ec0b3e39
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
670
diff
changeset
|
852 |
break; |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
853 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
854 |
case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
855 |
switch (e->we.dropdown.button) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
856 |
case NSSW_CONNTYPE_BTN: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
857 |
_network_advertise = (e->we.dropdown.index != 0); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
858 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
859 |
case NSSW_LANGUAGE_BTN: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
860 |
_network_game_info.server_lang = _language_dropdown[e->we.dropdown.index] - STR_NETWORK_LANG_ANY; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
861 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
862 |
default: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
863 |
NOT_REACHED(); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
864 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
865 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
866 |
SetWindowDirty(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
867 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
868 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
869 |
case WE_MOUSELOOP: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
870 |
if (nd->field == NSSW_GAMENAME) HandleEditBox(w, &WP(w, network_ql_d).q, NSSW_GAMENAME); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
871 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
872 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
873 |
case WE_KEYPRESS: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
874 |
if (nd->field == NSSW_GAMENAME) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
875 |
if (HandleEditBoxKey(w, &WP(w, network_ql_d).q, NSSW_GAMENAME, e) == 1) break; // enter pressed |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
876 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
877 |
ttd_strlcpy(_network_server_name, WP(w, network_ql_d).q.text.buf, sizeof(_network_server_name)); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
878 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
879 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
880 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
881 |
case WE_ON_EDIT_TEXT: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
882 |
if (e->we.edittext.str == NULL) break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
883 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
884 |
if (nd->widget_id == NSSW_SETPWD) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
885 |
ttd_strlcpy(_network_server_password, e->we.edittext.str, lengthof(_network_server_password)); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
886 |
_network_game_info.use_password = (_network_server_password[0] != '\0'); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
887 |
} else { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
888 |
int32 value = atoi(e->we.edittext.str); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
889 |
w->InvalidateWidget(nd->widget_id); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
890 |
switch (nd->widget_id) { |
7935
b5bc2bd79e6b
(svn r10886) -Codechange: modify the "start network server" GUI so it can actually handle more than 10 clients/companies/spectators in a nice way, i.e. without making a combobox with 100 players and add 90 new strings to be able to do so.
rubidium
parents:
7859
diff
changeset
|
891 |
default: NOT_REACHED(); |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
892 |
case NSSW_CLIENTS_TXT: _network_game_info.clients_max = Clamp(value, 2, MAX_CLIENTS); break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
893 |
case NSSW_COMPANIES_TXT: _network_game_info.companies_max = Clamp(value, 1, MAX_PLAYERS); break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
894 |
case NSSW_SPECTATORS_TXT: _network_game_info.spectators_max = Clamp(value, 0, MAX_CLIENTS); break; |
7935
b5bc2bd79e6b
(svn r10886) -Codechange: modify the "start network server" GUI so it can actually handle more than 10 clients/companies/spectators in a nice way, i.e. without making a combobox with 100 players and add 90 new strings to be able to do so.
rubidium
parents:
7859
diff
changeset
|
895 |
} |
b5bc2bd79e6b
(svn r10886) -Codechange: modify the "start network server" GUI so it can actually handle more than 10 clients/companies/spectators in a nice way, i.e. without making a combobox with 100 players and add 90 new strings to be able to do so.
rubidium
parents:
7859
diff
changeset
|
896 |
} |
2887
d5967e472eee
(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
|
897 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
898 |
SetWindowDirty(w); |
0 | 899 |
break; |
900 |
} |
|
901 |
} |
|
902 |
||
903 |
static const Widget _network_start_server_window_widgets[] = { |
|
8455
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
904 |
/* Window decoration and background panel */ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
905 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, // NSSW_CLOSE |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
906 |
{ WWT_CAPTION, RESIZE_NONE, BGC, 11, 419, 0, 13, STR_NETWORK_START_GAME_WINDOW, STR_NULL}, |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
907 |
{ WWT_PANEL, RESIZE_NONE, BGC, 0, 419, 14, 243, 0x0, STR_NULL}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
908 |
|
8455
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
909 |
/* Set game name and password widgets */ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
910 |
{ WWT_TEXT, RESIZE_NONE, BGC, 10, 90, 22, 34, STR_NETWORK_NEW_GAME_NAME, STR_NULL}, |
9233
4daa9bb8dbf7
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
9224
diff
changeset
|
911 |
{ WWT_EDITBOX, RESIZE_NONE, BGC, 100, 272, 22, 33, STR_NETWORK_NEW_GAME_NAME_OSKTITLE, STR_NETWORK_NEW_GAME_NAME_TIP}, // NSSW_GAMENAME |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
912 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 285, 405, 22, 33, STR_NETWORK_SET_PASSWORD, STR_NETWORK_PASSWORD_TIP}, // NSSW_SETPWD |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
913 |
|
8455
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
914 |
/* List of playable scenarios */ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
915 |
{ WWT_TEXT, RESIZE_NONE, BGC, 10, 110, 43, 55, STR_NETWORK_SELECT_MAP, STR_NULL}, |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
916 |
{ WWT_INSET, RESIZE_NONE, BGC, 10, 271, 62, 216, STR_NULL, STR_NETWORK_SELECT_MAP_TIP}, // NSSW_SELMAP |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
917 |
{ WWT_SCROLLBAR, RESIZE_NONE, BGC, 259, 270, 63, 215, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
8455
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
918 |
|
7935
b5bc2bd79e6b
(svn r10886) -Codechange: modify the "start network server" GUI so it can actually handle more than 10 clients/companies/spectators in a nice way, i.e. without making a combobox with 100 players and add 90 new strings to be able to do so.
rubidium
parents:
7859
diff
changeset
|
919 |
/* Combo/selection boxes to control Connection Type / Max Clients / Max Companies / Max Observers / Language */ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
920 |
{ WWT_TEXT, RESIZE_NONE, BGC, 280, 419, 63, 75, STR_NETWORK_CONNECTION, STR_NULL}, |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
921 |
{ WWT_DROPDOWNIN, RESIZE_NONE, BGC, 280, 410, 77, 88, STR_NETWORK_LAN_INTERNET_COMBO, STR_NETWORK_CONNECTION_TIP}, // NSSW_CONNTYPE_BTN |
7935
b5bc2bd79e6b
(svn r10886) -Codechange: modify the "start network server" GUI so it can actually handle more than 10 clients/companies/spectators in a nice way, i.e. without making a combobox with 100 players and add 90 new strings to be able to do so.
rubidium
parents:
7859
diff
changeset
|
922 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
923 |
{ WWT_TEXT, RESIZE_NONE, BGC, 280, 419, 95, 107, STR_NETWORK_NUMBER_OF_CLIENTS, STR_NULL}, |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
924 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 280, 291, 109, 120, SPR_ARROW_DOWN, STR_NETWORK_NUMBER_OF_CLIENTS_TIP}, // NSSW_CLIENTS_BTND |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
925 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BGC, 292, 397, 109, 120, STR_NETWORK_CLIENTS_SELECT, STR_NETWORK_NUMBER_OF_CLIENTS_TIP}, // NSSW_CLIENTS_TXT |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
926 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 398, 410, 109, 120, SPR_ARROW_UP, STR_NETWORK_NUMBER_OF_CLIENTS_TIP}, // NSSW_CLIENTS_BTNU |
8455
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
927 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
928 |
{ WWT_TEXT, RESIZE_NONE, BGC, 280, 419, 127, 139, STR_NETWORK_NUMBER_OF_COMPANIES, STR_NULL}, |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
929 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 280, 291, 141, 152, SPR_ARROW_DOWN, STR_NETWORK_NUMBER_OF_COMPANIES_TIP}, // NSSW_COMPANIES_BTND |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
930 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BGC, 292, 397, 141, 152, STR_NETWORK_COMPANIES_SELECT, STR_NETWORK_NUMBER_OF_COMPANIES_TIP}, // NSSW_COMPANIES_TXT |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
931 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 398, 410, 141, 152, SPR_ARROW_UP, STR_NETWORK_NUMBER_OF_COMPANIES_TIP}, // NSSW_COMPANIES_BTNU |
8455
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
932 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
933 |
{ WWT_TEXT, RESIZE_NONE, BGC, 280, 419, 159, 171, STR_NETWORK_NUMBER_OF_SPECTATORS, STR_NULL}, |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
934 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 280, 291, 173, 184, SPR_ARROW_DOWN, STR_NETWORK_NUMBER_OF_SPECTATORS_TIP}, // NSSW_SPECTATORS_BTND |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
935 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BGC, 292, 397, 173, 184, STR_NETWORK_SPECTATORS_SELECT, STR_NETWORK_NUMBER_OF_SPECTATORS_TIP}, // NSSW_SPECTATORS_TXT |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
936 |
{ WWT_IMGBTN, RESIZE_NONE, BGC, 398, 410, 173, 184, SPR_ARROW_UP, STR_NETWORK_NUMBER_OF_SPECTATORS_TIP}, // NSSW_SPECTATORS_BTNU |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
937 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
938 |
{ WWT_TEXT, RESIZE_NONE, BGC, 280, 419, 191, 203, STR_NETWORK_LANGUAGE_SPOKEN, STR_NULL}, |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
939 |
{ WWT_DROPDOWNIN, RESIZE_NONE, BGC, 280, 410, 205, 216, STR_NETWORK_LANGUAGE_COMBO, STR_NETWORK_LANGUAGE_TIP}, // NSSW_LANGUAGE_BTN |
8455
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
940 |
|
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
941 |
/* Buttons Start / Load / Cancel */ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
942 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 40, 140, 224, 235, STR_NETWORK_START_GAME, STR_NETWORK_START_GAME_TIP}, // NSSW_START |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
943 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 150, 250, 224, 235, STR_NETWORK_LOAD_GAME, STR_NETWORK_LOAD_GAME_TIP}, // NSSW_LOAD |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
944 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 260, 360, 224, 235, STR_012E_CANCEL, STR_NULL}, // NSSW_CANCEL |
8455
218ce4bc9b23
(svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp
smatz
parents:
8427
diff
changeset
|
945 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
175
diff
changeset
|
946 |
{ WIDGETS_END}, |
0 | 947 |
}; |
948 |
||
949 |
static const WindowDesc _network_start_server_window_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7817
diff
changeset
|
950 |
WDP_CENTER, WDP_CENTER, 420, 244, 420, 244, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5920
diff
changeset
|
951 |
WC_NETWORK_WINDOW, WC_NONE, |
2064
c889fcc76398
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2055
diff
changeset
|
952 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
0 | 953 |
_network_start_server_window_widgets, |
954 |
NetworkStartServerWindowWndProc, |
|
955 |
}; |
|
956 |
||
6573 | 957 |
static void ShowNetworkStartServerWindow() |
0 | 958 |
{ |
959 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
960 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
961 |
Window *w = AllocateWindowDesc(&_network_start_server_window_desc); |
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
962 |
ttd_strlcpy(_edit_str_net_buf, _network_server_name, lengthof(_edit_str_net_buf)); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
963 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
964 |
_saveload_mode = SLD_NEW_GAME; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
965 |
BuildFileList(); |
2943
384c32d588e3
(svn r3499) - Fix: a few gui glitches in the network window:
Darkvater
parents:
2938
diff
changeset
|
966 |
w->vscroll.cap = 12; |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6574
diff
changeset
|
967 |
w->vscroll.count = _fios_num + 1; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
968 |
|
4909
ef77bf81545c
(svn r6879) -Codechange: Remove the superflouos argument CharsetFilter parameter from HandleEditBoxKey
Darkvater
parents:
4906
diff
changeset
|
969 |
WP(w, network_ql_d).q.afilter = CS_ALPHANUMERAL; |
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
970 |
InitializeTextBuffer(&WP(w, network_ql_d).q.text, _edit_str_net_buf, lengthof(_edit_str_net_buf), 160); |
0 | 971 |
} |
972 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
973 |
static PlayerID NetworkLobbyFindCompanyIndex(byte pos) |
734
018e549265ed
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
974 |
{ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
975 |
/* Scroll through all _network_player_info and get the 'pos' item that is not empty */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
976 |
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
734
018e549265ed
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
977 |
if (_network_player_info[i].company_name[0] != '\0') { |
2639 | 978 |
if (pos-- == 0) return i; |
734
018e549265ed
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
979 |
} |
018e549265ed
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
980 |
} |
018e549265ed
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
981 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
982 |
return PLAYER_FIRST; |
734
018e549265ed
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
983 |
} |
018e549265ed
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
truelight
parents:
722
diff
changeset
|
984 |
|
8459
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
985 |
/** Enum for NetworkLobbyWindow, referring to _network_lobby_window_widgets */ |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
986 |
enum NetworkLobbyWindowWidgets { |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
987 |
NLWW_CLOSE = 0, ///< Close 'X' button |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
988 |
NLWW_MATRIX = 5, ///< List of companies |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
989 |
NLWW_DETAILS = 7, ///< Company details |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
990 |
NLWW_JOIN = 8, ///< 'Join company' button |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
991 |
NLWW_NEW = 9, ///< 'New company' button |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
992 |
NLWW_SPECTATE = 10, ///< 'Spectate game' button |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
993 |
NLWW_REFRESH = 11, ///< 'Refresh server' button |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
994 |
NLWW_CANCEL = 12, ///< 'Cancel' button |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
995 |
}; |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
996 |
|
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
997 |
/** |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
998 |
* Handler of actions done in the NetworkLobby window |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
999 |
* |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1000 |
* @param w pointer to the Window structure |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1001 |
* @param e pointer to window event |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1002 |
* @note uses network_d WP macro |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1003 |
* @see struct _network_lobby_window_widgets |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1004 |
* @see enum NetworkLobbyWindowWidgets |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1005 |
*/ |
0 | 1006 |
static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) |
1007 |
{ |
|
2887
d5967e472eee
(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
|
1008 |
network_d *nd = &WP(w, network_d); |
d5967e472eee
(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
|
1009 |
|
2639 | 1010 |
switch (e->event) { |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1011 |
case WE_CREATE: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1012 |
nd->company = INVALID_PLAYER; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1013 |
break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1014 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1015 |
case WE_PAINT: { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1016 |
const NetworkGameInfo *gi = &nd->server->info; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1017 |
int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1018 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1019 |
/* Join button is disabled when no company is selected */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1020 |
w->SetWidgetDisabledState(NLWW_JOIN, nd->company == INVALID_PLAYER); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1021 |
/* Cannot start new company if there are too many */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1022 |
w->SetWidgetDisabledState(NLWW_NEW, gi->companies_on >= gi->companies_max); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1023 |
/* Cannot spectate if there are too many spectators */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1024 |
w->SetWidgetDisabledState(NLWW_SPECTATE, gi->spectators_on >= gi->spectators_max); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1025 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1026 |
/* Draw window widgets */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1027 |
SetDParamStr(0, gi->server_name); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1028 |
DrawWindowWidgets(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1029 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1030 |
/* Draw company list */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1031 |
pos = w->vscroll.pos; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1032 |
while (pos < gi->companies_on) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1033 |
byte company = NetworkLobbyFindCompanyIndex(pos); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1034 |
bool income = false; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1035 |
if (nd->company == company) |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1036 |
GfxFillRect(11, y - 1, 154, y + 10, 10); // show highlighted item with a different colour |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1037 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1038 |
DoDrawStringTruncated(_network_player_info[company].company_name, 13, y, TC_BLACK, 135 - 13); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1039 |
if (_network_player_info[company].use_password != 0) DrawSprite(SPR_LOCK, PAL_NONE, 135, y); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1040 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1041 |
/* If the company's income was positive puts a green dot else a red dot */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1042 |
if (_network_player_info[company].income >= 0) income = true; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1043 |
DrawSprite(SPR_BLOT, income ? PALETTE_TO_GREEN : PALETTE_TO_RED, 145, y); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1044 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1045 |
pos++; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1046 |
y += NET_PRC__SIZE_OF_ROW; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1047 |
if (pos >= w->vscroll.cap) break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1048 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1049 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1050 |
/* Draw info about selected company when it is selected in the left window */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1051 |
GfxFillRect(174, 39, 403, 75, 157); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1052 |
DrawStringCentered(290, 50, STR_NETWORK_COMPANY_INFO, TC_FROMSTRING); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1053 |
if (nd->company != INVALID_PLAYER) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1054 |
const uint x = 183; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1055 |
const uint trunc_width = w->widget[NLWW_DETAILS].right - x; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1056 |
y = 80; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1057 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1058 |
SetDParam(0, nd->server->info.clients_on); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1059 |
SetDParam(1, nd->server->info.clients_max); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1060 |
SetDParam(2, nd->server->info.companies_on); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1061 |
SetDParam(3, nd->server->info.companies_max); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1062 |
DrawString(x, y, STR_NETWORK_CLIENTS, TC_GOLD); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1063 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1064 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1065 |
SetDParamStr(0, _network_player_info[nd->company].company_name); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1066 |
DrawStringTruncated(x, y, STR_NETWORK_COMPANY_NAME, TC_GOLD, trunc_width); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1067 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1068 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1069 |
SetDParam(0, _network_player_info[nd->company].inaugurated_year); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1070 |
DrawString(x, y, STR_NETWORK_INAUGURATION_YEAR, TC_GOLD); // inauguration year |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1071 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1072 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1073 |
SetDParam(0, _network_player_info[nd->company].company_value); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1074 |
DrawString(x, y, STR_NETWORK_VALUE, TC_GOLD); // company value |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1075 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1076 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1077 |
SetDParam(0, _network_player_info[nd->company].money); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1078 |
DrawString(x, y, STR_NETWORK_CURRENT_BALANCE, TC_GOLD); // current balance |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1079 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1080 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1081 |
SetDParam(0, _network_player_info[nd->company].income); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1082 |
DrawString(x, y, STR_NETWORK_LAST_YEARS_INCOME, TC_GOLD); // last year's income |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1083 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1084 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1085 |
SetDParam(0, _network_player_info[nd->company].performance); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1086 |
DrawString(x, y, STR_NETWORK_PERFORMANCE, TC_GOLD); // performance |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1087 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1088 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1089 |
SetDParam(0, _network_player_info[nd->company].num_vehicle[0]); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1090 |
SetDParam(1, _network_player_info[nd->company].num_vehicle[1]); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1091 |
SetDParam(2, _network_player_info[nd->company].num_vehicle[2]); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1092 |
SetDParam(3, _network_player_info[nd->company].num_vehicle[3]); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1093 |
SetDParam(4, _network_player_info[nd->company].num_vehicle[4]); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1094 |
DrawString(x, y, STR_NETWORK_VEHICLES, TC_GOLD); // vehicles |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1095 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1096 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1097 |
SetDParam(0, _network_player_info[nd->company].num_station[0]); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1098 |
SetDParam(1, _network_player_info[nd->company].num_station[1]); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1099 |
SetDParam(2, _network_player_info[nd->company].num_station[2]); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1100 |
SetDParam(3, _network_player_info[nd->company].num_station[3]); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1101 |
SetDParam(4, _network_player_info[nd->company].num_station[4]); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1102 |
DrawString(x, y, STR_NETWORK_STATIONS, TC_GOLD); // stations |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1103 |
y += 10; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1104 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1105 |
SetDParamStr(0, _network_player_info[nd->company].players); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1106 |
DrawStringTruncated(x, y, STR_NETWORK_PLAYERS, TC_GOLD, trunc_width); // players |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1107 |
} |
6988
76eba6a9cc6f
(svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents:
6987
diff
changeset
|
1108 |
} break; |
2884
c100870ea536
(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
|
1109 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1110 |
case WE_CLICK: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1111 |
switch (e->we.click.widget) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1112 |
case NLWW_CLOSE: // Close 'X' |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1113 |
case NLWW_CANCEL: // Cancel button |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1114 |
ShowNetworkGameWindow(); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1115 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1116 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1117 |
case NLWW_MATRIX: { // Company list |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1118 |
uint32 id_v = (e->we.click.pt.y - NET_PRC__OFFSET_TOP_WIDGET_COMPANY) / NET_PRC__SIZE_OF_ROW; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1119 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1120 |
if (id_v >= w->vscroll.cap) break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1121 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1122 |
id_v += w->vscroll.pos; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1123 |
nd->company = (id_v >= nd->server->info.companies_on) ? INVALID_PLAYER : NetworkLobbyFindCompanyIndex(id_v); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1124 |
SetWindowDirty(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1125 |
} break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1126 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1127 |
case NLWW_JOIN: // Join company |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1128 |
/* Button can be clicked only when it is enabled */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1129 |
_network_playas = nd->company; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1130 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1131 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1132 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1133 |
case NLWW_NEW: // New company |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1134 |
_network_playas = PLAYER_NEW_COMPANY; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1135 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1136 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1137 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1138 |
case NLWW_SPECTATE: // Spectate game |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1139 |
_network_playas = PLAYER_SPECTATOR; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1140 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1141 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1142 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1143 |
case NLWW_REFRESH: // Refresh |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1144 |
NetworkTCPQueryServer(_network_last_host, _network_last_port); // company info |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1145 |
NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1146 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1147 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1148 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1149 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1150 |
case WE_MESSAGE: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1151 |
SetWindowDirty(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1152 |
break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1153 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1154 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1155 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1156 |
static const Widget _network_lobby_window_widgets[] = { |
8459
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1157 |
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, // NLWW_CLOSE |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1158 |
{ WWT_CAPTION, RESIZE_NONE, BGC, 11, 419, 0, 13, STR_NETWORK_GAME_LOBBY, STR_NULL}, |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1159 |
{ WWT_PANEL, RESIZE_NONE, BGC, 0, 419, 14, 234, 0x0, STR_NULL}, |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1160 |
{ WWT_TEXT, RESIZE_NONE, BGC, 10, 419, 22, 34, STR_NETWORK_PREPARE_TO_JOIN, STR_NULL}, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1161 |
|
8459
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1162 |
/* company list */ |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1163 |
{ WWT_PANEL, RESIZE_NONE, BTC, 10, 155, 38, 49, 0x0, STR_NULL}, |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1164 |
{ WWT_MATRIX, RESIZE_NONE, BGC, 10, 155, 50, 190, (10 << 8) + 1, STR_NETWORK_COMPANY_LIST_TIP}, // NLWW_MATRIX |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1165 |
{ WWT_SCROLLBAR, RESIZE_NONE, BGC, 156, 167, 38, 190, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1166 |
|
8459
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1167 |
/* company/player info */ |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1168 |
{ WWT_PANEL, RESIZE_NONE, BGC, 173, 404, 38, 190, 0x0, STR_NULL}, // NLWW_DETAILS |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1169 |
|
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1170 |
/* buttons */ |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1171 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 10, 151, 200, 211, STR_NETWORK_JOIN_COMPANY, STR_NETWORK_JOIN_COMPANY_TIP}, // NLWW_JOIN |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1172 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 10, 151, 215, 226, STR_NETWORK_NEW_COMPANY, STR_NETWORK_NEW_COMPANY_TIP}, // NLWW_NEW |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1173 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 158, 268, 200, 211, STR_NETWORK_SPECTATE_GAME, STR_NETWORK_SPECTATE_GAME_TIP}, // NLWW_SPECTATE |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1174 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 158, 268, 215, 226, STR_NETWORK_REFRESH, STR_NETWORK_REFRESH_TIP}, // NLWW_REFRESH |
fc93bfaeca2e
(svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp
smatz
parents:
8457
diff
changeset
|
1175 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 278, 388, 200, 211, STR_012E_CANCEL, STR_NULL}, // NLWW_CANCEL |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1176 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1177 |
{ WIDGETS_END}, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1178 |
}; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1179 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1180 |
static const WindowDesc _network_lobby_window_desc = { |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7817
diff
changeset
|
1181 |
WDP_CENTER, WDP_CENTER, 420, 235, 420, 235, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5920
diff
changeset
|
1182 |
WC_NETWORK_WINDOW, WC_NONE, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1183 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1184 |
_network_lobby_window_widgets, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1185 |
NetworkLobbyWindowWndProc, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1186 |
}; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1187 |
|
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
1188 |
/* Show the networklobbywindow with the selected server |
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
1189 |
* @param ngl Selected game pointer which is passed to the new window */ |
2887
d5967e472eee
(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
|
1190 |
static void ShowNetworkLobbyWindow(NetworkGameList *ngl) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1191 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1192 |
DeleteWindowById(WC_NETWORK_WINDOW, 0); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1193 |
|
6167
1475cf991e66
(svn r8543) -Codechange: make a real difference between querying the server via UDP and TCP.
rubidium
parents:
6144
diff
changeset
|
1194 |
NetworkTCPQueryServer(_network_last_host, _network_last_port); // company info |
1475cf991e66
(svn r8543) -Codechange: make a real difference between querying the server via UDP and TCP.
rubidium
parents:
6144
diff
changeset
|
1195 |
NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1196 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1197 |
Window *w = AllocateWindowDesc(&_network_lobby_window_desc); |
2887
d5967e472eee
(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
|
1198 |
if (w != NULL) { |
2888
0972346d11a8
(svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents:
2887
diff
changeset
|
1199 |
WP(w, network_ql_d).n.server = ngl; |
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
1200 |
strcpy(_edit_str_net_buf, ""); |
2887
d5967e472eee
(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
|
1201 |
w->vscroll.cap = 10; |
d5967e472eee
(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
|
1202 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1203 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1204 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1205 |
// The window below gives information about the connected clients |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1206 |
// and also makes able to give money to them, kick them (if server) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1207 |
// and stuff like that. |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1208 |
|
3692 | 1209 |
extern void DrawPlayerIcon(PlayerID pid, int x, int y); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1210 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1211 |
// Every action must be of this form |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1212 |
typedef void ClientList_Action_Proc(byte client_no); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1213 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1214 |
// Max 10 actions per client |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1215 |
#define MAX_CLIENTLIST_ACTION 10 |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1216 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1217 |
// Some standard bullshit.. defines variables ;) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1218 |
static void ClientListWndProc(Window *w, WindowEvent *e); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1219 |
static void ClientListPopupWndProc(Window *w, WindowEvent *e); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1220 |
static byte _selected_clientlist_item = 255; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1221 |
static byte _selected_clientlist_y = 0; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1222 |
static char _clientlist_action[MAX_CLIENTLIST_ACTION][50]; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1223 |
static ClientList_Action_Proc *_clientlist_proc[MAX_CLIENTLIST_ACTION]; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1224 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1225 |
enum { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1226 |
CLNWND_OFFSET = 16, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1227 |
CLNWND_ROWSIZE = 10 |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1228 |
}; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1229 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1230 |
static const Widget _client_list_widgets[] = { |
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2669
diff
changeset
|
1231 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7525
d0e21b315b60
(svn r10293) -Add [FS#885]: a sticky button for the client list window (oxygene)
truelight
parents:
7498
diff
changeset
|
1232 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 237, 0, 13, STR_NETWORK_CLIENT_LIST, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
d0e21b315b60
(svn r10293) -Add [FS#885]: a sticky button for the client list window (oxygene)
truelight
parents:
7498
diff
changeset
|
1233 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 238, 249, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1234 |
|
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1235 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 249, 14, 14 + CLNWND_ROWSIZE + 1, 0x0, STR_NULL}, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1236 |
{ WIDGETS_END}, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1237 |
}; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1238 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1239 |
static const Widget _client_list_popup_widgets[] = { |
4344
5d0e40cd67b9
(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
|
1240 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 99, 0, 0, 0, STR_NULL}, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1241 |
{ WIDGETS_END}, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1242 |
}; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1243 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1244 |
static WindowDesc _client_list_desc = { |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7817
diff
changeset
|
1245 |
WDP_AUTO, WDP_AUTO, 250, 1, 250, 1, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5920
diff
changeset
|
1246 |
WC_CLIENT_LIST, WC_NONE, |
7525
d0e21b315b60
(svn r10293) -Add [FS#885]: a sticky button for the client list window (oxygene)
truelight
parents:
7498
diff
changeset
|
1247 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1248 |
_client_list_widgets, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1249 |
ClientListWndProc |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1250 |
}; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1251 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1252 |
// Finds the Xth client-info that is active |
4171 | 1253 |
static const NetworkClientInfo *NetworkFindClientInfo(byte client_no) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1254 |
{ |
4171 | 1255 |
const NetworkClientInfo *ci; |
2630 | 1256 |
|
4883
801b93ae218c
(svn r6820) -Codechange: Some more const correctness, coding style.
Darkvater
parents:
4880
diff
changeset
|
1257 |
FOR_ALL_ACTIVE_CLIENT_INFOS(ci) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1258 |
if (client_no == 0) return ci; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1259 |
client_no--; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1260 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1261 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1262 |
return NULL; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1263 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1264 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1265 |
// Here we start to define the options out of the menu |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1266 |
static void ClientList_Kick(byte client_no) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1267 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1268 |
if (client_no < MAX_PLAYERS) |
4880
0708f34e3586
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
1269 |
SEND_COMMAND(PACKET_SERVER_ERROR)(DEREF_CLIENT(client_no), NETWORK_ERROR_KICKED); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1270 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1271 |
|
841
8f0a68c6f43b
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1272 |
static void ClientList_Ban(byte client_no) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1273 |
{ |
841
8f0a68c6f43b
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1274 |
uint32 ip = NetworkFindClientInfo(client_no)->client_ip; |
8f0a68c6f43b
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1275 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1276 |
for (uint i = 0; i < lengthof(_network_ban_list); i++) { |
2914
04ce2485f05f
(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
|
1277 |
if (_network_ban_list[i] == NULL) { |
841
8f0a68c6f43b
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1278 |
_network_ban_list[i] = strdup(inet_ntoa(*(struct in_addr *)&ip)); |
8f0a68c6f43b
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1279 |
break; |
8f0a68c6f43b
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1280 |
} |
8f0a68c6f43b
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1281 |
} |
8f0a68c6f43b
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1282 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1283 |
if (client_no < MAX_PLAYERS) { |
4880
0708f34e3586
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
1284 |
SEND_COMMAND(PACKET_SERVER_ERROR)(DEREF_CLIENT(client_no), NETWORK_ERROR_KICKED); |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1285 |
} |
841
8f0a68c6f43b
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1286 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1287 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1288 |
static void ClientList_GiveMoney(byte client_no) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1289 |
{ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1290 |
if (NetworkFindClientInfo(client_no) != NULL) { |
4878
744717de172e
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
1291 |
ShowNetworkGiveMoneyWindow(NetworkFindClientInfo(client_no)->client_playas); |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1292 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1293 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1294 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1295 |
static void ClientList_SpeakToClient(byte client_no) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1296 |
{ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1297 |
if (NetworkFindClientInfo(client_no) != NULL) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1298 |
ShowNetworkChatQueryWindow(DESTTYPE_CLIENT, NetworkFindClientInfo(client_no)->client_index); |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1299 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1300 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1301 |
|
4906
8a10678a62a3
(svn r6876) -Codechange: Change the naming of _PLAYER in DESTTYPE_PLAYER/NETWORK_ACTION_CHAT_PLAYER
Darkvater
parents:
4895
diff
changeset
|
1302 |
static void ClientList_SpeakToCompany(byte client_no) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1303 |
{ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1304 |
if (NetworkFindClientInfo(client_no) != NULL) { |
4906
8a10678a62a3
(svn r6876) -Codechange: Change the naming of _PLAYER in DESTTYPE_PLAYER/NETWORK_ACTION_CHAT_PLAYER
Darkvater
parents:
4895
diff
changeset
|
1305 |
ShowNetworkChatQueryWindow(DESTTYPE_TEAM, NetworkFindClientInfo(client_no)->client_playas); |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1306 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1307 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1308 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1309 |
static void ClientList_SpeakToAll(byte client_no) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1310 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1311 |
ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1312 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1313 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1314 |
static void ClientList_None(byte client_no) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1315 |
{ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1316 |
/* No action ;) */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1317 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1318 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1319 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1320 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1321 |
/** |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1322 |
* An action is clicked! What do we do? |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1323 |
*/ |
7817
f24498d934ac
(svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents:
7717
diff
changeset
|
1324 |
static void HandleClientListPopupClick(byte index, byte clientno) |
f24498d934ac
(svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents:
7717
diff
changeset
|
1325 |
{ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1326 |
/* A click on the Popup of the ClientList.. handle the command */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1327 |
if (index < MAX_CLIENTLIST_ACTION && _clientlist_proc[index] != NULL) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1328 |
_clientlist_proc[index](clientno); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1329 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1330 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1331 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1332 |
/** |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1333 |
* Finds the amount of clients and set the height correct |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1334 |
*/ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1335 |
static bool CheckClientListHeight(Window *w) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1336 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1337 |
int num = 0; |
4883
801b93ae218c
(svn r6820) -Codechange: Some more const correctness, coding style.
Darkvater
parents:
4880
diff
changeset
|
1338 |
const NetworkClientInfo *ci; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1339 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1340 |
/* Should be replaced with a loop through all clients */ |
4883
801b93ae218c
(svn r6820) -Codechange: Some more const correctness, coding style.
Darkvater
parents:
4880
diff
changeset
|
1341 |
FOR_ALL_ACTIVE_CLIENT_INFOS(ci) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1342 |
num++; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1343 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1344 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1345 |
num *= CLNWND_ROWSIZE; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1346 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1347 |
/* If height is changed */ |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1348 |
if (w->height != CLNWND_OFFSET + num + 1) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1349 |
// XXX - magic unfortunately; (num + 2) has to be one bigger than heigh (num + 1) |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1350 |
SetWindowDirty(w); |
7525
d0e21b315b60
(svn r10293) -Add [FS#885]: a sticky button for the client list window (oxygene)
truelight
parents:
7498
diff
changeset
|
1351 |
w->widget[3].bottom = w->widget[3].top + num + 2; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1352 |
w->height = CLNWND_OFFSET + num + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1353 |
SetWindowDirty(w); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1354 |
return false; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1355 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1356 |
return true; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1357 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1358 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1359 |
/** |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1360 |
* Finds the amount of actions in the popup and set the height correct |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1361 |
*/ |
7817
f24498d934ac
(svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents:
7717
diff
changeset
|
1362 |
static uint ClientListPopupHeight() |
f24498d934ac
(svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents:
7717
diff
changeset
|
1363 |
{ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1364 |
int num = 0; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1365 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1366 |
// Find the amount of actions |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1367 |
for (int i = 0; i < MAX_CLIENTLIST_ACTION; i++) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1368 |
if (_clientlist_action[i][0] == '\0') continue; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1369 |
if (_clientlist_proc[i] == NULL) continue; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1370 |
num++; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1371 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1372 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1373 |
num *= CLNWND_ROWSIZE; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1374 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1375 |
return num + 1; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1376 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1377 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1378 |
/** |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1379 |
* Show the popup (action list) |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1380 |
*/ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1381 |
static Window *PopupClientList(Window *w, int client_no, int x, int y) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1382 |
{ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1383 |
int i; |
4171 | 1384 |
const NetworkClientInfo *ci; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1385 |
DeleteWindowById(WC_TOOLBAR_MENU, 0); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1386 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1387 |
/* Clean the current actions */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1388 |
for (i = 0; i < MAX_CLIENTLIST_ACTION; i++) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1389 |
_clientlist_action[i][0] = '\0'; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1390 |
_clientlist_proc[i] = NULL; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1391 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1392 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1393 |
/* |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1394 |
* Fill the actions this client has. |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1395 |
* Watch is, max 50 chars long! |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1396 |
*/ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1397 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1398 |
ci = NetworkFindClientInfo(client_no); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1399 |
if (ci == NULL) return NULL; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1400 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1401 |
i = 0; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1402 |
if (_network_own_client_index != ci->client_index) { |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
1403 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_CLIENT, lastof(_clientlist_action[i])); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1404 |
_clientlist_proc[i++] = &ClientList_SpeakToClient; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1405 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1406 |
|
4945
c5c9bfb156fb
(svn r6933) -Feature: Allow spectators to speak to eachother (team)
Darkvater
parents:
4943
diff
changeset
|
1407 |
if (IsValidPlayer(ci->client_playas) || ci->client_playas == PLAYER_SPECTATOR) { |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
1408 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY, lastof(_clientlist_action[i])); |
4906
8a10678a62a3
(svn r6876) -Codechange: Change the naming of _PLAYER in DESTTYPE_PLAYER/NETWORK_ACTION_CHAT_PLAYER
Darkvater
parents:
4895
diff
changeset
|
1409 |
_clientlist_proc[i++] = &ClientList_SpeakToCompany; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1410 |
} |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
1411 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_ALL, lastof(_clientlist_action[i])); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1412 |
_clientlist_proc[i++] = &ClientList_SpeakToAll; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1413 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1414 |
if (_network_own_client_index != ci->client_index) { |
8153
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7937
diff
changeset
|
1415 |
/* We are no spectator and the player we want to give money to is no spectator and money gifts are allowed */ |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7937
diff
changeset
|
1416 |
if (IsValidPlayer(_network_playas) && IsValidPlayer(ci->client_playas) && _patches.give_money) { |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
1417 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_GIVE_MONEY, lastof(_clientlist_action[i])); |
4878
744717de172e
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
1418 |
_clientlist_proc[i++] = &ClientList_GiveMoney; |
0 | 1419 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1420 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1421 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1422 |
/* A server can kick clients (but not himself) */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1423 |
if (_network_server && _network_own_client_index != ci->client_index) { |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
1424 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_KICK, lastof(_clientlist_action[i])); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1425 |
_clientlist_proc[i++] = &ClientList_Kick; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1426 |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
1427 |
sprintf(_clientlist_action[i],"Ban"); // XXX GetString? |
841
8f0a68c6f43b
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
827
diff
changeset
|
1428 |
_clientlist_proc[i++] = &ClientList_Ban; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1429 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1430 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1431 |
if (i == 0) { |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
1432 |
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_NONE, lastof(_clientlist_action[i])); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1433 |
_clientlist_proc[i++] = &ClientList_None; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1434 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1435 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1436 |
/* Calculate the height */ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1437 |
int h = ClientListPopupHeight(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1438 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1439 |
/* Allocate the popup */ |
3250
bf64b3e5f8db
(svn r3933) - [ 1439907 ] Increase client list window width so at least most languages fit (wikipedian).
Darkvater
parents:
2952
diff
changeset
|
1440 |
w = AllocateWindow(x, y, 150, h + 1, ClientListPopupWndProc, WC_TOOLBAR_MENU, _client_list_popup_widgets); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1441 |
w->widget[0].bottom = w->widget[0].top + h; |
3250
bf64b3e5f8db
(svn r3933) - [ 1439907 ] Increase client list window width so at least most languages fit (wikipedian).
Darkvater
parents:
2952
diff
changeset
|
1442 |
w->widget[0].right = w->widget[0].left + 150; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1443 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1444 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; |
8578
55218950ce2d
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8565
diff
changeset
|
1445 |
WP(w, menu_d).item_count = 0; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1446 |
// Save our client |
8578
55218950ce2d
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8565
diff
changeset
|
1447 |
WP(w, menu_d).main_button = client_no; |
55218950ce2d
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8565
diff
changeset
|
1448 |
WP(w, menu_d).sel_index = 0; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1449 |
// We are a popup |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1450 |
_popup_menu_active = true; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1451 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1452 |
return w; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1453 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1454 |
|
2887
d5967e472eee
(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
|
1455 |
/** Main handle for the client popup list |
d5967e472eee
(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
|
1456 |
* uses menu_d WP macro */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1457 |
static void ClientListPopupWndProc(Window *w, WindowEvent *e) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1458 |
{ |
2639 | 1459 |
switch (e->event) { |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1460 |
case WE_PAINT: { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1461 |
DrawWindowWidgets(w); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1462 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1463 |
/* Draw the actions */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1464 |
int sel = WP(w, menu_d).sel_index; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1465 |
int y = 1; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1466 |
for (int i = 0; i < MAX_CLIENTLIST_ACTION; i++, y += CLNWND_ROWSIZE) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1467 |
if (_clientlist_action[i][0] == '\0') continue; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1468 |
if (_clientlist_proc[i] == NULL) continue; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1469 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1470 |
TextColour colour; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1471 |
if (sel-- == 0) { // Selected item, highlight it |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1472 |
GfxFillRect(1, y, 150 - 2, y + CLNWND_ROWSIZE - 1, 0); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1473 |
colour = TC_WHITE; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1474 |
} else { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1475 |
colour = TC_BLACK; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1476 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1477 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1478 |
DoDrawString(_clientlist_action[i], 4, y, colour); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1479 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1480 |
} break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1481 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1482 |
case WE_POPUPMENU_SELECT: { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1483 |
/* We selected an action */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1484 |
int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1485 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1486 |
if (index >= 0 && e->we.popupmenu.pt.y >= w->top) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1487 |
HandleClientListPopupClick(index, WP(w, menu_d).main_button); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
1488 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1489 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1490 |
DeleteWindowById(WC_TOOLBAR_MENU, 0); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1491 |
} break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1492 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1493 |
case WE_POPUPMENU_OVER: { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1494 |
/* Our mouse hoovers over an action? Select it! */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1495 |
int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1496 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1497 |
if (index == -1 || index == WP(w, menu_d).sel_index) return; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1498 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1499 |
WP(w, menu_d).sel_index = index; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1500 |
SetWindowDirty(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1501 |
} break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1502 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1503 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1504 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1505 |
/** |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1506 |
* Main handle for clientlist |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1507 |
*/ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1508 |
static void ClientListWndProc(Window *w, WindowEvent *e) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1509 |
{ |
2639 | 1510 |
switch (e->event) { |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1511 |
case WE_PAINT: { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1512 |
NetworkClientInfo *ci; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1513 |
int i = 0; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1514 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1515 |
/* Check if we need to reset the height */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1516 |
if (!CheckClientListHeight(w)) break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1517 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1518 |
DrawWindowWidgets(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1519 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1520 |
int y = CLNWND_OFFSET; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1521 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1522 |
FOR_ALL_ACTIVE_CLIENT_INFOS(ci) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1523 |
TextColour colour; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1524 |
if (_selected_clientlist_item == i++) { // Selected item, highlight it |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1525 |
GfxFillRect(1, y, 248, y + CLNWND_ROWSIZE - 1, 0); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1526 |
colour = TC_WHITE; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1527 |
} else { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1528 |
colour = TC_BLACK; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1529 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1530 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1531 |
if (ci->client_index == NETWORK_SERVER_INDEX) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1532 |
DrawString(4, y, STR_NETWORK_SERVER, colour); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1533 |
} else { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1534 |
DrawString(4, y, STR_NETWORK_CLIENT, colour); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1535 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1536 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1537 |
/* Filter out spectators */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1538 |
if (IsValidPlayer(ci->client_playas)) DrawPlayerIcon(ci->client_playas, 64, y + 1); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1539 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1540 |
DoDrawString(ci->client_name, 81, y, colour); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1541 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1542 |
y += CLNWND_ROWSIZE; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1543 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1544 |
} break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1545 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1546 |
case WE_CLICK: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1547 |
/* Show the popup with option */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1548 |
if (_selected_clientlist_item != 255) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1549 |
PopupClientList(w, _selected_clientlist_item, e->we.click.pt.x + w->left, e->we.click.pt.y + w->top); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1550 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1551 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1552 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1553 |
case WE_MOUSEOVER: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1554 |
/* -1 means we left the current window */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1555 |
if (e->we.mouseover.pt.y == -1) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1556 |
_selected_clientlist_y = 0; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1557 |
_selected_clientlist_item = 255; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1558 |
SetWindowDirty(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1559 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1560 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1561 |
/* It did not change.. no update! */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1562 |
if (e->we.mouseover.pt.y == _selected_clientlist_y) break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1563 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1564 |
/* Find the new selected item (if any) */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1565 |
_selected_clientlist_y = e->we.mouseover.pt.y; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1566 |
if (e->we.mouseover.pt.y > CLNWND_OFFSET) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1567 |
_selected_clientlist_item = (e->we.mouseover.pt.y - CLNWND_OFFSET) / CLNWND_ROWSIZE; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
1568 |
} else { |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1569 |
_selected_clientlist_item = 255; |
2639 | 1570 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1571 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1572 |
/* Repaint */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1573 |
SetWindowDirty(w); |
0 | 1574 |
break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1575 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1576 |
case WE_DESTROY: case WE_CREATE: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1577 |
/* When created or destroyed, data is reset */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1578 |
_selected_clientlist_item = 255; |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1579 |
_selected_clientlist_y = 0; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1580 |
break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1581 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1582 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1583 |
|
6573 | 1584 |
void ShowClientList() |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1585 |
{ |
4491 | 1586 |
AllocateWindowDescFront(&_client_list_desc, 0); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1587 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1588 |
|
4512
7151d4ee3a0f
(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
|
1589 |
|
7151d4ee3a0f
(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
|
1590 |
static NetworkPasswordType pw_type; |
7151d4ee3a0f
(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
|
1591 |
|
7151d4ee3a0f
(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
|
1592 |
|
7151d4ee3a0f
(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
|
1593 |
void ShowNetworkNeedPassword(NetworkPasswordType npt) |
7151d4ee3a0f
(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
|
1594 |
{ |
7151d4ee3a0f
(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
|
1595 |
StringID caption; |
7151d4ee3a0f
(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
|
1596 |
|
7151d4ee3a0f
(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
|
1597 |
pw_type = npt; |
7151d4ee3a0f
(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
|
1598 |
switch (npt) { |
7151d4ee3a0f
(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
|
1599 |
default: NOT_REACHED(); |
4774
91b96d852ba5
(svn r6688) -Fix (r6297): Wrong caption for server password query window (eg put 'break' after switch statements)
Darkvater
parents:
4719
diff
changeset
|
1600 |
case NETWORK_GAME_PASSWORD: caption = STR_NETWORK_NEED_GAME_PASSWORD_CAPTION; break; |
91b96d852ba5
(svn r6688) -Fix (r6297): Wrong caption for server password query window (eg put 'break' after switch statements)
Darkvater
parents:
4719
diff
changeset
|
1601 |
case NETWORK_COMPANY_PASSWORD: caption = STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION; break; |
4512
7151d4ee3a0f
(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
|
1602 |
} |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5352
diff
changeset
|
1603 |
ShowQueryString(STR_EMPTY, caption, 20, 180, FindWindowById(WC_NETWORK_STATUS_WINDOW, 0), CS_ALPHANUMERAL); |
4512
7151d4ee3a0f
(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
|
1604 |
} |
7151d4ee3a0f
(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
|
1605 |
|
7151d4ee3a0f
(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
|
1606 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1607 |
static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1608 |
{ |
2639 | 1609 |
switch (e->event) { |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1610 |
case WE_PAINT: { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1611 |
uint8 progress; // used for progress bar |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1612 |
DrawWindowWidgets(w); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1613 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1614 |
DrawStringCentered(125, 35, STR_NETWORK_CONNECTING_1 + _network_join_status, TC_GREY); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1615 |
switch (_network_join_status) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1616 |
case NETWORK_JOIN_STATUS_CONNECTING: case NETWORK_JOIN_STATUS_AUTHORIZING: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1617 |
case NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1618 |
progress = 10; // first two stages 10% |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1619 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1620 |
case NETWORK_JOIN_STATUS_WAITING: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1621 |
SetDParam(0, _network_join_waiting); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1622 |
DrawStringCentered(125, 46, STR_NETWORK_CONNECTING_WAITING, TC_GREY); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1623 |
progress = 15; // third stage is 15% |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1624 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1625 |
case NETWORK_JOIN_STATUS_DOWNLOADING: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1626 |
SetDParam(0, _network_join_kbytes); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1627 |
SetDParam(1, _network_join_kbytes_total); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1628 |
DrawStringCentered(125, 46, STR_NETWORK_CONNECTING_DOWNLOADING, TC_GREY); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1629 |
/* Fallthrough */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1630 |
default: /* Waiting is 15%, so the resting receivement of map is maximum 70% */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1631 |
progress = 15 + _network_join_kbytes * (100 - 15) / _network_join_kbytes_total; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1632 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1633 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1634 |
/* Draw nice progress bar :) */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1635 |
DrawFrameRect(20, 18, (int)((w->width - 20) * progress / 100), 28, 10, FR_NONE); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1636 |
} break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1637 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1638 |
case WE_CLICK: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1639 |
if (e->we.click.widget == 2) { //Disconnect button |
2639 | 1640 |
NetworkDisconnect(); |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5352
diff
changeset
|
1641 |
DeleteWindow(w); |
2639 | 1642 |
SwitchMode(SM_MENU); |
1643 |
ShowNetworkGameWindow(); |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1644 |
} |
4512
7151d4ee3a0f
(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
|
1645 |
break; |
7151d4ee3a0f
(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
|
1646 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1647 |
/* If the server asks for a password, we need to fill it in */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1648 |
case WE_ON_EDIT_TEXT_CANCEL: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1649 |
NetworkDisconnect(); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1650 |
ShowNetworkGameWindow(); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1651 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1652 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1653 |
case WE_ON_EDIT_TEXT: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1654 |
SEND_COMMAND(PACKET_CLIENT_PASSWORD)(pw_type, e->we.edittext.str); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1655 |
break; |
0 | 1656 |
} |
1657 |
} |
|
1658 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1659 |
static const Widget _network_join_status_window_widget[] = { |
5683
dca046ba7aa3
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5682
diff
changeset
|
1660 |
{ WWT_CAPTION, RESIZE_NONE, 14, 0, 249, 0, 13, STR_NETWORK_CONNECTING, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1661 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 249, 14, 84, 0x0, STR_NULL}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
853
diff
changeset
|
1662 |
{ 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
|
1663 |
{ WIDGETS_END}, |
0 | 1664 |
}; |
1665 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1666 |
static const WindowDesc _network_join_status_window_desc = { |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7817
diff
changeset
|
1667 |
WDP_CENTER, WDP_CENTER, 250, 85, 250, 85, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5920
diff
changeset
|
1668 |
WC_NETWORK_STATUS_WINDOW, WC_NONE, |
5683
dca046ba7aa3
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5682
diff
changeset
|
1669 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_MODAL, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1670 |
_network_join_status_window_widget, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1671 |
NetworkJoinStatusWindowWndProc, |
0 | 1672 |
}; |
1673 |
||
6573 | 1674 |
void ShowJoinStatusWindow() |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1675 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1676 |
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1677 |
Window *w = AllocateWindowDesc(&_network_join_status_window_desc); |
5683
dca046ba7aa3
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5682
diff
changeset
|
1678 |
/* Parent the status window to the lobby */ |
dca046ba7aa3
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5682
diff
changeset
|
1679 |
if (w != NULL) w->parent = FindWindowById(WC_NETWORK_WINDOW, 0); |
670
7c58dc46609c
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
659
diff
changeset
|
1680 |
} |
0 | 1681 |
|
7027
f3d60745346d
(svn r9719) -Fix: in-game private messages did not work for clients with a Client ID > 255.
rubidium
parents:
6988
diff
changeset
|
1682 |
static void SendChat(const char *buf, DestType type, int dest) |
4013
a11adcc2a852
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1683 |
{ |
7817
f24498d934ac
(svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents:
7717
diff
changeset
|
1684 |
if (StrEmpty(buf)) return; |
4013
a11adcc2a852
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1685 |
if (!_network_server) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1686 |
SEND_COMMAND(PACKET_CLIENT_CHAT)((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf); |
4013
a11adcc2a852
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1687 |
} else { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1688 |
NetworkServer_HandleChat((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf, NETWORK_SERVER_INDEX); |
4013
a11adcc2a852
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1689 |
} |
a11adcc2a852
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1690 |
} |
a11adcc2a852
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1691 |
|
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1692 |
/** |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1693 |
* Find the next item of the list of things that can be auto-completed. |
4319
143de57b0e73
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1694 |
* @param item The current indexed item to return. This function can, and most |
143de57b0e73
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1695 |
* likely will, alter item, to skip empty items in the arrays. |
143de57b0e73
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1696 |
* @return Returns the char that matched to the index. |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1697 |
*/ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1698 |
static const char *ChatTabCompletionNextItem(uint *item) |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1699 |
{ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1700 |
static char chat_tab_temp_buffer[64]; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1701 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1702 |
/* First, try clients */ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1703 |
if (*item < MAX_CLIENT_INFO) { |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1704 |
/* Skip inactive clients */ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1705 |
while (_network_client_info[*item].client_index == NETWORK_EMPTY_INDEX && *item < MAX_CLIENT_INFO) (*item)++; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1706 |
if (*item < MAX_CLIENT_INFO) return _network_client_info[*item].client_name; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1707 |
} |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1708 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1709 |
/* Then, try townnames */ |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5125
diff
changeset
|
1710 |
/* Not that the following assumes all town indices are adjacent, ie no |
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5125
diff
changeset
|
1711 |
* towns have been deleted. */ |
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5125
diff
changeset
|
1712 |
if (*item <= (uint)MAX_CLIENT_INFO + GetMaxTownIndex()) { |
4319
143de57b0e73
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1713 |
const Town *t; |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1714 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1715 |
FOR_ALL_TOWNS_FROM(t, *item - MAX_CLIENT_INFO) { |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1716 |
/* Get the town-name via the string-system */ |
7452
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7294
diff
changeset
|
1717 |
SetDParam(0, t->index); |
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7294
diff
changeset
|
1718 |
GetString(chat_tab_temp_buffer, STR_TOWN, lastof(chat_tab_temp_buffer)); |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1719 |
return &chat_tab_temp_buffer[0]; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1720 |
} |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1721 |
} |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1722 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1723 |
return NULL; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1724 |
} |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1725 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1726 |
/** |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1727 |
* Find what text to complete. It scans for a space from the left and marks |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1728 |
* the word right from that as to complete. It also writes a \0 at the |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1729 |
* position of the space (if any). If nothing found, buf is returned. |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1730 |
*/ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1731 |
static char *ChatTabCompletionFindText(char *buf) |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1732 |
{ |
4880
0708f34e3586
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
1733 |
char *p = strrchr(buf, ' '); |
4319
143de57b0e73
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1734 |
if (p == NULL) return buf; |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1735 |
|
4319
143de57b0e73
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1736 |
*p = '\0'; |
143de57b0e73
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
truelight
parents:
4315
diff
changeset
|
1737 |
return p + 1; |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1738 |
} |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1739 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1740 |
/** |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1741 |
* See if we can auto-complete the current text of the user. |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1742 |
*/ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1743 |
static void ChatTabCompletion(Window *w) |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1744 |
{ |
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
1745 |
static char _chat_tab_completion_buf[lengthof(_edit_str_net_buf)]; |
7027
f3d60745346d
(svn r9719) -Fix: in-game private messages did not work for clients with a Client ID > 255.
rubidium
parents:
6988
diff
changeset
|
1746 |
Textbuf *tb = &WP(w, chatquerystr_d).text; |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1747 |
uint len, tb_len; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1748 |
uint item; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1749 |
char *tb_buf, *pre_buf; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1750 |
const char *cur_name; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1751 |
bool second_scan = false; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1752 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1753 |
item = 0; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1754 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1755 |
/* Copy the buffer so we can modify it without damaging the real data */ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1756 |
pre_buf = (_chat_tab_completion_active) ? strdup(_chat_tab_completion_buf) : strdup(tb->buf); |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1757 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1758 |
tb_buf = ChatTabCompletionFindText(pre_buf); |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1759 |
tb_len = strlen(tb_buf); |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1760 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1761 |
while ((cur_name = ChatTabCompletionNextItem(&item)) != NULL) { |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1762 |
item++; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1763 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1764 |
if (_chat_tab_completion_active) { |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1765 |
/* We are pressing TAB again on the same name, is there an other name |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1766 |
* that starts with this? */ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1767 |
if (!second_scan) { |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1768 |
uint offset; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1769 |
uint length; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1770 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1771 |
/* If we are completing at the begin of the line, skip the ': ' we added */ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1772 |
if (tb_buf == pre_buf) { |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1773 |
offset = 0; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1774 |
length = tb->length - 2; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1775 |
} else { |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1776 |
/* Else, find the place we are completing at */ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1777 |
offset = strlen(pre_buf) + 1; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1778 |
length = tb->length - offset; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1779 |
} |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1780 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1781 |
/* Compare if we have a match */ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1782 |
if (strlen(cur_name) == length && strncmp(cur_name, tb->buf + offset, length) == 0) second_scan = true; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1783 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1784 |
continue; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1785 |
} |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1786 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1787 |
/* Now any match we make on _chat_tab_completion_buf after this, is perfect */ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1788 |
} |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1789 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1790 |
len = strlen(cur_name); |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1791 |
if (tb_len < len && strncasecmp(cur_name, tb_buf, tb_len) == 0) { |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1792 |
/* Save the data it was before completion */ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1793 |
if (!second_scan) snprintf(_chat_tab_completion_buf, lengthof(_chat_tab_completion_buf), "%s", tb->buf); |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1794 |
_chat_tab_completion_active = true; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1795 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1796 |
/* Change to the found name. Add ': ' if we are at the start of the line (pretty) */ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1797 |
if (pre_buf == tb_buf) { |
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
1798 |
snprintf(tb->buf, lengthof(_edit_str_net_buf), "%s: ", cur_name); |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1799 |
} else { |
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
1800 |
snprintf(tb->buf, lengthof(_edit_str_net_buf), "%s %s", pre_buf, cur_name); |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1801 |
} |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1802 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1803 |
/* Update the textbuffer */ |
7027
f3d60745346d
(svn r9719) -Fix: in-game private messages did not work for clients with a Client ID > 255.
rubidium
parents:
6988
diff
changeset
|
1804 |
UpdateTextBufferSize(&WP(w, chatquerystr_d).text); |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1805 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1806 |
SetWindowDirty(w); |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1807 |
free(pre_buf); |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1808 |
return; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1809 |
} |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1810 |
} |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1811 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1812 |
if (second_scan) { |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1813 |
/* We walked all posibilities, and the user presses tab again.. revert to original text */ |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1814 |
strcpy(tb->buf, _chat_tab_completion_buf); |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1815 |
_chat_tab_completion_active = false; |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1816 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1817 |
/* Update the textbuffer */ |
7027
f3d60745346d
(svn r9719) -Fix: in-game private messages did not work for clients with a Client ID > 255.
rubidium
parents:
6988
diff
changeset
|
1818 |
UpdateTextBufferSize(&WP(w, chatquerystr_d).text); |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1819 |
|
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1820 |
SetWindowDirty(w); |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1821 |
} |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1822 |
free(pre_buf); |
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1823 |
} |
4013
a11adcc2a852
(svn r5226) Reduce the mess that sending chat messages is
tron
parents:
3860
diff
changeset
|
1824 |
|
7027
f3d60745346d
(svn r9719) -Fix: in-game private messages did not work for clients with a Client ID > 255.
rubidium
parents:
6988
diff
changeset
|
1825 |
/* |
f3d60745346d
(svn r9719) -Fix: in-game private messages did not work for clients with a Client ID > 255.
rubidium
parents:
6988
diff
changeset
|
1826 |
* uses chatquerystr_d WP macro |
9223
3512b3d48703
(svn r12403) -Codechange: unmisuse a variable in the chat window and make the code a little cleaner.
rubidium
parents:
9193
diff
changeset
|
1827 |
* uses chatquerystr_d->dtype to store type of chat message (Private/Team/All) |
7027
f3d60745346d
(svn r9719) -Fix: in-game private messages did not work for clients with a Client ID > 255.
rubidium
parents:
6988
diff
changeset
|
1828 |
*/ |
649 | 1829 |
static void ChatWindowWndProc(Window *w, WindowEvent *e) |
1830 |
{ |
|
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
1831 |
switch (e->event) { |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1832 |
case WE_CREATE: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1833 |
SendWindowMessage(WC_NEWS_WINDOW, 0, WE_CREATE, w->height, 0); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1834 |
SetBit(_no_scroll, SCROLL_CHAT); // do not scroll the game with the arrow-keys |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1835 |
break; |
649 | 1836 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1837 |
case WE_PAINT: { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1838 |
static const StringID chat_captions[] = { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1839 |
STR_NETWORK_CHAT_ALL_CAPTION, |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1840 |
STR_NETWORK_CHAT_COMPANY_CAPTION, |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1841 |
STR_NETWORK_CHAT_CLIENT_CAPTION |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1842 |
}; |
9233
4daa9bb8dbf7
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
9224
diff
changeset
|
1843 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1844 |
DrawWindowWidgets(w); |
649 | 1845 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1846 |
assert((uint)WP(w, chatquerystr_d).dtype < lengthof(chat_captions)); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1847 |
DrawStringRightAligned(w->widget[2].left - 2, w->widget[2].top + 1, chat_captions[WP(w, chatquerystr_d).dtype], TC_BLACK); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1848 |
DrawEditBox(w, &WP(w, chatquerystr_d), 2); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1849 |
} break; |
649 | 1850 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1851 |
case WE_CLICK: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1852 |
switch (e->we.click.widget) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1853 |
case 2: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1854 |
ShowOnScreenKeyboard(w, &WP(w, chatquerystr_d), 2, 0, 3); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1855 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1856 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1857 |
case 3: /* Send */ |
9223
3512b3d48703
(svn r12403) -Codechange: unmisuse a variable in the chat window and make the code a little cleaner.
rubidium
parents:
9193
diff
changeset
|
1858 |
SendChat(WP(w, chatquerystr_d).text.buf, WP(w, chatquerystr_d).dtype, WP(w, chatquerystr_d).dest); |
3512b3d48703
(svn r12403) -Codechange: unmisuse a variable in the chat window and make the code a little cleaner.
rubidium
parents:
9193
diff
changeset
|
1859 |
/* FALLTHROUGH */ |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1860 |
case 0: /* Cancel */ DeleteWindow(w); break; |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1861 |
} |
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1862 |
break; |
649 | 1863 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1864 |
case WE_MOUSELOOP: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1865 |
HandleEditBox(w, &WP(w, chatquerystr_d), 2); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1866 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1867 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1868 |
case WE_KEYPRESS: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1869 |
if (e->we.keypress.keycode == WKC_TAB) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1870 |
ChatTabCompletion(w); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1871 |
} else { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1872 |
_chat_tab_completion_active = false; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1873 |
switch (HandleEditBoxKey(w, &WP(w, chatquerystr_d), 2, e)) { |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1874 |
case 1: /* Return */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1875 |
SendChat(WP(w, chatquerystr_d).text.buf, WP(w, chatquerystr_d).dtype, WP(w, chatquerystr_d).dest); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1876 |
/* FALLTHROUGH */ |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1877 |
case 2: /* Escape */ DeleteWindow(w); break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1878 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1879 |
} |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1880 |
break; |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1881 |
|
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1882 |
case WE_DESTROY: |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1883 |
SendWindowMessage(WC_NEWS_WINDOW, 0, WE_DESTROY, 0, 0); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1884 |
ClrBit(_no_scroll, SCROLL_CHAT); |
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1885 |
break; |
649 | 1886 |
} |
1887 |
} |
|
1888 |
||
1889 |
static const Widget _chat_window_widgets[] = { |
|
9233
4daa9bb8dbf7
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
9224
diff
changeset
|
1890 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4daa9bb8dbf7
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
9224
diff
changeset
|
1891 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 11, 319, 0, 13, 0x0, STR_NULL}, // background |
4daa9bb8dbf7
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
9224
diff
changeset
|
1892 |
{ WWT_EDITBOX, RESIZE_RIGHT, 14, 75, 257, 1, 12, STR_NETWORK_CHAT_OSKTITLE, STR_NULL}, // text box |
4daa9bb8dbf7
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
9224
diff
changeset
|
1893 |
{ WWT_PUSHTXTBTN, RESIZE_LR, 14, 258, 319, 1, 12, STR_NETWORK_SEND, STR_NULL}, // send button |
649 | 1894 |
{ WIDGETS_END}, |
1895 |
}; |
|
1896 |
||
1897 |
static const WindowDesc _chat_window_desc = { |
|
7859
f0d341e69326
(svn r10726) -Codechange: make it possible that the chat window is less than 640 pixels.
rubidium
parents:
7839
diff
changeset
|
1898 |
WDP_CENTER, -26, 320, 14, 640, 14, // x, y, width, height |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5920
diff
changeset
|
1899 |
WC_SEND_NETWORK_MSG, WC_NONE, |
8515
d0401d967e99
(svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents:
8514
diff
changeset
|
1900 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET, |
649 | 1901 |
_chat_window_widgets, |
1902 |
ChatWindowWndProc |
|
1903 |
}; |
|
1904 |
||
7027
f3d60745346d
(svn r9719) -Fix: in-game private messages did not work for clients with a Client ID > 255.
rubidium
parents:
6988
diff
changeset
|
1905 |
void ShowNetworkChatQueryWindow(DestType type, int dest) |
649 | 1906 |
{ |
1907 |
DeleteWindowById(WC_SEND_NETWORK_MSG, 0); |
|
1908 |
||
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
1909 |
_edit_str_net_buf[0] = '\0'; |
4315
a0fc451fad6b
(svn r5968) -Feature: add auto-completion in chat-window. It completes Player-Names and
truelight
parents:
4300
diff
changeset
|
1910 |
_chat_tab_completion_active = false; |
649 | 1911 |
|
9234
8123d1c8e796
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
9233
diff
changeset
|
1912 |
Window *w = AllocateWindowDesc(&_chat_window_desc); |
649 | 1913 |
|
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8462
diff
changeset
|
1914 |
w->LowerWidget(2); |
9223
3512b3d48703
(svn r12403) -Codechange: unmisuse a variable in the chat window and make the code a little cleaner.
rubidium
parents:
9193
diff
changeset
|
1915 |
WP(w, chatquerystr_d).dtype = type; |
7027
f3d60745346d
(svn r9719) -Fix: in-game private messages did not work for clients with a Client ID > 255.
rubidium
parents:
6988
diff
changeset
|
1916 |
WP(w, chatquerystr_d).dest = dest; |
f3d60745346d
(svn r9719) -Fix: in-game private messages did not work for clients with a Client ID > 255.
rubidium
parents:
6988
diff
changeset
|
1917 |
WP(w, chatquerystr_d).afilter = CS_ALPHANUMERAL; |
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
1918 |
InitializeTextBuffer(&WP(w, chatquerystr_d).text, _edit_str_net_buf, lengthof(_edit_str_net_buf), 0); |
649 | 1919 |
} |
1920 |
||
8494
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1921 |
/** Enum for NetworkGameWindow, referring to _network_game_window_widgets */ |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1922 |
enum NetworkCompanyPasswordWindowWidgets { |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1923 |
NCPWW_CLOSE, ///< Close 'X' button |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1924 |
NCPWW_CAPTION, ///< Caption of the whole window |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1925 |
NCPWW_BACKGROUND, ///< The background of the interface |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1926 |
NCPWW_LABEL, ///< Label in front of the password field |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1927 |
NCPWW_PASSWORD, ///< Input field for the password |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1928 |
NCPWW_SAVE_AS_DEFAULT_PASSWORD, ///< Toggle 'button' for saving the current password as default password |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1929 |
NCPWW_CANCEL, ///< Close the window without changing anything |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1930 |
NCPWW_OK, ///< Safe the password etc. |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1931 |
}; |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1932 |
|
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1933 |
static void NetworkCompanyPasswordWindowWndProc(Window *w, WindowEvent *e) |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1934 |
{ |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1935 |
switch (e->event) { |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1936 |
case WE_PAINT: |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1937 |
DrawWindowWidgets(w); |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1938 |
DrawEditBox(w, &WP(w, chatquerystr_d), 4); |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1939 |
break; |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1940 |
|
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1941 |
case WE_CLICK: |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1942 |
switch (e->we.click.widget) { |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1943 |
case NCPWW_OK: { |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1944 |
if (w->IsWidgetLowered(NCPWW_SAVE_AS_DEFAULT_PASSWORD)) { |
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
1945 |
snprintf(_network_default_company_pass, lengthof(_network_default_company_pass), "%s", _edit_str_net_buf); |
8494
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1946 |
} |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1947 |
|
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1948 |
/* empty password is a '*' because of console argument */ |
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
1949 |
if (StrEmpty(_edit_str_net_buf)) snprintf(_edit_str_net_buf, lengthof(_edit_str_net_buf), "*"); |
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
1950 |
char *password = _edit_str_net_buf; |
8494
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1951 |
NetworkChangeCompanyPassword(1, &password); |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1952 |
} |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1953 |
|
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1954 |
/* FALL THROUGH */ |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1955 |
case NCPWW_CANCEL: |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1956 |
DeleteWindow(w); |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1957 |
break; |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1958 |
|
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1959 |
case NCPWW_SAVE_AS_DEFAULT_PASSWORD: |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1960 |
w->ToggleWidgetLoweredState(NCPWW_SAVE_AS_DEFAULT_PASSWORD); |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1961 |
SetWindowDirty(w); |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1962 |
break; |
9233
4daa9bb8dbf7
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
9224
diff
changeset
|
1963 |
case NCPWW_PASSWORD: |
4daa9bb8dbf7
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
9224
diff
changeset
|
1964 |
ShowOnScreenKeyboard(w, &WP(w, chatquerystr_d), NCPWW_PASSWORD, 2, 1); |
4daa9bb8dbf7
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
9224
diff
changeset
|
1965 |
break; |
8494
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1966 |
} |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1967 |
break; |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1968 |
|
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1969 |
case WE_MOUSELOOP: |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1970 |
HandleEditBox(w, &WP(w, chatquerystr_d), 4); |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1971 |
break; |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1972 |
|
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1973 |
case WE_KEYPRESS: |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1974 |
switch (HandleEditBoxKey(w, &WP(w, chatquerystr_d), 4, e)) { |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1975 |
case 1: // Return |
8583
3c3f27c720d6
(svn r11648) -Fix [FS#1560]: the company password was not set when one pressed the enter key.
rubidium
parents:
8578
diff
changeset
|
1976 |
e->event = WE_CLICK; |
3c3f27c720d6
(svn r11648) -Fix [FS#1560]: the company password was not set when one pressed the enter key.
rubidium
parents:
8578
diff
changeset
|
1977 |
e->we.click.widget = NCPWW_OK; |
3c3f27c720d6
(svn r11648) -Fix [FS#1560]: the company password was not set when one pressed the enter key.
rubidium
parents:
8578
diff
changeset
|
1978 |
NetworkCompanyPasswordWindowWndProc(w, e); |
3c3f27c720d6
(svn r11648) -Fix [FS#1560]: the company password was not set when one pressed the enter key.
rubidium
parents:
8578
diff
changeset
|
1979 |
break; |
3c3f27c720d6
(svn r11648) -Fix [FS#1560]: the company password was not set when one pressed the enter key.
rubidium
parents:
8578
diff
changeset
|
1980 |
|
8494
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1981 |
case 2: // Escape |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1982 |
DeleteWindow(w); |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1983 |
break; |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1984 |
} |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1985 |
break; |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1986 |
} |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1987 |
} |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1988 |
|
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1989 |
static const Widget _ncp_window_widgets[] = { |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1990 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1991 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 299, 0, 13, STR_COMPANY_PASSWORD_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1992 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 299, 14, 50, 0x0, STR_NULL}, |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1993 |
{ WWT_TEXT, RESIZE_NONE, 14, 5, 100, 19, 30, STR_COMPANY_PASSWORD, STR_NULL}, |
9233
4daa9bb8dbf7
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
9224
diff
changeset
|
1994 |
{ WWT_EDITBOX, RESIZE_NONE, 14, 101, 294, 19, 30, STR_SET_COMPANY_PASSWORD, STR_NULL}, |
8494
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1995 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 101, 294, 35, 46, STR_MAKE_DEFAULT_COMPANY_PASSWORD, STR_MAKE_DEFAULT_COMPANY_PASSWORD_TIP}, |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1996 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 149, 51, 62, STR_012E_CANCEL, STR_COMPANY_PASSWORD_CANCEL}, |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1997 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 150, 299, 51, 62, STR_012F_OK, STR_COMPANY_PASSWORD_OK}, |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1998 |
{ WIDGETS_END}, |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
1999 |
}; |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2000 |
|
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2001 |
static const WindowDesc _ncp_window_desc = { |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2002 |
WDP_AUTO, WDP_AUTO, 300, 63, 300, 63, |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2003 |
WC_COMPANY_PASSWORD_WINDOW, WC_NONE, |
8515
d0401d967e99
(svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents:
8514
diff
changeset
|
2004 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
8494
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2005 |
_ncp_window_widgets, |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2006 |
NetworkCompanyPasswordWindowWndProc |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2007 |
}; |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2008 |
|
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2009 |
void ShowNetworkCompanyPasswordWindow() |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2010 |
{ |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2011 |
DeleteWindowById(WC_COMPANY_PASSWORD_WINDOW, 0); |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2012 |
|
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
2013 |
_edit_str_net_buf[0] = '\0'; |
8494
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2014 |
Window *w = AllocateWindowDesc(&_ncp_window_desc); |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2015 |
WP(w, chatquerystr_d).afilter = CS_ALPHANUMERAL; |
9224
3db59d95ed2d
(svn r12404) -Codechange: rename the string buffer used for network GUIs to something more unique than what it is called now.
rubidium
parents:
9223
diff
changeset
|
2016 |
InitializeTextBuffer(&WP(w, chatquerystr_d).text, _edit_str_net_buf, min(lengthof(_network_default_company_pass), lengthof(_edit_str_net_buf)), 0); |
8494
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2017 |
} |
88f26cafc858
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium
parents:
8493
diff
changeset
|
2018 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
2019 |
#endif /* ENABLE_NETWORK */ |