mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-25 08:22:17 +00:00
Change: Enable dropdown text filter for various dropdown lists.
This commit is contained in:
committed by
Peter Nelson
parent
38b74639be
commit
d685fc97f1
@@ -540,11 +540,11 @@ public:
|
||||
}
|
||||
|
||||
case WID_RV_RAIL_TYPE_DROPDOWN: // Railtype selection dropdown menu
|
||||
ShowDropDownList(this, GetRailTypeDropDownList(true, true), this->sel_railtype, widget);
|
||||
ShowDropDownList(this, GetRailTypeDropDownList(true, true), this->sel_railtype, widget, 0, DropDownOption::Filterable);
|
||||
break;
|
||||
|
||||
case WID_RV_ROAD_TYPE_DROPDOWN: // Roadtype selection dropdown menu
|
||||
ShowDropDownList(this, GetRoadTypeDropDownList(RTTB_ROAD | RTTB_TRAM, true, true), this->sel_roadtype, widget);
|
||||
ShowDropDownList(this, GetRoadTypeDropDownList(RTTB_ROAD | RTTB_TRAM, true, true), this->sel_roadtype, widget, 0, DropDownOption::Filterable);
|
||||
break;
|
||||
|
||||
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
|
||||
|
||||
@@ -1739,7 +1739,7 @@ struct BuildVehicleWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_BV_CARGO_FILTER_DROPDOWN: // Select cargo filtering criteria dropdown menu
|
||||
ShowDropDownList(this, this->BuildCargoDropDownList(), this->cargo_filter_criteria, widget);
|
||||
ShowDropDownList(this, this->BuildCargoDropDownList(), this->cargo_filter_criteria, widget, 0, DropDownOption::Filterable);
|
||||
break;
|
||||
|
||||
case WID_BV_CONFIGURE_BADGES:
|
||||
@@ -1771,7 +1771,7 @@ struct BuildVehicleWindow : Window {
|
||||
default:
|
||||
if (IsInsideMM(widget, this->badge_filters.first, this->badge_filters.second)) {
|
||||
PaletteID palette = SPR_2CCMAP_BASE + Company::Get(_local_company)->GetCompanyRecolourOffset(LS_DEFAULT);
|
||||
ShowDropDownList(this, this->GetWidget<NWidgetBadgeFilter>(widget)->GetDropDownList(palette), -1, widget, 0);
|
||||
ShowDropDownList(this, this->GetWidget<NWidgetBadgeFilter>(widget)->GetDropDownList(palette), -1, widget, 0, DropDownOption::Filterable);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -753,7 +753,7 @@ public:
|
||||
return;
|
||||
|
||||
case WID_GL_FILTER_BY_CARGO: // Select filtering criteria dropdown menu
|
||||
ShowDropDownList(this, this->BuildCargoDropDownList(false), this->cargo_filter_criteria, widget);
|
||||
ShowDropDownList(this, this->BuildCargoDropDownList(false), this->cargo_filter_criteria, widget, 0, DropDownOption::Filterable);
|
||||
break;
|
||||
|
||||
case WID_GL_ALL_VEHICLES: // All vehicles button
|
||||
|
||||
@@ -1795,11 +1795,11 @@ public:
|
||||
break;
|
||||
|
||||
case WID_ID_FILTER_BY_ACC_CARGO: // Cargo filter dropdown
|
||||
ShowDropDownList(this, this->BuildCargoDropDownList(), this->accepted_cargo_filter_criteria, widget);
|
||||
ShowDropDownList(this, this->BuildCargoDropDownList(), this->accepted_cargo_filter_criteria, widget, 0, DropDownOption::Filterable);
|
||||
break;
|
||||
|
||||
case WID_ID_FILTER_BY_PROD_CARGO: // Cargo filter dropdown
|
||||
ShowDropDownList(this, this->BuildCargoDropDownList(), this->produced_cargo_filter_criteria, widget);
|
||||
ShowDropDownList(this, this->BuildCargoDropDownList(), this->produced_cargo_filter_criteria, widget, 0, DropDownOption::Filterable);
|
||||
break;
|
||||
|
||||
case WID_ID_INDUSTRY_LIST: {
|
||||
@@ -3085,7 +3085,7 @@ struct IndustryCargoesWindow : public Window {
|
||||
}
|
||||
if (!lst.empty()) {
|
||||
int selected = (this->ind_cargo >= NUM_INDUSTRYTYPES) ? (int)(this->ind_cargo - NUM_INDUSTRYTYPES) : -1;
|
||||
ShowDropDownList(this, std::move(lst), selected, WID_IC_CARGO_DROPDOWN);
|
||||
ShowDropDownList(this, std::move(lst), selected, WID_IC_CARGO_DROPDOWN, 0, DropDownOption::Filterable);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -3099,7 +3099,7 @@ struct IndustryCargoesWindow : public Window {
|
||||
}
|
||||
if (!lst.empty()) {
|
||||
int selected = (this->ind_cargo < NUM_INDUSTRYTYPES) ? (int)this->ind_cargo : -1;
|
||||
ShowDropDownList(this, std::move(lst), selected, WID_IC_IND_DROPDOWN);
|
||||
ShowDropDownList(this, std::move(lst), selected, WID_IC_IND_DROPDOWN, 0, DropDownOption::Filterable);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -606,7 +606,7 @@ struct MusicTrackSelectionWindow : public Window {
|
||||
|
||||
case WID_MTS_MUSICSET: {
|
||||
int selected = 0;
|
||||
ShowDropDownList(this, BuildSetDropDownList<BaseMusic>(&selected), selected, widget);
|
||||
ShowDropDownList(this, BuildSetDropDownList<BaseMusic>(&selected), selected, widget, 0, DropDownOption::Filterable);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -944,7 +944,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
}
|
||||
|
||||
this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window
|
||||
ShowDropDownList(this, std::move(list), this->preset, WID_NS_PRESET_LIST);
|
||||
ShowDropDownList(this, std::move(list), this->preset, WID_NS_PRESET_LIST, 0, DropDownOption::Filterable);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -527,7 +527,7 @@ void PickerWindow::OnClick(Point pt, WidgetID widget, int)
|
||||
}
|
||||
|
||||
case WID_PW_COLEC_LIST: {
|
||||
ShowDropDownList(this, this->BuildCollectionDropDownList(), -1, widget, 0);
|
||||
ShowDropDownList(this, this->BuildCollectionDropDownList(), -1, widget, 0, DropDownOption::Filterable);
|
||||
CloseWindowById(WC_SELECT_STATION, 0);
|
||||
break;
|
||||
}
|
||||
@@ -566,7 +566,7 @@ void PickerWindow::OnClick(Point pt, WidgetID widget, int)
|
||||
if (IsInsideMM(widget, this->badge_filters.first, this->badge_filters.second)) {
|
||||
/* Houses have recolours but not related to the company colour and other items depend on gamemode. */
|
||||
PaletteID palette = _game_mode != GM_NORMAL || this->callbacks.GetFeature() == GSF_HOUSES ? PAL_NONE : GetCompanyPalette(_local_company);
|
||||
ShowDropDownList(this, this->GetWidget<NWidgetBadgeFilter>(widget)->GetDropDownList(palette), -1, widget, 0);
|
||||
ShowDropDownList(this, this->GetWidget<NWidgetBadgeFilter>(widget)->GetDropDownList(palette), -1, widget, 0, DropDownOption::Filterable);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+14
-4
@@ -1154,18 +1154,28 @@ struct GameOptionsWindow : Window {
|
||||
ShowNetworkContentListWindow(nullptr, CONTENT_TYPE_BASE_MUSIC);
|
||||
break;
|
||||
|
||||
case WID_GO_CURRENCY_DROPDOWN:
|
||||
case WID_GO_AUTOSAVE_DROPDOWN:
|
||||
case WID_GO_LANG_DROPDOWN:
|
||||
case WID_GO_RESOLUTION_DROPDOWN:
|
||||
case WID_GO_REFRESH_RATE_DROPDOWN:
|
||||
case WID_GO_REFRESH_RATE_DROPDOWN: {
|
||||
int selected;
|
||||
DropDownList list = this->BuildDropDownList(widget, &selected);
|
||||
if (!list.empty()) {
|
||||
ShowDropDownList(this, std::move(list), selected, widget);
|
||||
} else {
|
||||
if (widget == WID_GO_RESOLUTION_DROPDOWN) ShowErrorMessage(GetEncodedString(STR_ERROR_RESOLUTION_LIST_FAILED), {}, WL_ERROR);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_GO_CURRENCY_DROPDOWN:
|
||||
case WID_GO_LANG_DROPDOWN:
|
||||
case WID_GO_BASE_GRF_DROPDOWN:
|
||||
case WID_GO_BASE_SFX_DROPDOWN:
|
||||
case WID_GO_BASE_MUSIC_DROPDOWN: {
|
||||
int selected;
|
||||
DropDownList list = this->BuildDropDownList(widget, &selected);
|
||||
if (!list.empty()) {
|
||||
ShowDropDownList(this, std::move(list), selected, widget);
|
||||
ShowDropDownList(this, std::move(list), selected, widget, 0, DropDownOption::Filterable);
|
||||
} else {
|
||||
if (widget == WID_GO_RESOLUTION_DROPDOWN) ShowErrorMessage(GetEncodedString(STR_ERROR_RESOLUTION_LIST_FAILED), {}, WL_ERROR);
|
||||
}
|
||||
|
||||
+1
-1
@@ -665,7 +665,7 @@ public:
|
||||
|
||||
case WID_STL_CARGODROPDOWN:
|
||||
this->filter_expanded = false;
|
||||
ShowDropDownList(this, this->BuildCargoDropDownList(this->filter_expanded), -1, widget, 0, DropDownOption::Persist);
|
||||
ShowDropDownList(this, this->BuildCargoDropDownList(this->filter_expanded), -1, widget, 0, {DropDownOption::Persist, DropDownOption::Filterable});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+13
-8
@@ -107,10 +107,15 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static DropDownOptions GetToolbarDropDownOptions()
|
||||
/**
|
||||
* Get options for toolbar dropdown menus,
|
||||
* @param options Additional options to include.
|
||||
* @return DropDownOptions to use for toolbar dropdown menus.
|
||||
*/
|
||||
static DropDownOptions GetToolbarDropDownOptions(DropDownOptions options = {})
|
||||
{
|
||||
if (_settings_client.gui.toolbar_dropdown_autoselect) return DropDownOption::InstantClose;
|
||||
return {};
|
||||
if (_settings_client.gui.toolbar_dropdown_autoselect) options.Set(DropDownOption::InstantClose).Reset(DropDownOption::Filterable);
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -878,7 +883,7 @@ static CallBackFunction ToolbarZoomOutClick(Window *w)
|
||||
|
||||
static CallBackFunction ToolbarBuildRailClick(Window *w)
|
||||
{
|
||||
ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, GetToolbarDropDownOptions());
|
||||
ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, GetToolbarDropDownOptions(DropDownOption::Filterable));
|
||||
return CallBackFunction::None;
|
||||
}
|
||||
|
||||
@@ -899,7 +904,7 @@ static CallBackFunction MenuClickBuildRail(int index)
|
||||
|
||||
static CallBackFunction ToolbarBuildRoadClick(Window *w)
|
||||
{
|
||||
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, GetToolbarDropDownOptions());
|
||||
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, GetToolbarDropDownOptions(DropDownOption::Filterable));
|
||||
return CallBackFunction::None;
|
||||
}
|
||||
|
||||
@@ -920,7 +925,7 @@ static CallBackFunction MenuClickBuildRoad(int index)
|
||||
|
||||
static CallBackFunction ToolbarBuildTramClick(Window *w)
|
||||
{
|
||||
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, GetToolbarDropDownOptions());
|
||||
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, GetToolbarDropDownOptions(DropDownOption::Filterable));
|
||||
return CallBackFunction::None;
|
||||
}
|
||||
|
||||
@@ -1257,7 +1262,7 @@ static CallBackFunction ToolbarScenGenIndustry(Window *w)
|
||||
|
||||
static CallBackFunction ToolbarScenBuildRoadClick(Window *w)
|
||||
{
|
||||
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, GetToolbarDropDownOptions());
|
||||
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, GetToolbarDropDownOptions(DropDownOption::Filterable));
|
||||
return CallBackFunction::None;
|
||||
}
|
||||
|
||||
@@ -1276,7 +1281,7 @@ static CallBackFunction ToolbarScenBuildRoad(int index)
|
||||
|
||||
static CallBackFunction ToolbarScenBuildTramClick(Window *w)
|
||||
{
|
||||
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, GetToolbarDropDownOptions());
|
||||
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, GetToolbarDropDownOptions(DropDownOption::Filterable));
|
||||
return CallBackFunction::None;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2138,7 +2138,7 @@ public:
|
||||
return;
|
||||
|
||||
case WID_VL_FILTER_BY_CARGO: // Cargo filter dropdown
|
||||
ShowDropDownList(this, this->BuildCargoDropDownList(false), this->cargo_filter_criteria, widget);
|
||||
ShowDropDownList(this, this->BuildCargoDropDownList(false), this->cargo_filter_criteria, widget, 0, DropDownOption::Filterable);
|
||||
break;
|
||||
|
||||
case WID_VL_LIST: { // Matrix to show vehicles
|
||||
|
||||
Reference in New Issue
Block a user