Fix #10023: Allow negative input in text fields when needed (#10112)

This commit is contained in:
hallonsoda79
2022-11-02 20:54:07 +01:00
committed by GitHub
parent 71663bbaee
commit 0d51460f27
3 changed files with 11 additions and 6 deletions

View File

@@ -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);
}