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

@@ -395,7 +395,7 @@ struct NewGRFParametersWindow : public Window {
list.emplace_back(new DropDownListStringItem(GetGRFStringFromGRFText(par_info.value_names.find(i)->second), i, false));
}
ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE);
ShowDropDownListAt(this, std::move(list), old_val, WID_NP_SETTING_DROPDOWN, wi_rect, COLOUR_ORANGE);
}
}
} else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) {
@@ -453,7 +453,7 @@ struct NewGRFParametersWindow : public Window {
void OnDropdownSelect(int widget, int index) override
{
if (widget >= 0) return;
if (widget != WID_NP_SETTING_DROPDOWN) return;
assert(this->clicked_dropdown);
GRFParameterInfo &par_info = this->GetParameterInfo(this->clicked_row);
par_info.SetValue(this->grf_config, index);
@@ -462,7 +462,7 @@ struct NewGRFParametersWindow : public Window {
void OnDropdownClose(Point, int widget, int, bool) override
{
if (widget >= 0) return;
if (widget != WID_NP_SETTING_DROPDOWN) return;
/* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
* the same dropdown button was clicked again, and then not open the dropdown again.
* So, we only remember that it was closed, and process it on the next OnPaint, which is