mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r25089) -Codechange: Move CharSetFilter from QueryString to Textbuf.
This commit is contained in:
parent
9cad36865f
commit
579ee7a592
|
@ -266,7 +266,6 @@ public:
|
|||
|
||||
this->querystrings[WID_SL_SAVE_OSK_TITLE] = &this->filename_editbox;
|
||||
this->filename_editbox.ok_button = WID_SL_SAVE_GAME;
|
||||
this->filename_editbox.afilter = CS_ALPHANUMERAL;
|
||||
|
||||
this->CreateNestedTree(desc, true);
|
||||
if (mode == SLD_LOAD_GAME) this->GetWidget<NWidgetStacked>(WID_SL_CONTENT_DOWNLOAD_SEL)->SetDisplayedPlane(SZSP_HORIZONTAL);
|
||||
|
|
|
@ -320,7 +320,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
this->querystrings[WID_GL_RANDOM_EDITBOX] = &this->seed_editbox;
|
||||
this->seed_editbox.text.Print("%u", _settings_newgame.game_creation.generation_seed);
|
||||
this->seed_editbox.caption = STR_NULL;
|
||||
this->seed_editbox.afilter = CS_NUMERAL;
|
||||
this->seed_editbox.text.afilter = CS_NUMERAL;
|
||||
|
||||
this->mode = (GenenerateLandscapeWindowMode)this->window_number;
|
||||
|
||||
|
|
|
@ -764,7 +764,7 @@ HandleEditBoxResult QueryString::HandleEditBoxKey(Window *w, int wid, uint16 key
|
|||
break;
|
||||
|
||||
default:
|
||||
if (IsValidChar(key, this->afilter)) {
|
||||
if (IsValidChar(key, this->text.afilter)) {
|
||||
edited = this->text.InsertChar(key);
|
||||
} else {
|
||||
state = ES_NOT_HANDLED;
|
||||
|
@ -889,7 +889,7 @@ struct QueryStringWindow : public Window
|
|||
this->editbox.caption = caption;
|
||||
this->editbox.cancel_button = WID_QS_CANCEL;
|
||||
this->editbox.ok_button = WID_QS_OK;
|
||||
this->editbox.afilter = afilter;
|
||||
this->editbox.text.afilter = afilter;
|
||||
this->flags = flags;
|
||||
|
||||
this->InitNested(desc, WN_QUERY_STRING);
|
||||
|
|
|
@ -303,7 +303,6 @@ struct NetworkChatWindow : public Window {
|
|||
this->querystrings[WID_NC_TEXTBOX] = &this->message_editbox;
|
||||
this->message_editbox.cancel_button = WID_NC_CLOSE;
|
||||
this->message_editbox.ok_button = WID_NC_SENDBUTTON;
|
||||
this->message_editbox.afilter = CS_ALPHANUMERAL;
|
||||
|
||||
static const StringID chat_captions[] = {
|
||||
STR_NETWORK_CHAT_ALL_CAPTION,
|
||||
|
|
|
@ -486,7 +486,6 @@ public:
|
|||
|
||||
this->querystrings[WID_NCL_FILTER] = &this->filter_editbox;
|
||||
this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
|
||||
this->filter_editbox.afilter = CS_ALPHANUMERAL;
|
||||
this->SetFocusedWidget(WID_NCL_FILTER);
|
||||
this->SetWidgetDisabledState(WID_NCL_SEARCH_EXTERNAL, this->auto_select);
|
||||
|
||||
|
|
|
@ -454,7 +454,6 @@ public:
|
|||
|
||||
this->querystrings[WID_NG_CLIENT] = &this->name_editbox;
|
||||
this->name_editbox.text.Assign(_settings_client.network.client_name);
|
||||
this->name_editbox.afilter = CS_ALPHANUMERAL;
|
||||
|
||||
this->querystrings[WID_NG_FILTER] = &this->filter_editbox;
|
||||
this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
|
||||
|
@ -1042,7 +1041,6 @@ struct NetworkStartServerWindow : public Window {
|
|||
this->querystrings[WID_NSS_GAMENAME] = &this->name_editbox;
|
||||
this->name_editbox.text.Assign(_settings_client.network.server_name);
|
||||
|
||||
this->name_editbox.afilter = CS_ALPHANUMERAL;
|
||||
this->SetFocusedWidget(WID_NSS_GAMENAME);
|
||||
}
|
||||
|
||||
|
@ -2147,7 +2145,6 @@ struct NetworkCompanyPasswordWindow : public Window {
|
|||
this->querystrings[WID_NCP_PASSWORD] = &this->password_editbox;
|
||||
this->password_editbox.cancel_button = WID_NCP_CANCEL;
|
||||
this->password_editbox.ok_button = WID_NCP_OK;
|
||||
this->password_editbox.afilter = CS_ALPHANUMERAL;
|
||||
this->SetFocusedWidget(WID_NCP_PASSWORD);
|
||||
}
|
||||
|
||||
|
|
|
@ -83,9 +83,9 @@ struct OskWindow : public Window {
|
|||
|
||||
for (uint i = 0; i < OSK_KEYBOARD_ENTRIES; i++) {
|
||||
this->SetWidgetDisabledState(WID_OSK_LETTERS + i,
|
||||
!IsValidChar(_keyboard[this->shift][i], this->qs->afilter) || _keyboard[this->shift][i] == ' ');
|
||||
!IsValidChar(_keyboard[this->shift][i], this->qs->text.afilter) || _keyboard[this->shift][i] == ' ');
|
||||
}
|
||||
this->SetWidgetDisabledState(WID_OSK_SPACE, !IsValidChar(' ', this->qs->afilter));
|
||||
this->SetWidgetDisabledState(WID_OSK_SPACE, !IsValidChar(' ', this->qs->text.afilter));
|
||||
|
||||
this->SetWidgetLoweredState(WID_OSK_SHIFT, HasBit(_keystate, KEYS_SHIFT));
|
||||
this->SetWidgetLoweredState(WID_OSK_CAPS, HasBit(_keystate, KEYS_CAPS));
|
||||
|
@ -113,7 +113,7 @@ struct OskWindow : public Window {
|
|||
if (widget >= WID_OSK_LETTERS) {
|
||||
WChar c = _keyboard[this->shift][widget - WID_OSK_LETTERS];
|
||||
|
||||
if (!IsValidChar(c, this->qs->afilter)) return;
|
||||
if (!IsValidChar(c, this->qs->text.afilter)) return;
|
||||
|
||||
if (this->qs->text.InsertChar(c)) this->OnEditboxChanged(WID_OSK_TEXT);
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ struct QueryString {
|
|||
int cancel_button; ///< Widget button of parent window to simulate when pressing CANCEL in OSK.
|
||||
Textbuf text;
|
||||
const char *orig;
|
||||
CharSetFilter afilter;
|
||||
bool handled;
|
||||
|
||||
/**
|
||||
|
|
|
@ -160,7 +160,6 @@ struct SignListWindow : Window, SignList {
|
|||
this->querystrings[WID_SIL_FILTER_TEXT] = &this->filter_editbox;
|
||||
this->filter_editbox.ok_button = WID_SIL_FILTER_ENTER_BTN;
|
||||
this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
|
||||
this->filter_editbox.afilter = CS_ALPHANUMERAL;
|
||||
|
||||
/* Initialize the filtering variables */
|
||||
this->SetFilterString("");
|
||||
|
@ -419,7 +418,6 @@ struct SignWindow : Window, SignList {
|
|||
this->name_editbox.caption = STR_EDIT_SIGN_CAPTION;
|
||||
this->name_editbox.cancel_button = WID_QES_CANCEL;
|
||||
this->name_editbox.ok_button = WID_QES_OK;
|
||||
this->name_editbox.afilter = CS_ALPHANUMERAL;
|
||||
|
||||
this->InitNested(desc, WN_QUERY_STRING_SIGN);
|
||||
|
||||
|
|
|
@ -364,6 +364,7 @@ Textbuf::Textbuf(uint16 max_bytes, uint16 max_chars)
|
|||
assert(max_bytes != 0);
|
||||
assert(max_chars != 0);
|
||||
|
||||
this->afilter = CS_ALPHANUMERAL;
|
||||
this->max_bytes = max_bytes;
|
||||
this->max_chars = max_chars == UINT16_MAX ? max_bytes : max_chars;
|
||||
this->caret = true;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
/** Helper/buffer for input fields. */
|
||||
struct Textbuf {
|
||||
CharSetFilter afilter; ///< Allowed characters
|
||||
char * const buf; ///< buffer in which text is saved
|
||||
uint16 max_bytes; ///< the maximum size of the buffer in bytes (including terminating '\0')
|
||||
uint16 max_chars; ///< the maximum size of the buffer in characters (including terminating '\0')
|
||||
|
|
Loading…
Reference in New Issue