Codechange: Add enum items for dynmically created setting dropdowns.

This commit is contained in:
frosch
2023-09-20 21:26:42 +02:00
committed by frosch
parent 39e67b6f4c
commit f40816503f
8 changed files with 26 additions and 20 deletions

View File

@@ -2394,7 +2394,7 @@ struct GameSettingsWindow : Window {
list.emplace_back(new DropDownListStringItem(sd->str_val + i - sd->min, i, false));
}
ShowDropDownListAt(this, std::move(list), value, -1, wi_rect, COLOUR_ORANGE);
ShowDropDownListAt(this, std::move(list), value, WID_GS_SETTING_DROPDOWN, wi_rect, COLOUR_ORANGE);
}
}
this->SetDirty();
@@ -2526,23 +2526,21 @@ struct GameSettingsWindow : Window {
this->InvalidateData();
break;
default:
if (widget < 0) {
/* Deal with drop down boxes on the panel. */
assert(this->valuedropdown_entry != nullptr);
const IntSettingDesc *sd = this->valuedropdown_entry->setting;
assert(sd->flags & SF_GUI_DROPDOWN);
case WID_GS_SETTING_DROPDOWN:
/* Deal with drop down boxes on the panel. */
assert(this->valuedropdown_entry != nullptr);
const IntSettingDesc *sd = this->valuedropdown_entry->setting;
assert(sd->flags & SF_GUI_DROPDOWN);
SetSettingValue(sd, index);
this->SetDirty();
}
SetSettingValue(sd, index);
this->SetDirty();
break;
}
}
void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
{
if (widget >= 0) {
if (widget != WID_GS_SETTING_DROPDOWN) {
/* Normally the default implementation of OnDropdownClose() takes care of
* a few things. We want that behaviour here too, but only for
* "normal" dropdown boxes. The special dropdown boxes added for every