summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--genworld_gui.c5
-rw-r--r--gui.h2
-rw-r--r--misc_gui.c11
-rw-r--r--network_gui.c9
4 files changed, 16 insertions, 11 deletions
diff --git a/genworld_gui.c b/genworld_gui.c
index 36f7473a5..304540fc6 100644
--- a/genworld_gui.c
+++ b/genworld_gui.c
@@ -321,7 +321,7 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
case 16: // Random seed
_patches_newgame.generation_seed = InteractiveRandom();
ttd_strlcpy(_edit_str_buf, str_fmt("%u", _patches_newgame.generation_seed), lengthof(_edit_str_buf));
- UpdateTextBufferSize(&((querystr_d *)&WP(w, querystr_d))->text);
+ UpdateTextBufferSize(&WP(w, querystr_d).text);
SetWindowDirty(w);
break;
case 17: // Generate
@@ -395,7 +395,7 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
break;
case WE_KEYPRESS:
- HandleEditBoxKey(w, &WP(w, querystr_d), SEED_EDIT, e, CS_NUMERAL);
+ HandleEditBoxKey(w, &WP(w, querystr_d), SEED_EDIT, e);
/* the seed is unsigned, therefore atoi cannot be used.
* As 2^32 - 1 (MAX_UVALUE(uint32)) is a 'magic' value
* (use random seed) it should not be possible to be
@@ -518,6 +518,7 @@ static void _ShowGenerateLandscape(glwp_modes mode)
querystr->text.maxwidth = 120;
querystr->text.buf = _edit_str_buf;
querystr->caption = STR_NULL;
+ querystr->afilter = CS_NUMERAL;
UpdateTextBufferSize(&querystr->text);
InvalidateWindow(WC_GENERATE_LANDSCAPE, mode);
diff --git a/gui.h b/gui.h
index af7028c5d..46f0c3996 100644
--- a/gui.h
+++ b/gui.h
@@ -104,7 +104,7 @@ void ShowCheatWindow(void);
void DrawEditBox(Window *w, querystr_d *string, int wid);
void HandleEditBox(Window *w, querystr_d *string, int wid);
-int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *we, CharSetFilter afilter);
+int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *we);
bool HandleCaret(Textbuf *tb);
void DeleteTextBufferAll(Textbuf *tb);
diff --git a/misc_gui.c b/misc_gui.c
index 68e125e4f..7df37a8d3 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -901,7 +901,7 @@ void UpdateTextBufferSize(Textbuf *tb)
tb->caretxoffs = tb->width;
}
-int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *e, CharSetFilter afilter)
+int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *e)
{
e->we.keypress.cont = false;
@@ -925,11 +925,11 @@ int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *e, Cha
InvalidateWidget(w, wid);
break;
default:
- if (IsValidAsciiChar(e->we.keypress.ascii, afilter)) {
+ if (IsValidAsciiChar(e->we.keypress.ascii, string->afilter)) {
if (InsertTextBufferChar(&string->text, e->we.keypress.ascii))
InvalidateWidget(w, wid);
} else { // key wasn't caught. Continue only if standard entry specified
- e->we.keypress.cont = (afilter == CS_ALPHANUMERAL);
+ e->we.keypress.cont = (string->afilter == CS_ALPHANUMERAL);
}
}
@@ -1019,7 +1019,7 @@ press_ok:;
} break;
case WE_KEYPRESS: {
- switch (HandleEditBoxKey(w, &WP(w, querystr_d), 5, e, WP(w, querystr_d).afilter)) {
+ switch (HandleEditBoxKey(w, &WP(w, querystr_d), 5, e)) {
case 1: // Return
goto press_ok;
case 2: // Escape
@@ -1455,7 +1455,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
}
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
- if (HandleEditBoxKey(w, &WP(w, querystr_d), 10, e, CS_ALPHANUMERAL) == 1) /* Press Enter */
+ if (HandleEditBoxKey(w, &WP(w, querystr_d), 10, e) == 1) /* Press Enter */
HandleButtonClick(w, 12);
}
break;
@@ -1580,6 +1580,7 @@ void ShowSaveLoadDialog(int mode)
WP(w,querystr_d).text.maxlength = lengthof(_edit_str_buf);
WP(w,querystr_d).text.maxwidth = 240;
WP(w,querystr_d).text.buf = _edit_str_buf;
+ WP(w,querystr_d).afilter = CS_ALPHANUMERAL;
UpdateTextBufferSize(&WP(w, querystr_d).text);
// pause is only used in single-player, non-editor mode, non-menu mode. It
diff --git a/network_gui.c b/network_gui.c
index 9f46912cc..0e45846a3 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -473,7 +473,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
break;
}
- if (HandleEditBoxKey(w, &WP(w, network_ql_d).q, 3, e, CS_ALPHANUMERAL) == 1) break; // enter pressed
+ if (HandleEditBoxKey(w, &WP(w, network_ql_d).q, 3, e) == 1) break; // enter pressed
// The name is only allowed when it starts with a letter!
if (_edit_str_buf[0] != '\0' && _edit_str_buf[0] != ' ') {
@@ -567,6 +567,7 @@ void ShowNetworkGameWindow(void)
querystr->text.maxlength = lengthof(_edit_str_buf);
querystr->text.maxwidth = 120;
querystr->text.buf = _edit_str_buf;
+ querystr->afilter = CS_ALPHANUMERAL;
UpdateTextBufferSize(&querystr->text);
UpdateNetworkGameWindow(true);
@@ -716,7 +717,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
case WE_KEYPRESS:
if (nd->field == 3) {
- if (HandleEditBoxKey(w, &WP(w, network_ql_d).q, 3, e, CS_ALPHANUMERAL) == 1) break; // enter pressed
+ if (HandleEditBoxKey(w, &WP(w, network_ql_d).q, 3, e) == 1) break; // enter pressed
ttd_strlcpy(_network_server_name, WP(w, network_ql_d).q.text.buf, sizeof(_network_server_name));
UpdateTextBufferSize(&WP(w, network_ql_d).q.text);
@@ -784,6 +785,7 @@ static void ShowNetworkStartServerWindow(void)
WP(w, network_ql_d).q.text.maxlength = lengthof(_edit_str_buf);
WP(w, network_ql_d).q.text.maxwidth = 160;
WP(w, network_ql_d).q.text.buf = _edit_str_buf;
+ WP(w, network_ql_d).q.afilter = CS_ALPHANUMERAL;
UpdateTextBufferSize(&WP(w, network_ql_d).q.text);
}
@@ -1665,7 +1667,7 @@ static void ChatWindowWndProc(Window *w, WindowEvent *e)
ChatTabCompletion(w);
} else {
_chat_tab_completion_active = false;
- switch (HandleEditBoxKey(w, &WP(w, querystr_d), 2, e, CS_ALPHANUMERAL)) {
+ switch (HandleEditBoxKey(w, &WP(w, querystr_d), 2, e)) {
case 1: { /* Return */
DestType type = GB(WP(w, querystr_d).caption, 0, 8);
byte dest = GB(WP(w, querystr_d).caption, 8, 8);
@@ -1714,6 +1716,7 @@ void ShowNetworkChatQueryWindow(DestType type, byte dest)
WP(w,querystr_d).caption = GB(type, 0, 8) | (dest << 8); // Misuse of caption
WP(w,querystr_d).wnd_class = WC_MAIN_TOOLBAR;
WP(w,querystr_d).wnd_num = 0;
+ WP(w,querystr_d).afilter = CS_ALPHANUMERAL;
WP(w,querystr_d).text.caret = false;
WP(w,querystr_d).text.maxlength = lengthof(_edit_str_buf);
WP(w,querystr_d).text.maxwidth = w->widget[2].right - w->widget[2].left - 2; // widget[1] is the "text box"