(svn r2157) - Feature (request): [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
authorDarkvater
Wed, 06 Apr 2005 18:44:34 +0000
changeset 1653 3eed36c12b1d
parent 1652 d8b3ae1b0768
child 1654 6b415f5a42c5
(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.
network.c
network_gui.c
--- a/network.c	Wed Apr 06 15:39:18 2005 +0000
+++ b/network.c	Wed Apr 06 18:44:34 2005 +0000
@@ -925,11 +925,7 @@
 	_network_game_info.map_height = MapSizeY();
 	_network_game_info.map_set = _opt.landscape;
 
-	if (_network_game_info.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;
 
 	// We use _network_client_info[MAX_CLIENT_INFO - 1] to store the server-data in it
 	//  The index is NETWORK_SERVER_INDEX ( = 1)
--- a/network_gui.c	Wed Apr 06 15:39:18 2005 +0000
+++ b/network_gui.c	Wed Apr 06 18:44:34 2005 +0000
@@ -96,7 +96,11 @@
 
 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 @@
 		NetworkAddServer(e->edittext.str);
 		NetworkRebuildHostList();
 	} break;
-
-	case WE_CREATE: {
-		_selected_item = NULL;
-	} break;
 	}
 }
 
@@ -486,7 +486,12 @@
 
 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 @@
 		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 @@
 		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;
 	}
 }