(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.
replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
Darkvater 20 years ago
parent 93c61b9e8f
commit 5109df6f55

@ -925,11 +925,7 @@ static void NetworkInitGameInfo(void)
_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)

@ -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;
}
}

Loading…
Cancel
Save