Codechange: remove SettingDescType in lieu of the actual classes
This commit is contained in:
@@ -1167,7 +1167,7 @@ static const void *ResolveVariableAddress(const GameSettings *settings_ptr, cons
|
||||
*/
|
||||
void SettingEntry::SetValueDParams(uint first_param, int32 value) const
|
||||
{
|
||||
if (this->setting->cmd == SDT_BOOLX) {
|
||||
if (this->setting->IsBoolSetting()) {
|
||||
SetDParam(first_param++, value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
|
||||
} else {
|
||||
if ((this->setting->flags & SGF_MULTISTRING) != 0) {
|
||||
@@ -1207,7 +1207,7 @@ void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right,
|
||||
|
||||
SetDParam(0, highlight ? STR_ORANGE_STRING1_WHITE : STR_ORANGE_STRING1_LTBLUE);
|
||||
int32 value = (int32)ReadValue(var, sd->save.conv);
|
||||
if (sd->cmd == SDT_BOOLX) {
|
||||
if (sd->IsBoolSetting()) {
|
||||
/* Draw checkbox for boolean-value either on/off */
|
||||
DrawBoolButton(buttons_left, button_y, value != 0, editable);
|
||||
} else if ((sd->flags & SGF_MULTISTRING) != 0) {
|
||||
@@ -2228,52 +2228,47 @@ struct GameSettingsWindow : Window {
|
||||
this->SetDisplayedHelpText(pe);
|
||||
int32 oldvalue = value;
|
||||
|
||||
switch (sd->cmd) {
|
||||
case SDT_BOOLX: value ^= 1; break;
|
||||
case SDT_ONEOFMANY:
|
||||
case SDT_NUMX: {
|
||||
/* Add a dynamic step-size to the scroller. In a maximum of
|
||||
* 50-steps you should be able to get from min to max,
|
||||
* unless specified otherwise in the 'interval' variable
|
||||
* of the current setting. */
|
||||
uint32 step = (sd->interval == 0) ? ((sd->max - sd->min) / 50) : sd->interval;
|
||||
if (step == 0) step = 1;
|
||||
if (sd->IsBoolSetting()) {
|
||||
value ^= 1;
|
||||
} else {
|
||||
/* Add a dynamic step-size to the scroller. In a maximum of
|
||||
* 50-steps you should be able to get from min to max,
|
||||
* unless specified otherwise in the 'interval' variable
|
||||
* of the current setting. */
|
||||
uint32 step = (sd->interval == 0) ? ((sd->max - sd->min) / 50) : sd->interval;
|
||||
if (step == 0) step = 1;
|
||||
|
||||
/* don't allow too fast scrolling */
|
||||
if ((this->flags & WF_TIMEOUT) && this->timeout_timer > 1) {
|
||||
_left_button_clicked = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Increase or decrease the value and clamp it to extremes */
|
||||
if (x >= SETTING_BUTTON_WIDTH / 2) {
|
||||
value += step;
|
||||
if (sd->min < 0) {
|
||||
assert((int32)sd->max >= 0);
|
||||
if (value > (int32)sd->max) value = (int32)sd->max;
|
||||
} else {
|
||||
if ((uint32)value > sd->max) value = (int32)sd->max;
|
||||
}
|
||||
if (value < sd->min) value = sd->min; // skip between "disabled" and minimum
|
||||
} else {
|
||||
value -= step;
|
||||
if (value < sd->min) value = (sd->flags & SGF_0ISDISABLED) ? 0 : sd->min;
|
||||
}
|
||||
|
||||
/* Set up scroller timeout for numeric values */
|
||||
if (value != oldvalue) {
|
||||
if (this->clicked_entry != nullptr) { // Release previous buttons if any
|
||||
this->clicked_entry->SetButtons(0);
|
||||
}
|
||||
this->clicked_entry = pe;
|
||||
this->clicked_entry->SetButtons((x >= SETTING_BUTTON_WIDTH / 2) != (_current_text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
|
||||
this->SetTimeout();
|
||||
_left_button_clicked = false;
|
||||
}
|
||||
break;
|
||||
/* don't allow too fast scrolling */
|
||||
if ((this->flags & WF_TIMEOUT) && this->timeout_timer > 1) {
|
||||
_left_button_clicked = false;
|
||||
return;
|
||||
}
|
||||
|
||||
default: NOT_REACHED();
|
||||
/* Increase or decrease the value and clamp it to extremes */
|
||||
if (x >= SETTING_BUTTON_WIDTH / 2) {
|
||||
value += step;
|
||||
if (sd->min < 0) {
|
||||
assert((int32)sd->max >= 0);
|
||||
if (value > (int32)sd->max) value = (int32)sd->max;
|
||||
} else {
|
||||
if ((uint32)value > sd->max) value = (int32)sd->max;
|
||||
}
|
||||
if (value < sd->min) value = sd->min; // skip between "disabled" and minimum
|
||||
} else {
|
||||
value -= step;
|
||||
if (value < sd->min) value = (sd->flags & SGF_0ISDISABLED) ? 0 : sd->min;
|
||||
}
|
||||
|
||||
/* Set up scroller timeout for numeric values */
|
||||
if (value != oldvalue) {
|
||||
if (this->clicked_entry != nullptr) { // Release previous buttons if any
|
||||
this->clicked_entry->SetButtons(0);
|
||||
}
|
||||
this->clicked_entry = pe;
|
||||
this->clicked_entry->SetButtons((x >= SETTING_BUTTON_WIDTH / 2) != (_current_text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
|
||||
this->SetTimeout();
|
||||
_left_button_clicked = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (value != oldvalue) {
|
||||
@@ -2282,7 +2277,7 @@ struct GameSettingsWindow : Window {
|
||||
}
|
||||
} else {
|
||||
/* Only open editbox if clicked for the second time, and only for types where it is sensible for. */
|
||||
if (this->last_clicked == pe && sd->cmd != SDT_BOOLX && !(sd->flags & SGF_MULTISTRING)) {
|
||||
if (this->last_clicked == pe && !sd->IsBoolSetting() && !(sd->flags & SGF_MULTISTRING)) {
|
||||
int64 value64 = value;
|
||||
/* Show the correct currency-translated value */
|
||||
if (sd->flags & SGF_CURRENCY) value64 *= _currency->rate;
|
||||
|
Reference in New Issue
Block a user