1
0
Fork 0

(svn r24727) -Fix: In various windows the OSK looked shiny but using it had no effect whatsoever.

release/1.3
frosch 2012-11-13 21:46:37 +00:00
parent 137adb3496
commit 1071d51508
3 changed files with 43 additions and 16 deletions

View File

@ -1342,9 +1342,7 @@ struct AIDebugWindow : public QueryStringBaseWindow {
EventState state = ES_NOT_HANDLED; EventState state = ES_NOT_HANDLED;
switch (this->HandleEditBoxKey(WID_AID_BREAK_STR_EDIT_BOX, key, keycode, state)) { switch (this->HandleEditBoxKey(WID_AID_BREAK_STR_EDIT_BOX, key, keycode, state)) {
case HEBR_EDITING: case HEBR_EDITING:
/* Save the current string to static member so it can be restored next time the window is opened. */ this->OnOSKInput(WID_AID_BREAK_STR_EDIT_BOX);
strecpy(this->break_string, this->edit_str_buf, lastof(this->break_string));
break_string_filter.SetFilterTerm(this->break_string);
break; break;
case HEBR_CANCEL: case HEBR_CANCEL:
@ -1373,6 +1371,15 @@ struct AIDebugWindow : public QueryStringBaseWindow {
return state; 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. * Some data on this window has become invalid.
* @param data Information about the changed data. * @param data Information about the changed data.

View File

@ -697,15 +697,21 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
virtual EventState OnKeyPress(uint16 key, uint16 keycode) virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{ {
EventState state = ES_NOT_HANDLED; EventState state = ES_NOT_HANDLED;
this->HandleEditBoxKey(WID_GL_RANDOM_EDITBOX, key, keycode, state); if (this->HandleEditBoxKey(WID_GL_RANDOM_EDITBOX, key, keycode, state) == HEBR_EDITING) this->OnOSKInput(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);
return state; 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) virtual void OnDropdownSelect(int widget, int index)
{ {
switch (widget) { switch (widget) {

View File

@ -851,18 +851,25 @@ public:
break; break;
default: default:
/* The name is only allowed when it starts with a letter! */ this->OnOSKInput(WID_NG_CLIENT);
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));
}
break; break;
} }
return state; 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) virtual void OnQueryTextFinished(char *str)
{ {
if (!StrEmpty(str)) NetworkAddServer(str); if (!StrEmpty(str)) NetworkAddServer(str);
@ -1183,13 +1190,20 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
break; break;
default: default:
strecpy(_settings_client.network.server_name, this->text.buf, lastof(_settings_client.network.server_name)); this->OnOSKInput(WID_NSS_GAMENAME);
break; break;
} }
return state; 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() 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}; 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};