From a5d005dd53822b7ec3294d87d8a5255212b9ecb0 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 31 Oct 2009 14:06:16 +0000 Subject: (svn r17920) -Codechange: add a 'filter' for numbers+spaces and use it for the NewGRF parameter list --- src/newgrf_gui.cpp | 2 +- src/string.cpp | 7 ++++--- src/string_type.h | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 1084e978d..c9ac27f3c 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -819,7 +819,7 @@ struct NewGRFWindow : public Window { static char buff[512]; GRFBuildParamList(buff, this->sel, lastof(buff)); SetDParamStr(0, buff); - ShowQueryString(STR_JUST_RAW_STRING, STR_NEWGRF_SETTINGS_PARAMETER_QUERY, 63, 250, this, CS_ALPHANUMERAL, QSF_NONE); + ShowQueryString(STR_JUST_RAW_STRING, STR_NEWGRF_SETTINGS_PARAMETER_QUERY, 63, 250, this, CS_NUMERAL_SPACE, QSF_NONE); break; } diff --git a/src/string.cpp b/src/string.cpp index 6503f8fd1..d9e27857d 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -194,9 +194,10 @@ void strtolower(char *str) bool IsValidChar(WChar key, CharSetFilter afilter) { switch (afilter) { - case CS_ALPHANUMERAL: return IsPrintable(key); - case CS_NUMERAL: return (key >= '0' && key <= '9'); - case CS_ALPHA: return IsPrintable(key) && !(key >= '0' && key <= '9'); + case CS_ALPHANUMERAL: return IsPrintable(key); + case CS_NUMERAL: return (key >= '0' && key <= '9'); + case CS_NUMERAL_SPACE: return (key >= '0' && key <= '9') || key == ' '; + case CS_ALPHA: return IsPrintable(key) && !(key >= '0' && key <= '9'); } return false; diff --git a/src/string_type.h b/src/string_type.h index 66b685ea3..40c1e2dc7 100644 --- a/src/string_type.h +++ b/src/string_type.h @@ -18,6 +18,7 @@ enum CharSetFilter { CS_ALPHANUMERAL, ///< Both numeric and alphabetic and spaces and stuff CS_NUMERAL, ///< Only numeric ones + CS_NUMERAL_SPACE, ///< Only numbers and spaces CS_ALPHA, ///< Only alphabetic values }; -- cgit v1.2.3-54-g00ecf