mirror of https://github.com/OpenTTD/OpenTTD.git
parent
71663bbaee
commit
0d51460f27
|
@ -2288,10 +2288,13 @@ struct GameSettingsWindow : Window {
|
|||
/* Show the correct currency-translated value */
|
||||
if (sd->flags & SF_GUI_CURRENCY) value64 *= _currency->rate;
|
||||
|
||||
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
|
||||
|
||||
this->valuewindow_entry = pe;
|
||||
SetDParam(0, value64);
|
||||
/* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */
|
||||
ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
|
||||
ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, charset_filter, QSF_ENABLE_DEFAULT);
|
||||
}
|
||||
this->SetDisplayedHelpText(pe);
|
||||
}
|
||||
|
|
|
@ -497,6 +497,7 @@ bool IsValidChar(WChar key, CharSetFilter afilter)
|
|||
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_NUMERAL_SIGNED: return (key >= '0' && key <= '9') || key == '-';
|
||||
case CS_ALPHA: return IsPrintable(key) && !(key >= '0' && key <= '9');
|
||||
case CS_HEXADECIMAL: return (key >= '0' && key <= '9') || (key >= 'a' && key <= 'f') || (key >= 'A' && key <= 'F');
|
||||
default: NOT_REACHED();
|
||||
|
|
|
@ -27,6 +27,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_NUMERAL_SIGNED, ///< Only numbers and '-' for negative values
|
||||
CS_ALPHA, ///< Only alphabetic values
|
||||
CS_HEXADECIMAL, ///< Only hexadecimal characters
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue