summaryrefslogtreecommitdiff
path: root/network_gui.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-04-06 18:44:34 +0000
committerDarkvater <darkvater@openttd.org>2005-04-06 18:44:34 +0000
commit5109df6f55e6fe7f25b4787b27d1f82f861edb23 (patch)
tree4ef7be42843d94cc5352ed8f9933253d6810e764 /network_gui.c
parent93c61b9e8f91f3fc6b5cd77c76b4e461216f13ef (diff)
downloadopenttd-5109df6f55e6fe7f25b4787b27d1f82f861edb23.tar.xz
(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
- Feature: If the to be started server is using a password, draw a red '*' after the set password button to remind the user.
Diffstat (limited to 'network_gui.c')
-rw-r--r--network_gui.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/network_gui.c b/network_gui.c
index 5e0245b99..93f26ae6b 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -96,7 +96,11 @@ void UpdateNetworkGameWindow(bool unselect)
static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
+ case WE_CREATE: /* focus input box */
+ _selected_field = 3;
+ _selected_item = NULL;
+ break;
case WE_PAINT: {
w->disabled_state = 0;
@@ -381,10 +385,6 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
NetworkAddServer(e->edittext.str);
NetworkRebuildHostList();
} break;
-
- case WE_CREATE: {
- _selected_item = NULL;
- } break;
}
}
@@ -486,7 +486,12 @@ enum {
static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
+ case WE_CREATE: /* focus input box */
+ _selected_field = 3;
+ _network_game_info.use_password = (_network_server_password[0] == '\0') ? 0 : 1;
+ break;
+
case WE_PAINT: {
int y = NSSWND_START, pos;
const FiosItem *item;
@@ -507,6 +512,8 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
DrawString(280, 95, STR_NETWORK_NUMBER_OF_CLIENTS, 2);
DrawString(280, 127, STR_NETWORK_LANGUAGE_SPOKEN, 2);
+ if (_network_game_info.use_password) DoDrawString("*", 408, 23, 3);
+
// draw list of maps
pos = w->vscroll.pos;
while (pos < _fios_num + 1) {
@@ -599,29 +606,20 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
break;
case WE_MOUSELOOP:
- if(_selected_field == 3 || _selected_field == 4)
- HandleEditBox(w, _selected_field);
-
+ if (_selected_field == 3)
+ HandleEditBox(w, 3);
break;
case WE_KEYPRESS:
- if(_selected_field != 3)
- break;
- switch (HandleEditBoxKey(w, _selected_field, e)) {
- case 1:
- HandleButtonClick(w, 9);
- break;
- }
+ if (_selected_field == 3)
+ HandleEditBoxKey(w, 3, e);
break;
case WE_ON_EDIT_TEXT: {
const char *b = e->edittext.str;
ttd_strlcpy(_network_server_password, b, sizeof(_network_server_password));
- if (_network_server_password[0] == '\0') {
- _network_game_info.use_password = 0;
- } else {
- _network_game_info.use_password = 1;
- }
+ _network_game_info.use_password = (_network_server_password[0] == '\0') ? 0 : 1;
+ SetWindowDirty(w);
} break;
}
}