Use separate CharSetFilter types for signed and unsigned decimal
This commit is contained in:
@@ -2811,8 +2811,11 @@ struct GameSettingsWindow : Window {
|
||||
|
||||
this->valuewindow_entry = pe;
|
||||
if (sd->flags & SF_DECIMAL1 || (sd->flags & SF_GUI_VELOCITY && _settings_game.locale.units_velocity == 3)) {
|
||||
CharSetFilter charset_filter = CS_NUMERAL_DECIMAL; //default, only numeric input and decimal point allowed
|
||||
if (sd->min < 0) charset_filter = CS_NUMERAL_DECIMAL_SIGNED; // special case, also allow '-' sign for negative input
|
||||
|
||||
SetDParam(0, value64);
|
||||
ShowQueryString(STR_JUST_DECIMAL1, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL_DECIMAL, QSF_ENABLE_DEFAULT);
|
||||
ShowQueryString(STR_JUST_DECIMAL1, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, charset_filter, QSF_ENABLE_DEFAULT);
|
||||
} else {
|
||||
CharSetFilter charset_filter = CS_NUMERAL; //default, only numeric input allowed
|
||||
if (sd->min < 0) charset_filter = CS_NUMERAL_SIGNED; // special case, also allow '-' sign for negative input
|
||||
|
@@ -602,9 +602,11 @@ bool IsValidChar(WChar key, CharSetFilter afilter)
|
||||
case CS_NUMERAL: return (key >= '0' && key <= '9');
|
||||
case CS_NUMERAL_SIGNED: return (key >= '0' && key <= '9') || key == '-';
|
||||
#if !defined(STRGEN) && !defined(SETTINGSGEN)
|
||||
case CS_NUMERAL_DECIMAL: return (key >= '0' && key <= '9') || key == '.' || key == '-' || key == GetDecimalSeparatorChar();
|
||||
case CS_NUMERAL_DECIMAL: return (key >= '0' && key <= '9') || key == '.' || key == GetDecimalSeparatorChar();
|
||||
case CS_NUMERAL_DECIMAL_SIGNED: return (key >= '0' && key <= '9') || key == '.' || key == '-' || key == GetDecimalSeparatorChar();
|
||||
#else
|
||||
case CS_NUMERAL_DECIMAL: return (key >= '0' && key <= '9') || key == '.' || key == '-';
|
||||
case CS_NUMERAL_DECIMAL: return (key >= '0' && key <= '9') || key == '.';
|
||||
case CS_NUMERAL_DECIMAL_SIGNED: return (key >= '0' && key <= '9') || key == '.' || key == '-';
|
||||
#endif
|
||||
case CS_NUMERAL_SPACE: return (key >= '0' && key <= '9') || key == ' ';
|
||||
case CS_ALPHA: return IsPrintable(key) && !(key >= '0' && key <= '9');
|
||||
|
@@ -27,7 +27,8 @@ enum CharSetFilter {
|
||||
CS_ALPHANUMERAL, ///< Both numeric and alphabetic and spaces and stuff
|
||||
CS_NUMERAL, ///< Only numeric ones
|
||||
CS_NUMERAL_SIGNED, ///< Only numeric ones, and minus/negative
|
||||
CS_NUMERAL_DECIMAL, ///< Only numeric, decimal separaters, and minus/negative
|
||||
CS_NUMERAL_DECIMAL, ///< Only numeric, decimal separaters
|
||||
CS_NUMERAL_DECIMAL_SIGNED, ///< Only numeric, decimal separaters, and minus/negative
|
||||
CS_NUMERAL_SPACE, ///< Only numbers and spaces
|
||||
CS_ALPHA, ///< Only alphabetic values
|
||||
CS_HEXADECIMAL, ///< Only hexadecimal characters
|
||||
|
Reference in New Issue
Block a user