From 1071d51508695978adcf9a184e0a26a65fff2705 Mon Sep 17 00:00:00 2001 From: frosch Date: Tue, 13 Nov 2012 21:46:37 +0000 Subject: (svn r24727) -Fix: In various windows the OSK looked shiny but using it had no effect whatsoever. --- src/ai/ai_gui.cpp | 13 ++++++++++--- src/genworld_gui.cpp | 18 ++++++++++++------ src/network/network_gui.cpp | 28 +++++++++++++++++++++------- 3 files changed, 43 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index a1c0616c2..98feba077 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -1342,9 +1342,7 @@ struct AIDebugWindow : public QueryStringBaseWindow { EventState state = ES_NOT_HANDLED; switch (this->HandleEditBoxKey(WID_AID_BREAK_STR_EDIT_BOX, key, keycode, state)) { case HEBR_EDITING: - /* Save the current string to static member so it can be restored next time the window is opened. */ - strecpy(this->break_string, this->edit_str_buf, lastof(this->break_string)); - break_string_filter.SetFilterTerm(this->break_string); + this->OnOSKInput(WID_AID_BREAK_STR_EDIT_BOX); break; case HEBR_CANCEL: @@ -1373,6 +1371,15 @@ struct AIDebugWindow : public QueryStringBaseWindow { return state; } + virtual void OnOSKInput(int wid) + { + if (wid == WID_AID_BREAK_STR_EDIT_BOX) { + /* Save the current string to static member so it can be restored next time the window is opened. */ + strecpy(this->break_string, this->edit_str_buf, lastof(this->break_string)); + break_string_filter.SetFilterTerm(this->break_string); + } + } + /** * Some data on this window has become invalid. * @param data Information about the changed data. diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 4eb1f8f51..36b25dbff 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -697,15 +697,21 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow { virtual EventState OnKeyPress(uint16 key, uint16 keycode) { EventState state = ES_NOT_HANDLED; - this->HandleEditBoxKey(WID_GL_RANDOM_EDITBOX, key, keycode, state); - /* the seed is unsigned, therefore atoi cannot be used. - * As UINT32_MAX is a 'magic' value (use random seed) it - * should not be possible to be entered into the input - * field; the generate seed button can be used instead. */ - _settings_newgame.game_creation.generation_seed = minu(strtoul(this->edit_str_buf, NULL, 10), UINT32_MAX - 1); + if (this->HandleEditBoxKey(WID_GL_RANDOM_EDITBOX, key, keycode, state) == HEBR_EDITING) this->OnOSKInput(WID_GL_RANDOM_EDITBOX); return state; } + virtual void OnOSKInput(int wid) + { + if (wid == WID_GL_RANDOM_EDITBOX) { + /* the seed is unsigned, therefore atoi cannot be used. + * As UINT32_MAX is a 'magic' value (use random seed) it + * should not be possible to be entered into the input + * field; the generate seed button can be used instead. */ + _settings_newgame.game_creation.generation_seed = minu(strtoul(this->edit_str_buf, NULL, 10), UINT32_MAX - 1); + } + } + virtual void OnDropdownSelect(int widget, int index) { switch (widget) { diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index d01f20e28..99256bda9 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -851,18 +851,25 @@ public: break; default: - /* The name is only allowed when it starts with a letter! */ - if (!StrEmpty(this->edit_str_buf) && this->edit_str_buf[0] != ' ') { - strecpy(_settings_client.network.client_name, this->edit_str_buf, lastof(_settings_client.network.client_name)); - } else { - strecpy(_settings_client.network.client_name, "Player", lastof(_settings_client.network.client_name)); - } + this->OnOSKInput(WID_NG_CLIENT); break; } return state; } + virtual void OnOSKInput(int wid) + { + if (wid == WID_NG_CLIENT) { + /* The name is only allowed when it starts with a letter! */ + if (!StrEmpty(this->edit_str_buf) && this->edit_str_buf[0] != ' ') { + strecpy(_settings_client.network.client_name, this->edit_str_buf, lastof(_settings_client.network.client_name)); + } else { + strecpy(_settings_client.network.client_name, "Player", lastof(_settings_client.network.client_name)); + } + } + } + virtual void OnQueryTextFinished(char *str) { if (!StrEmpty(str)) NetworkAddServer(str); @@ -1183,13 +1190,20 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow { break; default: - strecpy(_settings_client.network.server_name, this->text.buf, lastof(_settings_client.network.server_name)); + this->OnOSKInput(WID_NSS_GAMENAME); break; } return state; } + virtual void OnOSKInput(int wid) + { + if (wid == WID_NSS_GAMENAME) { + strecpy(_settings_client.network.server_name, this->text.buf, lastof(_settings_client.network.server_name)); + } + } + virtual void OnTimeout() { static const int raise_widgets[] = {WID_NSS_CLIENTS_BTND, WID_NSS_CLIENTS_BTNU, WID_NSS_COMPANIES_BTND, WID_NSS_COMPANIES_BTNU, WID_NSS_SPECTATORS_BTND, WID_NSS_SPECTATORS_BTNU, WIDGET_LIST_END}; -- cgit v1.2.3-70-g09d2