mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-02 09:40:35 +00:00
(svn r6879) -Codechange: Remove the superflouos argument CharsetFilter parameter from HandleEditBoxKey
as the same information is present in querystr_d->afilter -Also (&((querystr_d *)&WP(w, querystr_d))->text is the same as &WP(w, querystr_d).text
This commit is contained in:
parent
c12a9e19c3
commit
e550bccf15
@ -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);
|
||||
|
2
gui.h
2
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);
|
||||
|
11
misc_gui.c
11
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
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user